@@ -20,39 +20,69 @@ color
2020catch_errors
2121
2222function update_script() {
23- header_info
24- check_container_storage
25- check_container_resources
26- if [[ ! -d /opt/wastebin ]]; then
27- msg_error " No ${APP} Installation Found!"
28- exit
29- fi
30- RELEASE=$( curl -s https://api.github.com/repos/matze/wastebin/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- msg_info " Stopping Wastebin"
33- systemctl stop wastebin
34- msg_ok " Wastebin Stopped"
23+ header_info
24+ check_container_storage
25+ check_container_resources
26+ if [[ ! -d /opt/wastebin ]]; then
27+ msg_error " No ${APP} Installation Found!"
28+ exit
29+ fi
30+ RELEASE=$( curl -s https://api.github.com/repos/matze/wastebin/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
31+ # Dirty-Fix 03/2025 for missing APP_version.txt on old installations, set to pre-latest release
32+ msg_info " Running Migration"
33+ if [[ ! -f /opt/${APP} _version.txt ]]; then
34+ echo " 2.7.1" > /opt/${APP} _version.txt
35+ mkdir -p /opt/wastebin-data
36+ cat << EOF >/opt/wastebin-data/.env
37+ WASTEBIN_DATABASE_PATH=/opt/wastebin-data/wastebin.db
38+ WASTEBIN_CACHE_SIZE=1024
39+ WASTEBIN_HTTP_TIMEOUT=30
40+ WASTEBIN_SIGNING_KEY=$( openssl rand -hex 32)
41+ WASTEBIN_PASTE_EXPIRATIONS=0,600,3600=d,86400,604800,2419200,29030400
42+ EOF
43+ systemctl stop wastebin
44+ cat << EOF >/etc/systemd/system/wastebin.service
45+ [Unit]
46+ Description=Wastebin Service
47+ After=network.target
48+
49+ [Service]
50+ WorkingDirectory=/opt/wastebin
51+ ExecStart=/opt/wastebin/wastebin
52+ EnvironmentFile=/opt/wastebin-data/.env
3553
36- msg_info " Updating Wastebin"
37- wget -q https://github.com/matze/wastebin/releases/download/${RELEASE} /wastebin_${RELEASE} _x86_64-unknown-linux-musl.tar.zst
38- tar -xf wastebin_${RELEASE} _x86_64-unknown-linux-musl.tar.zst
39- cp -f wastebin /opt/wastebin/
40- chmod +x /opt/wastebin/wastebin
41- echo " ${RELEASE} " > /opt/${APP} _version.txt
42- msg_ok " Updated Wastebin"
54+ [Install]
55+ WantedBy=multi-user.target
56+ EOF
57+ systemctl daemon-reload
58+ fi
59+ msg_ok " Migration Done"
60+ if [[ ! -f /opt/${APP} _version.txt ]] || [[ " ${RELEASE} " != " $( cat /opt/${APP} _version.txt) " ]]; then
61+ msg_info " Stopping Wastebin"
62+ systemctl stop wastebin
63+ msg_ok " Wastebin Stopped"
4364
44- msg_info " Starting Wastebin"
45- systemctl start wastebin
46- msg_ok " Started Wastebin"
65+ msg_info " Updating Wastebin"
66+ temp_file=$( mktemp)
67+ wget -q https://github.com/matze/wastebin/releases/download/${RELEASE} /wastebin_${RELEASE} _x86_64-unknown-linux-musl.zip -O $temp_file
68+ unzip -q $temp_file
69+ cp -f wastebin /opt/wastebin/
70+ chmod +x /opt/wastebin/wastebin
71+ echo " ${RELEASE} " > /opt/${APP} _version.txt
72+ msg_ok " Updated Wastebin"
4773
48- msg_info " Cleaning Up"
49- rm -rf wastebin_${RELEASE} _x86_64-unknown-linux-musl.tar.zst
50- msg_ok " Cleaned"
51- msg_ok " Updated Successfully"
52- else
53- msg_ok " No update required. ${APP} is already at v${RELEASE} "
54- fi
55- exit
74+ msg_info " Starting Wastebin"
75+ systemctl start wastebin
76+ msg_ok " Started Wastebin"
77+
78+ msg_info " Cleaning Up"
79+ rm -f $temp_file
80+ msg_ok " Cleanup Completed"
81+ msg_ok " Updated Successfully"
82+ else
83+ msg_ok " No update required. ${APP} is already at v${RELEASE} "
84+ fi
85+ exit
5686}
5787
5888start
0 commit comments