From d4b9bc86e8fa2f476e7e694146ae699aef25ab59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Sat, 13 Jun 2026 18:43:15 +0200 Subject: [PATCH] Refactor A-B (#15075) --- ct/2fauth.sh | 16 ++++++++++------ ct/adventurelog.sh | 16 ++++++---------- ct/ampache.sh | 18 +++++------------- ct/anchor.sh | 7 ++----- ct/anytype-server.sh | 9 ++------- ct/apache-tomcat.sh | 20 ++++++++------------ ct/babybuddy.sh | 5 +++-- ct/baikal.sh | 13 +++++-------- ct/bambuddy.sh | 24 ++++++------------------ ct/bar-assistant.sh | 26 +++++++++++--------------- ct/baserow.sh | 19 ++++++------------- ct/bentopdf.sh | 17 ++++++----------- ct/bichon.sh | 14 +++++++------- ct/bitmagnet.sh | 14 ++++++-------- ct/blocky.sh | 10 ++-------- ct/bookstack.sh | 17 +++++------------ ct/bytestash.sh | 21 +++------------------ 17 files changed, 93 insertions(+), 173 deletions(-) diff --git a/ct/2fauth.sh b/ct/2fauth.sh index 3906ec971..506f140d8 100644 --- a/ct/2fauth.sh +++ b/ct/2fauth.sh @@ -35,8 +35,10 @@ function update_script() { $STD apt -y upgrade msg_info "Creating Backup" - rm -rf /opt/2fauth-backup - mv /opt/2fauth /opt/2fauth-backup + create_backup \ + /opt/2fauth/.env \ + /opt/2fauth/storage + if ! dpkg -l | grep -q 'php8.4'; then cp /etc/nginx/conf.d/2fauth.conf /etc/nginx/conf.d/2fauth.conf.bak fi @@ -46,11 +48,13 @@ function update_script() { PHP_VERSION="8.4" PHP_FPM="YES" setup_php sed -i 's/php8\.[0-9]/php8.4/g' /etc/nginx/conf.d/2fauth.conf fi + fetch_and_deploy_gh_release "2fauth" "Bubka/2FAuth" "tarball" setup_composer - cp /opt/2fauth-backup/.env /opt/2fauth/.env - cp -r /opt/2fauth-backup/storage /opt/2fauth/storage - cd /opt/2fauth || return + restore_backup + + msg_info "Configuring 2FAuth" + cd /opt/2fauth export COMPOSER_ALLOW_SUPERUSER=1 $STD composer install --no-dev --prefer-dist php artisan 2fauth:install @@ -58,7 +62,7 @@ function update_script() { chmod -R 755 /opt/2fauth $STD systemctl restart php8.4-fpm $STD systemctl restart nginx - rm -rf /opt/2fauth-backup + msg_ok "Configured 2FAuth" msg_ok "Updated successfully!" fi exit diff --git a/ct/adventurelog.sh b/ct/adventurelog.sh index 4b7825bfd..e61c7f2da 100644 --- a/ct/adventurelog.sh +++ b/ct/adventurelog.sh @@ -35,10 +35,8 @@ function update_script() { systemctl stop adventurelog-frontend msg_ok "Services Stopped" - msg_info "Backup Old Installation" - cp -r /opt/adventurelog /opt/adventurelog-backup - rm -rf /opt/adventurelog - msg_ok "Backup done" + create_backup /opt/adventurelog/backend/server/.env \ + /opt/adventurelog/backend/server/media fetch_and_deploy_gh_release "adventurelog" "seanmorley15/adventurelog" "tarball" PYTHON_VERSION="3.13" setup_uv @@ -47,9 +45,9 @@ function update_script() { $STD sudo -u postgres psql -d adventurelog_db -c "CREATE EXTENSION IF NOT EXISTS postgis;" msg_ok "PostgreSQL Extensions Ready" - msg_info "Updating ${APP}" - cp /opt/adventurelog-backup/backend/server/.env /opt/adventurelog/backend/server/.env - cp -r /opt/adventurelog-backup/backend/server/media /opt/adventurelog/backend/server/media + restore_backup + + msg_info "Updating AdventureLog" cd /opt/adventurelog/backend/server if [[ ! -x .venv/bin/python ]]; then $STD uv venv --clear .venv @@ -61,12 +59,10 @@ function update_script() { $STD .venv/bin/python -m manage collectstatic --noinput $STD .venv/bin/python -m manage migrate - cp /opt/adventurelog-backup/frontend/.env /opt/adventurelog/frontend/.env cd /opt/adventurelog/frontend $STD pnpm i $STD pnpm build - rm -rf /opt/adventurelog-backup - msg_ok "Updated ${APP}" + msg_ok "Updated AdventureLog" msg_info "Starting Services" systemctl daemon-reexec diff --git a/ct/ampache.sh b/ct/ampache.sh index 88aac095e..11798160e 100644 --- a/ct/ampache.sh +++ b/ct/ampache.sh @@ -34,24 +34,16 @@ function update_script() { systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Creating Backup" - cp /opt/ampache/config/ampache.cfg.php /tmp/ampache.cfg.php.backup - cp /opt/ampache/public/rest/.htaccess /tmp/ampache_rest.htaccess.backup - cp /opt/ampache/public/play/.htaccess /tmp/ampache_play.htaccess.backup - rm -rf /opt/ampache_backup - mv /opt/ampache /opt/ampache_backup - msg_ok "Created Backup" + create_backup /opt/ampache/config/ampache.cfg.php \ + /opt/ampache/public/rest/.htaccess \ + /opt/ampache/public/play/.htaccess \ + /opt/ampache/advanced-config fetch_and_deploy_gh_release "Ampache" "ampache/ampache" "prebuild" "latest" "/opt/ampache" "ampache-*_all_php8.4.zip" - msg_info "Restoring Backup" - cp /tmp/ampache.cfg.php.backup /opt/ampache/config/ampache.cfg.php - cp /tmp/ampache_rest.htaccess.backup /opt/ampache/public/rest/.htaccess - cp /tmp/ampache_play.htaccess.backup /opt/ampache/public/play/.htaccess + restore_backup chmod 664 /opt/ampache/public/rest/.htaccess /opt/ampache/public/play/.htaccess chown -R www-data:www-data /opt/ampache - rm -f /tmp/ampache*.backup - msg_ok "Restored Configuration" msg_info "Starting Service" systemctl start apache2 diff --git a/ct/anchor.sh b/ct/anchor.sh index 7702598a2..f0094c30c 100644 --- a/ct/anchor.sh +++ b/ct/anchor.sh @@ -35,9 +35,7 @@ function update_script() { systemctl stop anchor-web anchor-server msg_ok "Stopped Services" - msg_info "Backing up Configuration" - cp /opt/anchor/.env /opt/anchor.env.bak - msg_ok "Backed up Configuration" + create_backup /opt/anchor/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "anchor" "ZhFahim/anchor" "tarball" @@ -57,8 +55,7 @@ function update_script() { cp -r public .next/standalone/public msg_ok "Built Web Interface" - cp /opt/anchor.env.bak /opt/anchor/.env - rm -f /opt/anchor.env.bak + restore_backup msg_info "Running Database Migrations" cd /opt/anchor/server diff --git a/ct/anytype-server.sh b/ct/anytype-server.sh index 5058177e6..c54c8da6b 100644 --- a/ct/anytype-server.sh +++ b/ct/anytype-server.sh @@ -36,17 +36,12 @@ function update_script() { systemctl stop anytype msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -r /opt/anytype/data /opt/anytype_data_backup - msg_ok "Backed up Data" + create_backup /opt/anytype/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "anytype" "grishy/any-sync-bundle" "prebuild" "latest" "/opt/anytype" "any-sync-bundle_*_linux_amd64.tar.gz" chmod +x /opt/anytype/any-sync-bundle - msg_info "Restoring Data" - cp -r /opt/anytype_data_backup/. /opt/anytype/data - rm -rf /opt/anytype_data_backup - msg_ok "Restored Data" + restore_backup msg_info "Starting Service" systemctl start anytype diff --git a/ct/apache-tomcat.sh b/ct/apache-tomcat.sh index 48b9bc5f8..734fe1bde 100644 --- a/ct/apache-tomcat.sh +++ b/ct/apache-tomcat.sh @@ -26,26 +26,26 @@ function update_script() { check_container_resources TOMCAT_DIR=$(ls -d /opt/tomcat-* 2>/dev/null | head -n1) - if [[ -z "$TOMCAT_DIR" || ! -d "$TOMCAT_DIR" ]]; then + if [[ -z $TOMCAT_DIR || ! -d $TOMCAT_DIR ]]; then msg_error "No ${APP} Installation Found!" exit fi # Detect major version and current version from install path (e.g., /opt/tomcat-11 -> 11) TOMCAT_MAJOR=$(basename "$TOMCAT_DIR" | grep -oP 'tomcat-\K[0-9]+') - if [[ -z "$TOMCAT_MAJOR" ]]; then + if [[ -z $TOMCAT_MAJOR ]]; then msg_error "Cannot determine Tomcat major version from path: $TOMCAT_DIR" exit fi CURRENT_VERSION=$(grep -oP 'Apache Tomcat Version \K[0-9.]+' "$TOMCAT_DIR/RELEASE-NOTES" 2>/dev/null || echo "unknown") LATEST_VERSION=$(curl -fsSL "https://dlcdn.apache.org/tomcat/tomcat-${TOMCAT_MAJOR}/" | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+(-M[0-9]+)?/' | sort -V | tail -n1 | sed 's/\/$//; s/v//') - if [[ -z "$LATEST_VERSION" ]]; then + if [[ -z $LATEST_VERSION ]]; then msg_error "Failed to fetch latest version for Tomcat ${TOMCAT_MAJOR}" exit fi - if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then + if [[ $CURRENT_VERSION == "$LATEST_VERSION" ]]; then msg_ok "${APP} ${CURRENT_VERSION} is already up to date" exit fi @@ -54,13 +54,9 @@ function update_script() { systemctl stop tomcat msg_ok "Stopped Tomcat service" - msg_info "Backing up configuration and applications" - BACKUP_DIR="/tmp/tomcat-backup-$$" - mkdir -p "$BACKUP_DIR" - cp -a "$TOMCAT_DIR/conf" "$BACKUP_DIR/conf" - cp -a "$TOMCAT_DIR/webapps" "$BACKUP_DIR/webapps" - [[ -d "$TOMCAT_DIR/lib" ]] && cp -a "$TOMCAT_DIR/lib" "$BACKUP_DIR/lib" - msg_ok "Backed up configuration and applications" + create_backup $TOMCAT_DIR/conf + [[ -d $TOMCAT_DIR/webapps ]] && create_backup $TOMCAT_DIR/webapps + [[ -d $TOMCAT_DIR/lib ]] && create_backup $TOMCAT_DIR/lib msg_info "Downloading Tomcat ${LATEST_VERSION}" TOMCAT_URL="https://dlcdn.apache.org/tomcat/tomcat-${TOMCAT_MAJOR}/v${LATEST_VERSION}/bin/apache-tomcat-${LATEST_VERSION}.tar.gz" @@ -78,7 +74,7 @@ function update_script() { cp -a "$BACKUP_DIR/webapps"/* "$TOMCAT_DIR/webapps/" 2>/dev/null || true if [[ -d "$BACKUP_DIR/lib" ]]; then for jar in "$BACKUP_DIR/lib"/*.jar; do - [[ -f "$jar" ]] || continue + [[ -f $jar ]] || continue jar_name=$(basename "$jar") if [[ ! -f "$TOMCAT_DIR/lib/$jar_name" ]]; then cp "$jar" "$TOMCAT_DIR/lib/" diff --git a/ct/babybuddy.sh b/ct/babybuddy.sh index 66d5f71f7..29fc7703a 100644 --- a/ct/babybuddy.sh +++ b/ct/babybuddy.sh @@ -37,16 +37,17 @@ function update_script() { systemctl stop uwsgi msg_ok "Services Stopped" + create_backup /opt/babybuddy/babybuddy/settings/production.py + msg_info "Cleaning old files" - cp /opt/babybuddy/babybuddy/settings/production.py /tmp/production.py.bak find . -mindepth 1 -maxdepth 1 ! -name '.venv' -exec rm -rf {} + msg_ok "Cleaned old files" fetch_and_deploy_gh_release "babybuddy" "babybuddy/babybuddy" "tarball" + restore_backup msg_info "Updating ${APP}" cd /opt/babybuddy - mv /tmp/production.py.bak /opt/babybuddy/babybuddy/settings/production.py source .venv/bin/activate $STD uv pip install -r requirements.txt export DJANGO_SETTINGS_MODULE=babybuddy.settings.production diff --git a/ct/baikal.sh b/ct/baikal.sh index cc568f039..74550dd8e 100644 --- a/ct/baikal.sh +++ b/ct/baikal.sh @@ -34,22 +34,19 @@ function update_script() { systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Backing up data" - mv /opt/baikal /opt/baikal-backup - msg_ok "Backed up data" + create_backup /opt/baikal/config/baikal.yaml \ + /opt/baikal/Specific/ PHP_APACHE="YES" PHP_VERSION="8.3" setup_php setup_composer fetch_and_deploy_gh_release "baikal" "sabre-io/Baikal" "tarball" - - msg_info "Configuring Baikal" - cp -r /opt/baikal-backup/config/baikal.yaml /opt/baikal/config/ - cp -r /opt/baikal-backup/Specific/ /opt/baikal/ + restore_backup chown -R www-data:www-data /opt/baikal/ chmod -R 755 /opt/baikal/ + + msg_info "Configuring Baikal" cd /opt/baikal $STD composer install - rm -rf /opt/baikal-backup msg_ok "Configured Baikal" msg_info "Starting Service" diff --git a/ct/bambuddy.sh b/ct/bambuddy.sh index 045e2bc4a..8f19a1015 100644 --- a/ct/bambuddy.sh +++ b/ct/bambuddy.sh @@ -38,11 +38,11 @@ function update_script() { msg_ok "Stopped Service" msg_info "Backing up Configuration and Data" - cp /opt/bambuddy/.env /opt/bambuddy.env.bak - cp -r /opt/bambuddy/data /opt/bambuddy_data_bak - [[ -f /opt/bambuddy/bambuddy.db ]] && cp /opt/bambuddy/bambuddy.db /opt/bambuddy.db.bak - [[ -f /opt/bambuddy/bambutrack.db ]] && cp /opt/bambuddy/bambutrack.db /opt/bambutrack.db.bak - [[ -d /opt/bambuddy/archive ]] && cp -r /opt/bambuddy/archive /opt/bambuddy_archive_bak + create_backup /opt/bambuddy/.env \ + /opt/bambuddy/data \ + /opt/bambuddy/bambuddy.db \ + /opt/bambuddy/bambutrack.db \ + /opt/bambuddy/archive msg_ok "Backed up Configuration and Data" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bambuddy" "maziggy/bambuddy" "tarball" "latest" "/opt/bambuddy" @@ -59,19 +59,7 @@ function update_script() { $STD npm run build msg_ok "Rebuilt Frontend" - msg_info "Restoring Configuration and Data" - mkdir -p /opt/bambuddy/data - cp /opt/bambuddy.env.bak /opt/bambuddy/.env - cp -r /opt/bambuddy_data_bak/. /opt/bambuddy/data/ - [[ -f /opt/bambuddy.db.bak ]] && cp /opt/bambuddy.db.bak /opt/bambuddy/bambuddy.db - [[ -f /opt/bambutrack.db.bak ]] && cp /opt/bambutrack.db.bak /opt/bambuddy/bambutrack.db - if [[ -d /opt/bambuddy_archive_bak ]]; then - mkdir -p /opt/bambuddy/archive - cp -r /opt/bambuddy_archive_bak/. /opt/bambuddy/archive/ - fi - rm -f /opt/bambuddy.env.bak /opt/bambuddy.db.bak /opt/bambutrack.db.bak - rm -rf /opt/bambuddy_data_bak /opt/bambuddy_archive_bak - msg_ok "Restored Configuration and Data" + restore_backup msg_info "Starting Service" systemctl start bambuddy diff --git a/ct/bar-assistant.sh b/ct/bar-assistant.sh index be0b90f24..d38393ef0 100644 --- a/ct/bar-assistant.sh +++ b/ct/bar-assistant.sh @@ -37,16 +37,15 @@ function update_script() { PHP_VERSION="8.4" PHP_FPM="YES" PHP_MODULE="pdo-sqlite" setup_php - msg_info "Backing up Bar Assistant" - mv /opt/bar-assistant /opt/bar-assistant-backup - msg_ok "Backed up Bar Assistant" + create_backup /opt/bar-assistant/.env \ + /opt/bar-assistant/storage/bar-assistant fetch_and_deploy_gh_release "bar-assistant" "karlomikus/bar-assistant" "tarball" "latest" "/opt/bar-assistant" setup_composer - msg_info "Updating Bar-Assistant" - cp -r /opt/bar-assistant-backup/.env /opt/bar-assistant/.env - cp -r /opt/bar-assistant-backup/storage/bar-assistant /opt/bar-assistant/storage/bar-assistant + restore_backup + + msg_info "Configuring Bar-Assistant" cd /opt/bar-assistant $STD composer install --no-interaction $STD php artisan migrate --force @@ -57,8 +56,7 @@ function update_script() { $STD php artisan route:cache $STD php artisan event:cache chown -R www-data:www-data /opt/bar-assistant - rm -rf /opt/bar-assistant-backup - msg_ok "Updated Bar-Assistant" + msg_ok "Configured Bar-Assistant" msg_info "Starting nginx" systemctl start nginx @@ -66,23 +64,21 @@ function update_script() { fi if check_for_gh_release "vue-salt-rim" "karlomikus/vue-salt-rim"; then - msg_info "Backing up Vue Salt Rim" - mv /opt/vue-salt-rim /opt/vue-salt-rim-backup - msg_ok "Backed up Vue Salt Rim" + + create_backup /opt/vue-salt-rim/public/config.js msg_info "Stopping nginx" systemctl stop nginx msg_ok "Stopped nginx" fetch_and_deploy_gh_release "vue-salt-rim" "karlomikus/vue-salt-rim" "tarball" "latest" "/opt/vue-salt-rim" + restore_backup - msg_info "Updating Vue Salt Rim" - cp /opt/vue-salt-rim-backup/public/config.js /opt/vue-salt-rim/public/config.js + msg_info "Configuring Vue Salt Rim" cd /opt/vue-salt-rim $STD npm install $STD npm run build - rm -rf /opt/vue-salt-rim-backup - msg_ok "Updated Vue Salt Rim" + msg_ok "Configured Vue Salt Rim" msg_info "Starting nginx" systemctl start nginx diff --git a/ct/baserow.sh b/ct/baserow.sh index 34ce68ccf..fa0d044db 100644 --- a/ct/baserow.sh +++ b/ct/baserow.sh @@ -35,27 +35,20 @@ function update_script() { systemctl stop baserow-backend baserow-celery baserow-celery-beat baserow-celery-export baserow-frontend msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/baserow/.env /opt/baserow.env.bak - msg_ok "Backed up Data" - + create_backup /opt/baserow/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "baserow" "baserow/baserow" "tarball" + restore_backup - msg_info "Restoring Configuration" - cp /opt/baserow.env.bak /opt/baserow/.env - rm -f /opt/baserow.env.bak - msg_ok "Restored Configuration" - - msg_info "Updating Backend Dependencies" + msg_info "Configuring Baserow" cd /opt/baserow/backend $STD uv sync --frozen --no-dev - msg_ok "Updated Backend Dependencies" + msg_ok "Configured Baserow" - msg_info "Updating Frontend" + msg_info "Rebuilding Frontend" cd /opt/baserow/web-frontend $STD npm install $STD npm run build - msg_ok "Updated Frontend" + msg_ok "Rebuilt Frontend" msg_info "Running Migrations" cd /opt/baserow/backend diff --git a/ct/bentopdf.sh b/ct/bentopdf.sh index eabbc1952..072a71db9 100644 --- a/ct/bentopdf.sh +++ b/ct/bentopdf.sh @@ -36,18 +36,13 @@ function update_script() { systemctl stop bentopdf msg_ok "Stopped Service" - [[ -f /opt/bentopdf/.env.production ]] && cp /opt/bentopdf/.env.production /opt/production.env - + create_backup /opt/bentopdf/.env.production CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bentopdf" "alam00000/bentopdf" "tarball" "latest" "/opt/bentopdf" + restore_backup - msg_info "Updating BentoPDF" + msg_info "Configuring BentoPDF" cd /opt/bentopdf $STD npm ci --no-audit --no-fund - if [[ -f /opt/production.env ]]; then - mv /opt/production.env ./.env.production - else - cp ./.env.example ./.env.production - fi export NODE_OPTIONS="--max-old-space-size=3072" export SIMPLE_MODE=true export VITE_USE_CDN=true @@ -64,9 +59,9 @@ EOF if [[ ! -f /etc/ssl/private/bentopdf-selfsigned.key || ! -f /etc/ssl/certs/bentopdf-selfsigned.crt ]]; then CERT_CN="$(hostname -I | awk '{print $1}')" $STD openssl req -x509 -nodes -newkey rsa:2048 -days 3650 \ - -keyout /etc/ssl/private/bentopdf-selfsigned.key \ - -out /etc/ssl/certs/bentopdf-selfsigned.crt \ - -subj "/CN=${CERT_CN}" + -keyout /etc/ssl/private/bentopdf-selfsigned.key \ + -out /etc/ssl/certs/bentopdf-selfsigned.crt \ + -subj "/CN=${CERT_CN}" fi cat <<'EOF' >/etc/nginx/sites-available/bentopdf server { diff --git a/ct/bichon.sh b/ct/bichon.sh index 00f7dd77b..94bcf71a7 100644 --- a/ct/bichon.sh +++ b/ct/bichon.sh @@ -35,14 +35,14 @@ function update_script() { fi MIGRATE_V1=0 - if [[ "$CURRENT_VERSION" == 0.* ]]; then + if [[ $CURRENT_VERSION == 0.* ]]; then MIGRATE_V1=1 DISK_USAGE=$(df / | awk 'NR==2 {print $5}' | sed 's/%//') if [ "$DISK_USAGE" -gt 50 ]; then echo -e "\n${RD}Warning: Less than 50% free storage remaining on the root disk.${CL}" echo -e "${RD}Bichon v1 data migration temporarily duplicates data and requires free space for it.${CL}" read -r -p "Are you sure you want to proceed with the update? (y/N): " proceed - if [[ ! "$proceed" =~ ^[Yy]$ ]]; then + if [[ ! $proceed =~ ^[Yy]$ ]]; then msg_error "Update cancelled by user." exit fi @@ -53,7 +53,7 @@ function update_script() { echo -e "\n${RD}Warning: LXC has less than 2GB of RAM allocated (${RAM_TOTAL}MB).${CL}" echo -e "${RD}Bichon v1 data migration consumes significant memory and may crash if insufficient.${CL}" read -r -p "Are you sure you want to proceed with the update? (y/N): " proceed_ram - if [[ ! "$proceed_ram" =~ ^[Yy]$ ]]; then + if [[ ! $proceed_ram =~ ^[Yy]$ ]]; then msg_error "Update cancelled by user." exit fi @@ -65,12 +65,12 @@ function update_script() { systemctl stop bichon msg_ok "Stopped service" - cp /opt/bichon/bichon.env /tmp/bichon.env.backup + create_backup /opt/bichon/bichon.env if [ "$MIGRATE_V1" -eq 1 ] && [ "$CURRENT_VERSION" != "0.3.7" ]; then - msg_info "Updating to intermediate version v0.3.7" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bichon" "rustmailer/bichon" "prebuild" "v0.3.7" "/opt/bichon" "bichon-*-x86_64-unknown-linux-gnu.tar.gz" - cp /tmp/bichon.env.backup /opt/bichon/bichon.env + restore_backup + msg_info "Updating to intermediate version v0.3.7" systemctl start bichon sleep 30 systemctl stop bichon @@ -78,7 +78,7 @@ function update_script() { fi CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bichon" "rustmailer/bichon" "prebuild" "latest" "/opt/bichon" "bichon-*-x86_64-unknown-linux-gnu.tar.gz" - cp /tmp/bichon.env.backup /opt/bichon/bichon.env + restore_backup if [ "$MIGRATE_V1" -eq 1 ]; then msg_info "Running Bichon v1 Data Migration (patience)" diff --git a/ct/bitmagnet.sh b/ct/bitmagnet.sh index ab4d534d1..8d8d5b875 100644 --- a/ct/bitmagnet.sh +++ b/ct/bitmagnet.sh @@ -56,21 +56,19 @@ function update_script() { bitmagnet \ >/tmp/backup.sql mv /tmp/backup.sql /opt/ - [ -f /opt/bitmagnet/.env ] && cp /opt/bitmagnet/.env /opt/ - [ -f /opt/bitmagnet/config.yml ] && cp /opt/bitmagnet/config.yml /opt/ + create_backup /opt/bitmagnet/.env \ + /opt/bitmagnet/config.yml msg_ok "Data backed up" - rm -rf /opt/bitmagnet - fetch_and_deploy_gh_release "bitmagnet" "bitmagnet-io/bitmagnet" "tarball" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bitmagnet" "bitmagnet-io/bitmagnet" "tarball" + restore_backup - msg_info "Updating Bitmagnet" + msg_info "Configuring Bitmagnet" cd /opt/bitmagnet VREL=v$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') $STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL" chmod +x bitmagnet - [ -f "/opt/.env" ] && cp "/opt/.env" /opt/bitmagnet/ - [ -f "/opt/config.yml" ] && cp "/opt/config.yml" /opt/bitmagnet/ - msg_ok "Updated Bitmagnet" + msg_ok "Configured Bitmagnet" msg_info "Starting Service" systemctl start bitmagnet-web diff --git a/ct/blocky.sh b/ct/blocky.sh index d8b57c24d..b26890622 100644 --- a/ct/blocky.sh +++ b/ct/blocky.sh @@ -33,15 +33,9 @@ function update_script() { systemctl stop blocky msg_ok "Stopped Service" - msg_info "Backup Config" - mv /opt/blocky/config.yml /opt/config.yml - msg_ok "Backed Up Config" - + create_backup /opt/blocky/config.yml CLEAN_INSTALL=1 fetch_and_deploy_gh_release "blocky" "0xERR0R/blocky" "prebuild" "latest" "/opt/blocky" "blocky_*_Linux_x86_64.tar.gz" - - msg_info "Restore Config" - mv /opt/config.yml /opt/blocky/config.yml - msg_ok "Restored Config" + restore_backup msg_info "Starting Service" systemctl start blocky diff --git a/ct/bookstack.sh b/ct/bookstack.sh index eafc91657..caa720d4b 100644 --- a/ct/bookstack.sh +++ b/ct/bookstack.sh @@ -36,20 +36,14 @@ function update_script() { systemctl stop apache2 msg_ok "Services Stopped" - msg_info "Backing up data" - mv /opt/bookstack /opt/bookstack-backup - msg_ok "Backup finished" - + create_backup /opt/bookstack/.env \ + /opt/bookstack/public/uploads \ + /opt/bookstack/storage/uploads \ + /opt/bookstack/themes fetch_and_deploy_gh_release "bookstack" "BookStackApp/BookStack" "tarball" PHP_VERSION="8.3" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="ldap,tidy,mysqli" setup_php setup_composer - - msg_info "Restoring backup" - cp /opt/bookstack-backup/.env /opt/bookstack/.env - [[ -d /opt/bookstack-backup/public/uploads ]] && cp -a /opt/bookstack-backup/public/uploads/. /opt/bookstack/public/uploads/ - [[ -d /opt/bookstack-backup/storage/uploads ]] && cp -a /opt/bookstack-backup/storage/uploads/. /opt/bookstack/storage/uploads/ - [[ -d /opt/bookstack-backup/themes ]] && cp -a /opt/bookstack-backup/themes/. /opt/bookstack/themes/ - msg_ok "Backup restored" + restore_backup msg_info "Configuring BookStack" cd /opt/bookstack @@ -60,7 +54,6 @@ function update_script() { chmod -R 755 /opt/bookstack /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads /opt/bookstack/storage chmod -R 775 /opt/bookstack/storage /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads chmod -R 640 /opt/bookstack/.env - rm -rf /opt/bookstack-backup msg_ok "Configured BookStack" msg_info "Starting Apache2" diff --git a/ct/bytestash.sh b/ct/bytestash.sh index 5a65a9b76..c71e100ae 100644 --- a/ct/bytestash.sh +++ b/ct/bytestash.sh @@ -34,25 +34,10 @@ function update_script() { systemctl stop bytestash-backend bytestash-frontend msg_ok "Services Stopped" - msg_info "Backing up data" - tmp_dir="/opt/bytestash-data-backup" - mkdir -p "$tmp_dir" - if [[ -d /opt/bytestash/data ]]; then - cp -r /opt/bytestash/data "$tmp_dir"/data - elif [[ -d /opt/data ]]; then - cp -r /opt/data "$tmp_dir"/data - fi - msg_ok "Data backed up" - + [[ -d /opt/bytestash/data ]] && create_backup /opt/bytestash/data + [[ -d /opt/data ]] && create_backup /opt/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash" "tarball" - - msg_info "Restoring data" - if [[ -d "$tmp_dir"/data ]]; then - mkdir -p /opt/bytestash/data - cp -r "$tmp_dir"/data/* /opt/bytestash/data/ - rm -rf "$tmp_dir" - fi - msg_ok "Data restored" + restore_backup msg_info "Configuring ByteStash" cd /opt/bytestash/server