@@ -20,48 +20,46 @@ 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/cryptpad" ]]; then
28- msg_error " No ${APP} Installation Found!"
29- exit
30- fi
31- RELEASE=$( curl -fsSL https://api.github.com/repos/cryptpad/cryptpad/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
32- if [[ " ${RELEASE} " != " $( cat /opt/ ${APP} _version.txt ) " ]] || [[ ! -f /opt/ ${APP} _version.txt ]]; then
33- msg_info " Stopping $APP "
34- systemctl stop cryptpad
35- msg_ok " Stopped $APP "
27+ if [[ ! -d " /opt/cryptpad" ]]; then
28+ msg_error " No ${APP} Installation Found!"
29+ exit
30+ fi
31+ RELEASE=$( curl -fsSL https://api.github.com/repos/cryptpad/cryptpad/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
32+ if [[ " ${RELEASE} " != " $( cat ~ /.cryptpad 2> /dev/null ) " ]] || [[ ! -f ~ /.cryptpad ]]; then
33+ msg_info " Stopping $APP "
34+ systemctl stop cryptpad
35+ msg_ok " Stopped $APP "
3636
37- msg_info " Updating $APP to ${RELEASE} "
38- temp_dir=$( mktemp -d)
39- cp -f /opt/cryptpad/config/config.js /opt/config.js
40- curl -fsSL " https://github.com/cryptpad/cryptpad/archive/refs/tags/${RELEASE} .tar.gz" -o " $temp_dir /cryptpad-${RELEASE} .tar.gz"
41- cd " $temp_dir "
42- tar zxf " cryptpad-${RELEASE} .tar.gz"
43- cp -rf " cryptpad-${RELEASE} " /* /opt/cryptpad
44- cd /opt/cryptpad
45- $STD npm ci
46- $STD npm run install:components
47- $STD npm run build
48- cp -f /opt/config.js /opt/cryptpad/config/config.js
49- echo " ${RELEASE} " > /opt/${APP} _version.txt
50- msg_ok " Updated $APP to ${RELEASE} "
37+ msg_info " Backing up configuration"
38+ [ -f /opt/cryptpad/config/config.js ] && mv /opt/cryptpad/config/config.js /opt/
39+ msg_ok " Backed up configuration"
5140
52- msg_info " Cleaning Up"
53- rm -rf $temp_dir
54- msg_ok " Cleanup Completed"
41+ fetch_and_deploy_gh_release " cryptpad" " cryptpad/cryptpad"
5542
56- msg_info " Starting $APP "
57- systemctl start cryptpad
58- msg_ok " Started $APP "
43+ msg_info " Updating $APP to ${RELEASE} "
44+ cd /opt/cryptpad
45+ $STD npm ci
46+ $STD npm run install:components
47+ $STD npm run build
48+ msg_ok " Updated $APP to ${RELEASE} "
5949
60- msg_ok " Update Successful"
61- else
62- msg_ok " No update required. ${APP} is already at ${RELEASE} "
63- fi
64- exit
50+ msg_info " Restoring configuration"
51+ mv /opt/config.js /opt/cryptpad/config/
52+ msg_ok " Configuration restored"
53+
54+ msg_info " Starting $APP "
55+ systemctl start cryptpad
56+ msg_ok " Started $APP "
57+
58+ msg_ok " Update Successful"
59+ else
60+ msg_ok " No update required. ${APP} is already at ${RELEASE} "
61+ fi
62+ exit
6563}
6664
6765start
0 commit comments