This commit is contained in:
Slaviša Arežina 2025-07-06 10:43:54 +02:00 committed by GitHub
parent 5e7eb4ae3a
commit e492a9b5d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 19 deletions

View File

@ -23,34 +23,35 @@ function update_script() {
header_info header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /opt/baikal ]]; then if [[ ! -d /opt/baikal ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi 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) }') 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" msg_info "Stopping Service"
systemctl stop apache2 systemctl stop apache2
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Updating ${APP} to v${RELEASE}" msg_info "Backing up data"
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")
mv /opt/baikal /opt/baikal-backup 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/config/baikal.yaml /opt/baikal/config/
cp -r /opt/baikal-backup/Specific/ /opt/baikal/ cp -r /opt/baikal-backup/Specific/ /opt/baikal/
chown -R www-data:www-data /opt/baikal/ chown -R www-data:www-data /opt/baikal/
chmod -R 755 /opt/baikal/ chmod -R 755 /opt/baikal/
echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Configured Baikal"
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start apache2 systemctl start apache2
msg_ok "Started Service" msg_ok "Started Service"
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf "/opt/baikal-${RELEASE}.zip"
rm -rf /opt/baikal-backup rm -rf /opt/baikal-backup
msg_ok "Cleaned" msg_ok "Cleaned"
msg_ok "Updated Successfully" msg_ok "Updated Successfully"

View File

@ -14,13 +14,12 @@ network_check
update_os update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt-get install -y apache2
apache2 \
libapache2-mod-php \
php-{pgsql,dom}
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PG_VERSION="16" setup_postgresql 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" msg_info "Setting up PostgreSQL Database"
DB_NAME=baikal DB_NAME=baikal
@ -36,11 +35,7 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMP
} >>~/baikal.creds } >>~/baikal.creds
msg_ok "Set up PostgreSQL Database" msg_ok "Set up PostgreSQL Database"
msg_info "Installing Baikal" msg_info "Configuring 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"
cat <<EOF >/opt/baikal/config/baikal.yaml cat <<EOF >/opt/baikal/config/baikal.yaml
database: database:
backend: pgsql backend: pgsql
@ -51,7 +46,6 @@ database:
EOF EOF
chown -R www-data:www-data /opt/baikal/ chown -R www-data:www-data /opt/baikal/
chmod -R 755 /opt/baikal/ chmod -R 755 /opt/baikal/
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Baikal" msg_ok "Installed Baikal"
msg_info "Creating Service" msg_info "Creating Service"
@ -90,7 +84,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf "/opt/baikal-${RELEASE}.zip"
$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"