From e454d22b6d52ce6a584039581ad2da5e98d93e03 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 27 Mar 2021 15:22:24 +0100 Subject: [PATCH] Fix --- conf/systemd.service | 3 +-- scripts/_common.sh | 13 +++++++++++++ scripts/install | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 52a6375..64633e2 100755 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,8 +8,7 @@ User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ Environment='NODE_ENV=production' -Environment="__YNH_NODE_LOAD_PATH__" -ExecStart=__YNH_NODE_LOAD_PATH__ __FINALPATH__ mynewwiki --listen port=__PORT__ #authenticated-user-header=basic +ExecStart=__YNH_NODE__ mynewwiki --listen port=__PORT__ #authenticated-user-header=basic Restart=always [Install] diff --git a/scripts/_common.sh b/scripts/_common.sh index 7912aa4..d7982dd 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -17,3 +17,16 @@ nodejs_version=14 #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +# Execute a command as another user +# usage: ynh_exec_as USER COMMAND [ARG ...] +ynh_exec_as() { + local USER=$1 + shift 1 + + if [[ $USER = $(whoami) ]]; then + eval "$@" + else + sudo -u "$USER" "$@" + fi +} diff --git a/scripts/install b/scripts/install index 74b7fa3..da77163 100755 --- a/scripts/install +++ b/scripts/install @@ -98,7 +98,8 @@ ynh_script_progression --message="Configuring TiddlyWiki..." --weight=2 pushd $final_path ynh_use_nodejs - ynh_npm install -g tiddlywiki + #ynh_npm install -g tiddlywiki + ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install -g tiddlywiki tiddlywiki mynewwiki --init server popd