From 859a156ceffa342d03efcbf59ec46160460c1220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Mon, 1 Mar 2021 07:23:47 +0100 Subject: [PATCH] [__wikijs] run under own user --- type/__wikijs/files/wikijs-openrc | 1 + type/__wikijs/gencode-remote | 1 + type/__wikijs/manifest | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/type/__wikijs/files/wikijs-openrc b/type/__wikijs/files/wikijs-openrc index e484647..351332a 100644 --- a/type/__wikijs/files/wikijs-openrc +++ b/type/__wikijs/files/wikijs-openrc @@ -3,6 +3,7 @@ command='/usr/bin/node' command_args='server' command_background=true +command_user='wikijs' description="Run wiki.js" directory='/var/wiki' error_log=/var/log/"$RC_SVCNAME".err diff --git a/type/__wikijs/gencode-remote b/type/__wikijs/gencode-remote index 37c7df7..3058fde 100755 --- a/type/__wikijs/gencode-remote +++ b/type/__wikijs/gencode-remote @@ -17,6 +17,7 @@ EOF # Download and copy source cat << EOF wget -O - https://github.com/Requarks/wiki/releases/download/$version/wiki-js.tar.gz | tar xz -C /var/wiki +chown -R wikijs:wikijs /var/wiki EOF # Install deps and launch diff --git a/type/__wikijs/manifest b/type/__wikijs/manifest index 9a9a94f..8231ebb 100644 --- a/type/__wikijs/manifest +++ b/type/__wikijs/manifest @@ -52,15 +52,20 @@ export HTTP_PORT HTTPS_PORT db_pass="$(cat "${__object:?}/parameter/database-password")" __package nodejs -__directory /var/wiki/ +__user wikijs --home /var/wiki --create-home # These things are Alpine-dependant. __file /etc/init.d/wikijs \ --source "${__type:?}/files/wikijs-openrc" \ --mode 0755 __package nghttp2-dev # Required for some reason, else a symbol is missing +for logfile in wikijs.log wikijs.err; do + require="__user/wikijs" __file /var/log/$logfile --owner wikijs +done mkdir -p "${__object:?}/files" "${__type:?}/files/config.yml.sh" "$db_pass" > "${__object:?}/files/config.yml" -require='__directory/var/wiki' \ - __file /var/wiki/config.yml --source "${__object:?}/files/config.yml" +require='__user/wikijs' \ + __file /var/wiki/config.yml \ + --source "${__object:?}/files/config.yml" \ + --owner wikijs