Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions ct/baikal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 4 additions & 11 deletions install/baikal-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <<EOF >/opt/baikal/config/baikal.yaml
database:
backend: pgsql
Expand All @@ -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"
Expand Down Expand Up @@ -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"