Skip to content

Commit d087719

Browse files
Refactor: Fluid-Calendar (#5846)
* Refactor * Update fluid-calendar.sh --------- Co-authored-by: Tobias <[email protected]>
1 parent df52a2d commit d087719

File tree

2 files changed

+38
-58
lines changed

2 files changed

+38
-58
lines changed

ct/fluid-calendar.sh

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,43 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
23+
header_info
24+
check_container_storage
25+
check_container_resources
2626

27-
if [[ ! -d /opt/fluid-calendar ]]; then
28-
msg_error "No ${APP} Installation Found!"
29-
exit
30-
fi
31-
32-
RELEASE=$(curl -fsSL https://api.github.com/repos/dotnetfactory/fluid-calendar/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
33-
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
34-
msg_info "Stopping $APP"
35-
systemctl stop fluid-calendar.service
36-
msg_ok "Stopped $APP"
27+
if [[ ! -d /opt/fluid-calendar ]]; then
28+
msg_error "No ${APP} Installation Found!"
29+
exit
30+
fi
31+
RELEASE=$(curl -fsSL https://api.github.com/repos/dotnetfactory/fluid-calendar/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32+
if [[ "${RELEASE}" != "$(cat ~/.fluid-calendar 2>/dev/null)" ]] || [[ ! -f ~/.fluid-calendar ]]; then
33+
msg_info "Stopping $APP"
34+
systemctl stop fluid-calendar
35+
msg_ok "Stopped $APP"
3736

38-
msg_info "Updating $APP to v${RELEASE}"
39-
cp /opt/fluid-calendar/.env /opt/fluid.env
40-
rm -rf /opt/fluid-calendar
41-
tmp_file=$(mktemp)
42-
curl -fsSL "https://github.com/dotnetfactory/fluid-calendar/archive/refs/tags/v${RELEASE}.zip" -o "$tmp_file"
43-
$STD unzip $tmp_file
44-
mv ${APP}-${RELEASE}/ /opt/fluid-calendar
45-
mv /opt/fluid.env /opt/fluid-calendar/.env
46-
cd /opt/fluid-calendar
47-
export NEXT_TELEMETRY_DISABLED=1
48-
$STD npm install --legacy-peer-deps
49-
$STD npm run prisma:generate
50-
$STD npx prisma migrate deploy
51-
$STD npm run build:os
52-
msg_ok "Updated $APP to v${RELEASE}"
37+
cp /opt/fluid-calendar/.env /opt/fluid.env
38+
rm -rf /opt/fluid-calendar
39+
fetch_and_deploy_gh_release "fluid-calendar" "dotnetfactory/fluid-calendar"
5340

54-
msg_info "Starting $APP"
55-
systemctl start fluid-calendar.service
56-
msg_ok "Started $APP"
41+
msg_info "Updating $APP to v${RELEASE}"
42+
mv /opt/fluid.env /opt/fluid-calendar/.env
43+
cd /opt/fluid-calendar
44+
export NEXT_TELEMETRY_DISABLED=1
45+
$STD npm install --legacy-peer-deps
46+
$STD npm run prisma:generate
47+
$STD npx prisma migrate deploy
48+
$STD npm run build:os
49+
msg_ok "Updated $APP to v${RELEASE}"
5750

58-
msg_info "Cleaning Up"
59-
rm -rf $tmp_file
60-
msg_ok "Cleanup Completed"
51+
msg_info "Starting $APP"
52+
systemctl start fluid-calendar
53+
msg_ok "Started $APP"
6154

62-
echo "${RELEASE}" >/opt/${APP}_version.txt
63-
msg_ok "Update Successful"
64-
else
65-
msg_ok "No update required. ${APP} is already at v${RELEASE}"
66-
fi
67-
exit
55+
msg_ok "Update Successful"
56+
else
57+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
58+
fi
59+
exit
6860
}
6961

7062
start

install/fluid-calendar-install.sh

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,11 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt-get install -y \
18-
zip \
19-
postgresql-common
17+
$STD apt-get install -y zip
2018
msg_ok "Installed Dependencies"
2119

22-
msg_info "Installing Additional Dependencies"
23-
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
24-
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
25-
echo "YES" | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh &>/dev/null
26-
$STD apt-get install -y postgresql-17 nodejs
27-
msg_ok "Installed Additional Dependencies"
20+
PG_VERSION="17" setup_postgresql
21+
NODE_VERSION="20" setup_nodejs
2822

2923
msg_info "Setting up Postgresql Database"
3024
DB_NAME="fluiddb"
@@ -44,14 +38,9 @@ $STD sudo -u postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER;"
4438
} >>~/$APPLICATION.creds
4539
msg_ok "Set up Postgresql Database"
4640

47-
msg_info "Setup ${APPLICATION}"
48-
tmp_file=$(mktemp)
49-
RELEASE=$(curl -fsSL https://api.github.com/repos/dotnetfactory/fluid-calendar/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
50-
curl -fsSL "https://github.com/dotnetfactory/fluid-calendar/archive/refs/tags/v${RELEASE}.zip" -o "$tmp_file"
51-
$STD unzip $tmp_file
52-
mv ${APPLICATION}-${RELEASE}/ /opt/${APPLICATION}
53-
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
41+
fetch_and_deploy_gh_release "fluid-calendar" "dotnetfactory/fluid-calendar"
5442

43+
msg_info "Configuring ${APPLICATION}"
5544
cat <<EOF >/opt/fluid-calendar/.env
5645
DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME}"
5746
@@ -72,7 +61,7 @@ $STD npm install --legacy-peer-deps
7261
$STD npm run prisma:generate
7362
$STD npx prisma migrate deploy
7463
$STD npm run build:os
75-
msg_ok "Setup ${APPLICATION}"
64+
msg_ok "Configuring ${APPLICATION}"
7665

7766
msg_info "Creating Service"
7867
cat <<EOF >/etc/systemd/system/fluid-calendar.service
@@ -95,7 +84,6 @@ motd_ssh
9584
customize
9685

9786
msg_info "Cleaning up"
98-
rm -f $tmp_file
9987
$STD apt-get -y autoremove
10088
$STD apt-get -y autoclean
10189
msg_ok "Cleaned"

0 commit comments

Comments
 (0)