@@ -3,9 +3,9 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
33# Copyright (c) 2021-2025 tteck
44# Author: tteck (tteckster)
55# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6- # Source: https://triliumnext. github.io/Docs/
6+ # Source: https://github.com/TriliumNext/Trilium
77
8- APP=" Trilium"
8+ APP=" Trilium Notes "
99var_tags=" ${var_tags:- notes} "
1010var_cpu=" ${var_cpu:- 1} "
1111var_ram=" ${var_ram:- 512} "
@@ -27,57 +27,52 @@ function update_script() {
2727 msg_error " No ${APP} Installation Found!"
2828 exit
2929 fi
30- if [[ ! -f /opt/${APP} _version.txt ]]; then touch /opt/${APP} _version.txt; fi
31- RELEASE=$( curl -fsSL https://api.github.com/repos/TriliumNext/Notes/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
32- if [[ " v${RELEASE} " != " $( cat /opt/${APP} _version.txt 2> /dev/null) " ]] || [[ ! -f /opt/${APP} _version.txt ]]; then
33-
34- if [[ -d /opt/trilium/db ]]; then
35- DB_PATH=" /opt/trilium/db"
36- DB_RESTORE_PATH=" /opt/trilium/db"
37- elif [[ -d /opt/trilium/assets/db ]]; then
38- DB_PATH=" /opt/trilium/assets/db"
39- DB_RESTORE_PATH=" /opt/trilium/assets/db"
40- else
41- msg_error " Database not found in either /opt/trilium/db or /opt/trilium/assets/db"
42- exit 1
43- fi
30+ RELEASE=$( curl -fsSL https://api.github.com/repos/TriliumNext/Trilium/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
31+ if [[ " ${RELEASE} " != " $( cat ~ /.Trilium 2> /dev/null) " ]] || [[ ! -f ~ /.Trilium ]]; then
32+
33+ if [[ -d /opt/trilium/db ]]; then
34+ DB_PATH=" /opt/trilium/db"
35+ DB_RESTORE_PATH=" /opt/trilium/db"
36+ elif [[ -d /opt/trilium/assets/db ]]; then
37+ DB_PATH=" /opt/trilium/assets/db"
38+ DB_RESTORE_PATH=" /opt/trilium/assets/db"
39+ else
40+ msg_error " Database not found in either /opt/trilium/db or /opt/trilium/assets/db"
41+ exit 1
42+ fi
4443
45- msg_info " Stopping ${APP} "
46- systemctl stop trilium
47- sleep 1
48- msg_ok " Stopped ${APP} "
44+ msg_info " Stopping ${APP} "
45+ systemctl stop trilium
46+ sleep 1
47+ msg_ok " Stopped ${APP} "
4948
50- msg_info " Updating to ${RELEASE} "
51- mkdir -p /opt/trilium_backup
52- cp -r " ${DB_PATH} " /opt/trilium_backup/
53- rm -rf /opt/trilium
54- cd /tmp
55- curl -fsSL " https://github.com/TriliumNext/trilium/releases/download/v${RELEASE} /TriliumNextNotes-Server-v${RELEASE} -linux-x64.tar.xz" -o " TriliumNextNotes-Server-v${RELEASE} -linux-x64.tar.xz"
56- tar -xf " TriliumNextNotes-Server-v${RELEASE} -linux-x64.tar.xz"
57- mv " TriliumNextNotes-Server-${RELEASE} -linux-x64" /opt/trilium
49+ msg_info " Backing up Database"
50+ mkdir -p /opt/trilium_backup
51+ cp -r " ${DB_PATH} " /opt/trilium_backup/
52+ rm -rf /opt/trilium
53+ msg_ok " Backed up Database"
5854
59- # Restore database
60- mkdir -p " $( dirname " ${DB_RESTORE_PATH} " ) "
61- cp -r /opt/trilium_backup/$( basename " ${DB_PATH} " ) " ${DB_RESTORE_PATH} "
55+ fetch_and_deploy_gh_release " Trilium" " TriliumNext/Trilium" " prebuild" " latest" " /opt/trilium" " TriliumNotes-Server-*linux-x64.tar.xz"
6256
63- echo " v${RELEASE} " > /opt/${APP} _version.txt
64- msg_ok " Updated to ${RELEASE} "
57+ msg_info " Restoring Database"
58+ mkdir -p " $( dirname " ${DB_RESTORE_PATH} " ) "
59+ cp -r /opt/trilium_backup/$( basename " ${DB_PATH} " ) " ${DB_RESTORE_PATH} "
60+ msg_ok " Restored Database"
6561
66- msg_info " Cleaning up"
67- rm -rf " /tmp/TriliumNextNotes-Server-${RELEASE} -linux-x64.tar.xz"
68- rm -rf /opt/trilium_backup
69- msg_ok " Cleaned"
62+ msg_info " Cleaning up"
63+ rm -rf /opt/trilium_backup
64+ msg_ok " Cleaned"
7065
71- msg_info " Starting ${APP} "
72- systemctl start trilium
73- sleep 1
74- msg_ok " Started ${APP} "
75- msg_ok " Updated Successfully"
76- else
77- msg_ok " No update required. ${APP} is already at ${RELEASE} "
78- fi
66+ msg_info " Starting ${APP} "
67+ systemctl start trilium
68+ sleep 1
69+ msg_ok " Started ${APP} "
70+ msg_ok " Updated Successfully"
71+ else
72+ msg_ok " No update required. ${APP} is already at ${RELEASE} "
73+ fi
7974
80- exit
75+ exit
8176}
8277
8378start
0 commit comments