Skip to content

Commit e492a9b

Browse files
authored
Refactor (#5736)
1 parent 5e7eb4a commit e492a9b

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

ct/baikal.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,35 @@ function update_script() {
2323
header_info
2424
check_container_storage
2525
check_container_resources
26+
2627
if [[ ! -d /opt/baikal ]]; then
2728
msg_error "No ${APP} Installation Found!"
2829
exit
2930
fi
3031
RELEASE=$(curl -fsSL https://api.github.com/repos/sabre-io/Baikal/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32+
if [[ "${RELEASE}" != "$(cat ~/.baikal 2>/dev/null)" ]] || [[ ! -f ~/.baikal ]]; then
3233
msg_info "Stopping Service"
3334
systemctl stop apache2
3435
msg_ok "Stopped Service"
3536

36-
msg_info "Updating ${APP} to v${RELEASE}"
37-
cd /opt
38-
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")
37+
msg_info "Backing up data"
3938
mv /opt/baikal /opt/baikal-backup
40-
$STD unzip -o "baikal-${RELEASE}.zip"
39+
msg_ok "Backed up data"
40+
41+
fetch_and_deploy_gh_release "baikal" "sabre-io/Baikal"
42+
43+
msg_info "Configuring Baikal"
4144
cp -r /opt/baikal-backup/config/baikal.yaml /opt/baikal/config/
4245
cp -r /opt/baikal-backup/Specific/ /opt/baikal/
4346
chown -R www-data:www-data /opt/baikal/
4447
chmod -R 755 /opt/baikal/
45-
echo "${RELEASE}" >/opt/${APP}_version.txt
46-
msg_ok "Updated $APP to v${RELEASE}"
48+
msg_ok "Configured Baikal"
4749

4850
msg_info "Starting Service"
4951
systemctl start apache2
5052
msg_ok "Started Service"
5153

5254
msg_info "Cleaning up"
53-
rm -rf "/opt/baikal-${RELEASE}.zip"
5455
rm -rf /opt/baikal-backup
5556
msg_ok "Cleaned"
5657
msg_ok "Updated Successfully"

install/baikal-install.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt-get install -y \
18-
apache2 \
19-
libapache2-mod-php \
20-
php-{pgsql,dom}
17+
$STD apt-get install -y apache2
2118
msg_ok "Installed Dependencies"
2219

2320
PG_VERSION="16" setup_postgresql
21+
PHP_APACHE="YES" PHP_MODULE="pgsql, dom" PHP_VERSION="8.2" setup_php
22+
fetch_and_deploy_gh_release "baikal" "sabre-io/Baikal"
2423

2524
msg_info "Setting up PostgreSQL Database"
2625
DB_NAME=baikal
@@ -36,11 +35,7 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMP
3635
} >>~/baikal.creds
3736
msg_ok "Set up PostgreSQL Database"
3837

39-
msg_info "Installing Baikal"
40-
RELEASE=$(curl -fsSL https://api.github.com/repos/sabre-io/Baikal/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
41-
cd /opt
42-
curl -fsSL "https://github.com/sabre-io/baikal/releases/download/${RELEASE}/baikal-${RELEASE}.zip" -o "baikal-${RELEASE}.zip"
43-
$STD unzip "baikal-${RELEASE}.zip"
38+
msg_info "Configuring Baikal"
4439
cat <<EOF >/opt/baikal/config/baikal.yaml
4540
database:
4641
backend: pgsql
@@ -51,7 +46,6 @@ database:
5146
EOF
5247
chown -R www-data:www-data /opt/baikal/
5348
chmod -R 755 /opt/baikal/
54-
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
5549
msg_ok "Installed Baikal"
5650

5751
msg_info "Creating Service"
@@ -90,7 +84,6 @@ motd_ssh
9084
customize
9185

9286
msg_info "Cleaning up"
93-
rm -rf "/opt/baikal-${RELEASE}.zip"
9487
$STD apt-get -y autoremove
9588
$STD apt-get -y autoclean
9689
msg_ok "Cleaned"

0 commit comments

Comments
 (0)