Skip to content

Commit 9c23b55

Browse files
authored
Fix: Trillium Update Function & Harmonize Installation (#2148)
* Fix Trillium Update Function * Update trilium-install.sh
1 parent 5c0811c commit 9c23b55

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

ct/trilium.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,41 @@ function update_script() {
3232
msg_error "No ${APP} Installation Found!"
3333
exit
3434
fi
35+
if [[ ! -f /opt/${APP}_version.txt ]]; then touch /opt/${APP}_version.txt
36+
fi
37+
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
3538
RELEASE=$(curl -s https://api.github.com/repos/TriliumNext/Notes/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
36-
3739
msg_info "Stopping ${APP}"
3840
systemctl stop trilium
3941
sleep 1
4042
msg_ok "Stopped ${APP}"
4143

4244
msg_info "Updating to ${RELEASE}"
45+
mkdir -p /opt/trilium_backup
46+
mv /opt/trilium/{db,dump-db} /opt/trilium_backup/
47+
rm -rf /opt/trilium
48+
cd /tmp
4349
wget -q https://github.com/TriliumNext/Notes/releases/download/${RELEASE}/TriliumNextNotes-linux-x64-${RELEASE}.tar.xz
4450
tar -xf TriliumNextNotes-linux-x64-${RELEASE}.tar.xz
45-
cp -r trilium-linux-x64-server/* /opt/trilium/
51+
mv trilium-linux-x64-server /opt/trilium
52+
cp -r /opt/trilium_backup/{db,dump-db} /opt/trilium/
53+
echo "${RELEASE}" >/opt/${APP}_version.txt
4654
msg_ok "Updated to ${RELEASE}"
4755

4856
msg_info "Cleaning up"
49-
rm -rf TriliumNextNotes-linux-x64-${RELEASE}.tar.xz trilium-linux-x64-server
57+
rm -rf /tmp/TriliumNextNotes-linux-x64-${RELEASE}.tar.xz
58+
rm -rf /opt/trilium_backup
5059
msg_ok "Cleaned"
5160

5261
msg_info "Starting ${APP}"
5362
systemctl start trilium
5463
sleep 1
5564
msg_ok "Started ${APP}"
5665
msg_ok "Updated Successfully"
57-
exit
66+
else
67+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
68+
fi
69+
exit
5870
}
5971

6072
start

install/trilium-install.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
# Copyright (c) 2021-2025 tteck
44
# Author: tteck (tteckster)
5-
# License: MIT
6-
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
76

87
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
98
color
@@ -14,23 +13,24 @@ network_check
1413
update_os
1514

1615
msg_info "Installing Dependencies"
17-
$STD apt-get install -y curl
18-
$STD apt-get install -y sudo
19-
$STD apt-get install -y mc
16+
$STD apt-get install -y \
17+
curl \
18+
sudo \
19+
mc
2020
msg_ok "Installed Dependencies"
2121

22+
msg_info "Setup TriliumNext"
23+
cd /opt
2224
RELEASE=$(curl -s https://api.github.com/repos/TriliumNext/Notes/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
23-
24-
msg_info "Installing TriliumNext"
2525
wget -q https://github.com/TriliumNext/Notes/releases/download/${RELEASE}/TriliumNextNotes-linux-x64-${RELEASE}.tar.xz
2626
tar -xf TriliumNextNotes-linux-x64-${RELEASE}.tar.xz
2727
mv trilium-linux-x64-server /opt/trilium
28-
msg_ok "Installed TriliumNext"
28+
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
29+
msg_ok "Setup TriliumNext"
2930

3031
msg_info "Creating Service"
31-
service_path="/etc/systemd/system/trilium.service"
32-
33-
echo "[Unit]
32+
cat <<EOF >/etc/systemd/system/trilium.service
33+
[Unit]
3434
Description=Trilium Daemon
3535
After=syslog.target network.target
3636
@@ -43,15 +43,16 @@ TimeoutStopSec=20
4343
Restart=always
4444
4545
[Install]
46-
WantedBy=multi-user.target" >$service_path
46+
WantedBy=multi-user.target
47+
EOF
4748
systemctl enable --now -q trilium
4849
msg_ok "Created Service"
4950

5051
motd_ssh
5152
customize
5253

5354
msg_info "Cleaning up"
55+
rm -rf /opt/TriliumNextNotes-linux-x64-${RELEASE}.tar.xz
5456
$STD apt-get -y autoremove
5557
$STD apt-get -y autoclean
56-
rm -rf TriliumNextNotes-linux-x64-${RELEASE}.tar.xz
5758
msg_ok "Cleaned"

0 commit comments

Comments
 (0)