diff options
Diffstat (limited to '')
-rwxr-xr-x | create_service.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/create_service.sh b/create_service.sh new file mode 100755 index 0000000..549230b --- /dev/null +++ b/create_service.sh @@ -0,0 +1,40 @@ +usage () { + echo "You must set a $1 !" + echo "Usage:" + echo " create-service.sh <user>" + exit 0 +} + +if [ -z $1 ]; then + usage "USER" +fi + + +USER=$1 +NODE_PATH=$(which node) + +sudo bash -c "cat << EOF > /etc/systemd/system/kresus-$USER.service +[Unit] +Description=Personal finance manager +After=network.target + +[Service] +WorkingDirectory=/home/website/kresus-gen/$USER.kresus.neodarz.net +Environment=NODE_ENV=production +ExecStart=$NODE_PATH bin/kresus.js + +Type=simple +#Restart=always + +User=neodarz + +StandardOutput=journal +StandardError=inherit +SyslogIdentifier=kresus + +[Install] +WantedBy=multi-user.target +EOF" + +sudo systemctl enable kresus-$USER.service +sudo systemctl start kresus-$USER.service |