From 234fe49cc5327e962bfddbef3332ead2aa80d7e7 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 20 Mar 2020 22:51:45 +0100 Subject: [PATCH] [fix] overhaul See #2. Getting rid of start script. cp instead of ln the "fake" ssl certificates. --- conf/start.sh | 5 ----- conf/systemd.service | 6 +++--- scripts/install | 13 +++++++------ 3 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 conf/start.sh diff --git a/conf/start.sh b/conf/start.sh deleted file mode 100644 index 43f8d7f..0000000 --- a/conf/start.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -pushd __FINALPATH__/src/ - npm start -popd diff --git a/conf/systemd.service b/conf/systemd.service index d2f3180..4072a8b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -4,11 +4,11 @@ After=network.target [Service] Type=simple -User=root -Group=root +User=ztncui +Group=ztncui Environment="PATH=__ENV_PATH__" WorkingDirectory=__FINALPATH__/src/ -ExecStart=/bin/bash __FINALPATH__/src/start.sh >> /var/log/__APP__/__APP__.log 2>&1 +ExecStart=__NODEJS_PATH__/npm start [Install] WantedBy=multi-user.target diff --git a/scripts/install b/scripts/install index 8788a4b..3fd84dc 100644 --- a/scripts/install +++ b/scripts/install @@ -161,14 +161,11 @@ popd mkdir -p $final_path env_file=$final_path/src/.env touch $env_file +chmod 600 $env_file echo "ZT_TOKEN=$(> $env_file echo "HTTP_PORT=$port" >> $env_file -cp ../conf/start.sh $final_path/src/ -ynh_replace_string "__APP__" "$app" "$final_path/src/start.sh" -ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/src/start.sh" - cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd #================================================= @@ -178,8 +175,8 @@ cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd # Even though one can stay in HTTP mode, the ztncui requires SSL certificates # let's use the ones of the domain pushd $final_path/src/etc/tls - ln -s /etc/yunohost/certs/$domain/key.pem privkey.pem - ln -s /etc/yunohost/certs/$domain/crt.pem fullchain.pem + cp /etc/yunohost/certs/$domain/key.pem privkey.pem + cp /etc/yunohost/certs/$domain/crt.pem fullchain.pem popd #================================================= @@ -201,6 +198,9 @@ ynh_script_progression --message="Configuring a systemd service..." --time --wei # Create a dedicated systemd config ynh_add_systemd_config ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service" +ynh_replace_string "__NODEJS_PATH__" "/opt/node_n/n/versions/node/$nodejs_version/bin/" "/etc/systemd/system/$app.service" +ynh_replace_string "__FINALPATH__" "$final_path" "/etc/systemd/system/$app.service" + systemctl daemon-reload #================================================= @@ -294,3 +294,4 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Installation of $app completed" --time --last +ynh_print_warn --message="Installation of $app completed. Default credentials: admin/password"