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