usage () { echo "You must set a $1 !" echo "Usage:" echo " create-service.sh " 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