Skip to content

Commit e7508fa

Browse files
Removed git dependency and pulling latest release (also beta releases) via Download_Install(). Do not exec 'npm run setup' anymore, since the install script uses git to checkout latest repo. We pull the latest release anyway. Use only npm commands for installation. Added hardening to system service. Minimized db-config. Removed unecessary aSTART_SERVICES, added service name to To_Install instead.
1 parent 3d139db commit e7508fa

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

dietpi/dietpi-software

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ Available commands:
11911191
aSOFTWARE_DESC[$software_id]='A fancy self-hosted monitoring tool'
11921192
aSOFTWARE_CATX[$software_id]=8
11931193
aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/system_stats/#uptime_kuma'
1194-
aSOFTWARE_DEPS[$software_id]='17 9' # Git, Node.js
1194+
aSOFTWARE_DEPS[$software_id]='9' # Node.js
11951195

11961196
# Remote Access
11971197
#--------------------------------------------------------------------------------
@@ -12289,41 +12289,39 @@ _EOF_
1228912289
unset -v rd_inst rd_data
1229012290
fi
1229112291

12292-
if To_Install 176 # Uptime Kuma
12292+
if To_Install 176 uptime-kuma # Uptime Kuma
1229312293
then
1229412294
local opt='/opt/uptime-kuma'
1229512295
local mnt='/mnt/dietpi_userdata/uptime-kuma'
12296+
local LATEST_TAG=$(curl -s https://api.github.com/repos/louislam/uptime-kuma/tags | grep -Po '"name": "\K.*?(?=")' | head -n1)
1229612297

1229712298
# Reinstall
1229812299
[[ -d $opt ]] && G_EXEC rm -R "$opt"
1229912300

1230012301
# User and directories
1230112302
Create_User -d "$mnt" uptime-kuma
1230212303

12304+
G_EXEC mkdir -p "$opt" "$mnt"
12305+
1230312306
# Clone & install https://github.com/louislam/uptime-kuma/wiki/%F0%9F%94%A7-How-to-Install#-non-docker
12304-
G_EXEC git clone https://github.com/louislam/uptime-kuma.git "$opt"
12305-
G_EXEC cd "$opt" && /usr/local/bin/npm run setup
12307+
Download_Install "https://github.com/louislam/uptime-kuma/archive/refs/tags/${LATEST_TAG}.tar.gz" /opt
1230612308

12307-
# Create data dir and link it
12308-
G_EXEC mkdir -p "$mnt"
12309+
G_EXEC rsync -a "/opt/uptime-kuma-$LATEST_TAG/" "$opt/"
12310+
G_EXEC rm -R "/opt/uptime-kuma-$LATEST_TAG"
1230912311
G_EXEC ln -s "$mnt" "$opt/data"
1231012312

12313+
G_EXEC cd "$opt"
12314+
G_EXEC_OUTPUT=1 G_EXEC npm ci --omit dev --no-audit
12315+
G_EXEC_OUTPUT=1 G_EXEC npm run download-dist
12316+
1231112317
# Create db-config to pre-select usage of sqlite3 (without this you can choose between mariaDB and sqlite on first run)
12312-
[[ -f "$mnt/db-config.json" ]] || cat << _EOF_ > "$mnt/db-config.json" || exit 1
12313-
{
12314-
"type": "sqlite",
12315-
"port": 3306,
12316-
"hostname": "",
12317-
"username": "",
12318-
"password": "",
12319-
"dbName": "kuma"
12320-
}
12321-
_EOF_
12322-
G_EXEC chown -R uptime-kuma:uptime-kuma "$mnt"
12323-
G_EXEC chmod -R 755 "$mnt"
12318+
[[ -f "$mnt/db-config.json" ]] || G_EXEC eval "echo '{\"type\":\"sqlite\"}' > '$mnt/db-config.json'"
1232412319

12325-
# Create systemd service, we do not use pm2 to run it
12326-
cat << _EOF_ > /etc/systemd/system/uptime-kuma.service
12320+
G_EXEC chown -R uptime-kuma:uptime-kuma "$mnt"
12321+
G_EXEC chmod -R 755 "$mnt"
12322+
12323+
# Create systemd service, we do not use pm2 to run it
12324+
cat << _EOF_ > /etc/systemd/system/uptime-kuma.service
1232712325
# /etc/systemd/system/uptime-kuma.service
1232812326
[Unit]
1232912327
Description=Uptime Kuma
@@ -12339,11 +12337,23 @@ Restart=on-failure
1233912337
RestartSec=10
1234012338
Environment=NODE_ENV=production
1234112339

12340+
# Hardening
12341+
ProtectSystem=strict
12342+
ProtectHome=1
12343+
PrivateUsers=1
12344+
PrivateTmp=1
12345+
PrivateDevices=1
12346+
ProtectKernelTunables=1
12347+
ProtectControlGroups=1
12348+
ProtectKernelModules=1
12349+
ProtectKernelLogs=1
12350+
ProtectClock=1
12351+
ReadWritePaths=-$mnt
12352+
1234212353
[Install]
1234312354
WantedBy=multi-user.target
1234412355
_EOF_
12345-
aSTART_SERVICES+=('uptime-kuma')
12346-
unset -v mnt opt
12356+
unset -v mnt opt LATEST_TAG
1234712357
fi
1234812358
}
1234912359

@@ -14490,7 +14500,6 @@ _EOF_
1449014500
then
1449114501
Remove_Service uptime-kuma uptime-kuma uptime-kuma
1449214502
G_EXEC rm -Rf /opt/uptime-kuma
14493-
G_EXEC rm -Rf /mnt/dietpi_userdata/uptime-kuma
1449414503
fi
1449514504

1449614505
G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Finalising uninstall'

0 commit comments

Comments
 (0)