@@ -20,63 +20,62 @@ color
2020catch_errors
2121
2222function 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/pocket-id ]]; then
28- msg_error " No ${APP} Installation Found!"
29- exit
30- fi
31-
32- RELEASE=$( curl -fsSL https://api.github.com/repos/pocket-id/pocket-id/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 " Updating $APP "
35-
36- msg_info " Stopping $APP "
37- systemctl stop pocketid-backend.service
38- systemctl stop pocketid-frontend.service
39- systemctl stop caddy.service
40- msg_ok " Stopped $APP "
41-
42- msg_info " Updating $APP to v${RELEASE} "
43- cd /opt
44- cp -r /opt/pocket-id/backend/data /opt/data
45- cp /opt/pocket-id/backend/.env /opt/backend.env
46- cp /opt/pocket-id/frontend/.env /opt/frontend.env
47- rm -r /opt/pocket-id
48- curl -fsSL " https://github.com/pocket-id/pocket-id/archive/refs/tags/v${RELEASE} .zip" -o $( basename " https://github.com/pocket-id/pocket-id/archive/refs/tags/v${RELEASE} .zip" )
49- unzip -q v${RELEASE} .zip
50- mv pocket-id-${RELEASE} /opt/pocket-id
51- mv /opt/data /opt/pocket-id/backend/data
52- mv /opt/backend.env /opt/pocket-id/backend/.env
53- mv /opt/frontend.env /opt/pocket-id/frontend/.env
54-
55- cd /opt/pocket-id/backend/cmd
56- go build -o ../pocket-id-backend
57- cd ../../frontend
58- npm install
59- npm run build
60- msg_ok " Updated $APP to ${RELEASE} "
61-
62- msg_info " Starting $APP "
63- systemctl start pocketid-backend.service
64- systemctl start pocketid-frontend.service
65- systemctl start caddy.service
66- sleep 2
67- msg_ok " Started $APP "
68-
69- # Cleaning up
70- msg_info " Cleaning Up"
71- rm -f /opt/v${RELEASE} .zip
72- msg_ok " Cleanup Completed"
27+ if [[ ! -d /opt/pocket-id ]]; then
28+ msg_error " No ${APP} Installation Found!"
29+ exit
30+ fi
7331
74- echo " ${RELEASE} " > /opt/${APP} _version.txt
75- msg_ok " Update Successful"
32+ RELEASE=$( curl -fsSL https://api.github.com/repos/pocket-id/pocket-id/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+ if [[ " $( cat /opt/${APP} _version.txt) " < " 1.0.0" ]]; then
35+ msg_info " Migrating ${APP} to v${RELEASE} "
36+ systemctl -q disable --now pocketid-backend pocketid-frontend caddy
37+ mv /etc/caddy/Caddyfile ~ /Caddyfile.bak
38+ $STD apt remove --purge caddy nodejs -y
39+ $STD apt autoremove -y
40+ rm /etc/apt/{keyrings/nodesource.gpg,sources.list.d/nodesource.list}
41+ rm -r /usr/local/go
42+ cp -r /opt/pocket-id/backend/data /opt/data
43+ cp /opt/pocket-id/backend/.env /opt/env
44+ sed -i -e ' s/PUBLIC_//g' \
45+ -e ' /^SQLITE_DB_PATH/d' \
46+ -e ' /^POSTGRES/s/^/# /' \
47+ -e ' /^UPLOAD_PATH/d' \
48+ -e ' s/8080/1411/' /opt/env
49+ rm -r /opt/pocket-id
50+ rm /etc/systemd/system/pocketid-frontend.service
51+ BACKEND=" /etc/systemd/system/pocketid-backend.service"
52+ sed -i -e ' s/Backend/Service/' \
53+ -e ' s/\/backend\|-backend//g' " $BACKEND "
54+ mv " $BACKEND " ${BACKEND// -backend/ }
55+ systemctl daemon-reload
56+ systemctl -q enable pocketid
57+ mkdir /opt/pocket-id
58+ mv /opt/data /opt/pocket-id
59+ msg_ok " Migration complete. The reverse proxy port has been changed to 1411."
7660 else
77- msg_ok " No update required. ${APP} is already at ${RELEASE} "
61+ msg_info " Updating $APP to v${RELEASE} "
62+ systemctl stop pocketid
63+ cp /opt/pocket-id/.env /opt/env
7864 fi
79- exit
65+ curl -fsSL " https://github.com/pocket-id/pocket-id/releases/download/v${RELEASE} /pocket-id-linux-amd64" -o /opt/pocket-id/pocket-id
66+ chmod u+x /opt/pocket-id/pocket-id
67+ mv /opt/env /opt/pocket-id/.env
68+
69+ msg_info " Starting $APP "
70+ systemctl start pocketid
71+ msg_ok " Started $APP "
72+
73+ echo " ${RELEASE} " > /opt/${APP} _version.txt
74+ msg_ok " Update Successful"
75+ else
76+ msg_ok " No update required. ${APP} is already at ${RELEASE} "
77+ fi
78+ exit
8079}
8180
8281start
@@ -85,6 +84,6 @@ description
8584
8685msg_ok " Completed Successfully!\n"
8786echo -e " ${CREATING}${GN}${APP} setup has been successfully initialized!${CL} "
88- echo -e " ${INFO}${YW} Configure your reverse proxy to point to:${BGN} ${IP} :80 ${CL} "
87+ echo -e " ${INFO}${YW} Configure your reverse proxy to point to:${BGN} ${IP} :1411 ${CL} "
8988echo -e " ${INFO}${YW} Access it using the following URL:${CL} "
9089echo -e " ${TAB}${GATEWAY}${BGN} https://{PUBLIC_URL}/login/setup${CL} "
0 commit comments