From e492a9b5d92858c46ccb0fd3ef9f0c20319c1afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Sun, 6 Jul 2025 10:43:54 +0200 Subject: [PATCH] Refactor (#5736) --- ct/baikal.sh | 17 +++++++++-------- install/baikal-install.sh | 15 ++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/ct/baikal.sh b/ct/baikal.sh index 5d71b1a66..252d8c24e 100644 --- a/ct/baikal.sh +++ b/ct/baikal.sh @@ -23,34 +23,35 @@ function update_script() { header_info check_container_storage check_container_resources + if [[ ! -d /opt/baikal ]]; then msg_error "No ${APP} Installation Found!" exit fi RELEASE=$(curl -fsSL https://api.github.com/repos/sabre-io/Baikal/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 [[ "${RELEASE}" != "$(cat ~/.baikal 2>/dev/null)" ]] || [[ ! -f ~/.baikal ]]; then msg_info "Stopping Service" systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Updating ${APP} to v${RELEASE}" - cd /opt - curl -fsSL "https://github.com/sabre-io/baikal/releases/download/${RELEASE}/baikal-${RELEASE}.zip" -o $(basename "https://github.com/sabre-io/baikal/releases/download/${RELEASE}/baikal-${RELEASE}.zip") + msg_info "Backing up data" mv /opt/baikal /opt/baikal-backup - $STD unzip -o "baikal-${RELEASE}.zip" + msg_ok "Backed up data" + + fetch_and_deploy_gh_release "baikal" "sabre-io/Baikal" + + msg_info "Configuring Baikal" cp -r /opt/baikal-backup/config/baikal.yaml /opt/baikal/config/ cp -r /opt/baikal-backup/Specific/ /opt/baikal/ chown -R www-data:www-data /opt/baikal/ chmod -R 755 /opt/baikal/ - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to v${RELEASE}" + msg_ok "Configured Baikal" msg_info "Starting Service" systemctl start apache2 msg_ok "Started Service" msg_info "Cleaning up" - rm -rf "/opt/baikal-${RELEASE}.zip" rm -rf /opt/baikal-backup msg_ok "Cleaned" msg_ok "Updated Successfully" diff --git a/install/baikal-install.sh b/install/baikal-install.sh index 93d68fabc..c054bdd50 100644 --- a/install/baikal-install.sh +++ b/install/baikal-install.sh @@ -14,13 +14,12 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt-get install -y \ - apache2 \ - libapache2-mod-php \ - php-{pgsql,dom} +$STD apt-get install -y apache2 msg_ok "Installed Dependencies" PG_VERSION="16" setup_postgresql +PHP_APACHE="YES" PHP_MODULE="pgsql, dom" PHP_VERSION="8.2" setup_php +fetch_and_deploy_gh_release "baikal" "sabre-io/Baikal" msg_info "Setting up PostgreSQL Database" DB_NAME=baikal @@ -36,11 +35,7 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMP } >>~/baikal.creds msg_ok "Set up PostgreSQL Database" -msg_info "Installing Baikal" -RELEASE=$(curl -fsSL https://api.github.com/repos/sabre-io/Baikal/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -cd /opt -curl -fsSL "https://github.com/sabre-io/baikal/releases/download/${RELEASE}/baikal-${RELEASE}.zip" -o "baikal-${RELEASE}.zip" -$STD unzip "baikal-${RELEASE}.zip" +msg_info "Configuring Baikal" cat </opt/baikal/config/baikal.yaml database: backend: pgsql @@ -51,7 +46,6 @@ database: EOF chown -R www-data:www-data /opt/baikal/ chmod -R 755 /opt/baikal/ -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Installed Baikal" msg_info "Creating Service" @@ -90,7 +84,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf "/opt/baikal-${RELEASE}.zip" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"