@@ -20,48 +20,61 @@ 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/habitica" ]]; then
28- msg_error " No ${APP} Installation Found!"
29- exit
30- fi
31- RELEASE=$( curl -fsSL https://api.github.com/repos/HabitRPG/habitica/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
32- if [[ " ${RELEASE} " != " $( cat /opt/${APP} _version.txt) " ]] || [[ ! -f /opt/${APP} _version.txt ]]; then
33- msg_info " Stopping $APP "
34- systemctl stop habitica-mongodb
35- systemctl stop habitica
36- systemctl stop habitica-client
37- msg_ok " Stopped $APP "
27+ if [[ ! -d " /opt/habitica" ]]; then
28+ msg_error " No ${APP} Installation Found!"
29+ exit
30+ fi
31+ NODE_VERSION=" 20" NODE_MODULE=" gulp-cli,mocha" setup_nodejs
32+ RELEASE=$( curl -fsSL https://api.github.com/repos/HabitRPG/habitica/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
33+ if [[ " ${RELEASE} " != " $( cat ~ /.habitica 2> /dev/null) " ]] || [[ ! -f ~ /.habitica ]]; then
3834
39- msg_info " Updating $APP to ${RELEASE} "
40- temp_file=$( mktemp)
41- curl -fsSL " https://github.com/HabitRPG/habitica/archive/refs/tags/v${RELEASE} .tar.gz" -o " $temp_file "
42- tar zxf $temp_file
43- cp -rf habitica-${RELEASE} /* /opt/habitica
44- cd /opt/habitica
45- $STD npm i
46- echo " ${RELEASE} " > /opt/${APP} _version.txt
47- msg_ok " Updated $APP to ${RELEASE} "
35+ msg_info " Stopping $APP "
36+ systemctl stop habitica-mongodb
37+ systemctl stop habitica
38+ systemctl stop habitica-client
39+ msg_ok " Stopped $APP "
40+
41+ msg_info " Save configuration"
42+ if [[ -f /opt/habitica/config.json ]]; then
43+ cp /opt/habitica/config.json ~ /config.json
44+ msg_ok " Saved configuration"
45+ else
46+ msg_warn " No configuration file found, skipping save"
47+ fi
4848
49- msg_info " Starting $APP "
50- systemctl start habitica-mongodb
51- systemctl start habitica
52- systemctl start habitica-client
53- msg_ok " Started $APP "
49+ fetch_and_deploy_gh_release " habitica" " HabitRPG/habitica" " tarball" " latest" " /opt/habitica"
5450
55- msg_info " Cleaning Up"
56- rm -f $temp_file
57- rm -rf ~ /habitica-${RELEASE}
58- msg_ok " Cleanup Completed"
51+ msg_info " Updating $APP to ${RELEASE} "
52+ cd /opt/habitica
53+ $STD npm i
54+ $STD npm run postinstall
55+ $STD npm run client:build
56+ $STD gulp build:prod
57+ msg_ok " Updated $APP to ${RELEASE} "
5958
60- msg_ok " Update Successful"
59+ msg_info " Restoring configuration"
60+ if [[ -f ~ /config.json ]]; then
61+ cp ~ /config.json /opt/habitica/config.json
62+ msg_ok " Restored configuration"
6163 else
62- msg_ok " No update required. ${APP} is already at ${RELEASE} "
64+ msg_warn " No configuration file found to restore "
6365 fi
64- exit
66+
67+ msg_info " Starting $APP "
68+ systemctl start habitica-mongodb
69+ systemctl start habitica
70+ systemctl start habitica-client
71+ msg_ok " Started $APP "
72+
73+ msg_ok " Update Successful"
74+ else
75+ msg_ok " No update required. ${APP} is already at ${RELEASE} "
76+ fi
77+ exit
6578}
6679
6780start
@@ -71,4 +84,4 @@ description
7184msg_ok " Completed Successfully!\n"
7285echo -e " ${CREATING}${GN}${APP} setup has been successfully initialized!${CL} "
7386echo -e " ${INFO}${YW} Access it using the following URL:${CL} "
74- echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :8080 ${CL} "
87+ echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :3000 ${CL} "
0 commit comments