Refactor (#6559)
This commit is contained in:
parent
3b1b8a7da2
commit
fdc381e501
@ -27,22 +27,25 @@ function update_script() {
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
|
||||
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
|
||||
msg_info "Updating ${APP} to v${RELEASE}"
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
if [[ ! -f ~/.privatebin ]] || [[ "${RELEASE}" != "$(cat ~/.privatebin)" ]]; then
|
||||
msg_info "Creating backup"
|
||||
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")
|
||||
$STD unzip ${RELEASE}.zip
|
||||
msg_ok "Backup created"
|
||||
|
||||
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
|
||||
chown -R www-data:www-data /opt/privatebin
|
||||
chmod -R 0755 /opt/privatebin/data
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
rm -rf ${RELEASE}.zip PrivateBin-${RELEASE}
|
||||
chmod -R 0755 /opt/privatebin/data}
|
||||
systemctl reload nginx php8.2-fpm
|
||||
msg_ok "Updated ${APP} to v${RELEASE}"
|
||||
msg_ok "Configured ${APP}"
|
||||
|
||||
msg_ok "Successfully updated"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
||||
fi
|
||||
|
@ -16,20 +16,11 @@ update_os
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt-get install -y \
|
||||
nginx \
|
||||
php8.2-fpm \
|
||||
php8.2-{common,cli,gd,mbstring,xml,fpm,curl,zip} \
|
||||
openssl
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Installing PrivateBin"
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/PrivateBin/PrivateBin/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
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"
|
||||
PHP_VERSION="8.2" PHP_MODULE="common,fpm" setup_php
|
||||
fetch_and_deploy_gh_release "privatebin" "PrivateBin/PrivateBin" "tarball"
|
||||
|
||||
msg_info "Generating Universal SSL Certificate"
|
||||
mkdir -p /etc/ssl/privatebin
|
||||
@ -96,12 +87,10 @@ rm -f /etc/nginx/sites-enabled/default
|
||||
systemctl reload nginx
|
||||
msg_ok "Nginx Configured"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
||||
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 autoclean
|
||||
msg_ok "Cleaned"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
Loading…
x
Reference in New Issue
Block a user