This commit is contained in:
Slaviša Arežina 2025-08-04 16:46:32 +02:00 committed by GitHub
parent 3b1b8a7da2
commit fdc381e501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 26 deletions

View File

@ -27,22 +27,25 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
RELEASE=$(curl -fsSL https://api.github.com/repos/PrivateBin/PrivateBin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') RELEASE=$(curl -fsSL https://api.github.com/repos/PrivateBin/PrivateBin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then if [[ ! -f ~/.privatebin ]] || [[ "${RELEASE}" != "$(cat ~/.privatebin)" ]]; then
msg_info "Updating ${APP} to v${RELEASE}" msg_info "Creating backup"
echo "${RELEASE}" >/opt/${APP}_version.txt
cp -f /opt/privatebin/cfg/conf.php /tmp/privatebin_conf.bak cp -f /opt/privatebin/cfg/conf.php /tmp/privatebin_conf.bak
curl -fsSL "https://github.com/PrivateBin/PrivateBin/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/PrivateBin/PrivateBin/archive/refs/tags/${RELEASE}.zip") msg_ok "Backup created"
$STD unzip ${RELEASE}.zip
rm -rf /opt/privatebin/* rm -rf /opt/privatebin/*
mv PrivateBin-${RELEASE}/* /opt/privatebin/ fetch_and_deploy_gh_release "privatebin" "PrivateBin/PrivateBin" "tarball"
msg_info "Configuring ${APP}"
mkdir -p /opt/privatebin/data
mv /tmp/privatebin_conf.bak /opt/privatebin/cfg/conf.php mv /tmp/privatebin_conf.bak /opt/privatebin/cfg/conf.php
chown -R www-data:www-data /opt/privatebin chown -R www-data:www-data /opt/privatebin
chmod -R 0755 /opt/privatebin/data chmod -R 0755 /opt/privatebin/data}
echo "${RELEASE}" >/opt/${APP}_version.txt
rm -rf ${RELEASE}.zip PrivateBin-${RELEASE}
systemctl reload nginx php8.2-fpm systemctl reload nginx php8.2-fpm
msg_ok "Updated ${APP} to v${RELEASE}" msg_ok "Configured ${APP}"
msg_ok "Successfully updated"
else else
msg_ok "No update required. ${APP} is already at v${RELEASE}" msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi fi

View File

@ -16,20 +16,11 @@ update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt-get install -y \
nginx \ nginx \
php8.2-fpm \
php8.2-{common,cli,gd,mbstring,xml,fpm,curl,zip} \
openssl openssl
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
msg_info "Installing PrivateBin" PHP_VERSION="8.2" PHP_MODULE="common,fpm" setup_php
RELEASE=$(curl -fsSL https://api.github.com/repos/PrivateBin/PrivateBin/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') fetch_and_deploy_gh_release "privatebin" "PrivateBin/PrivateBin" "tarball"
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
mkdir -p /opt/privatebin
cd /opt/privatebin
curl -fsSL "https://github.com/PrivateBin/PrivateBin/archive/refs/tags/${RELEASE}.zip" -o "${RELEASE}.zip"
$STD unzip ${RELEASE}.zip
mv PrivateBin-${RELEASE}/* .
msg_ok "Installed PrivateBin"
msg_info "Generating Universal SSL Certificate" msg_info "Generating Universal SSL Certificate"
mkdir -p /etc/ssl/privatebin mkdir -p /etc/ssl/privatebin
@ -96,12 +87,10 @@ rm -f /etc/nginx/sites-enabled/default
systemctl reload nginx systemctl reload nginx
msg_ok "Nginx Configured" msg_ok "Nginx Configured"
motd_ssh
customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf /opt/privatebin/${RELEASE}.zip
rm -rf /opt/privatebin/PrivateBin-${RELEASE}
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"
motd_ssh
customize