#!/bin/bash
SERVICE_NAME="my_service"
SERVICE_DESCRIPTION="My Service"
SERVICE_USER="myuser"
SERVICE_COMMAND="/usr/bin/mycommand --myarg1 --myarg2"
cat <<EOF > /etc/systemd/system/${SERVICE_NAME}.service
[Unit]
Description=${SERVICE_DESCRIPTION}
[Service]
User=${SERVICE_USER}
ExecStart=${SERVICE_COMMAND}
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable ${SERVICE_NAME}
systemctl start ${SERVICE_NAME}