Created
September 9, 2019 00:13
-
-
Save Inobtenio/50a5f622fbbd7a2856c6a3d2f4247af0 to your computer and use it in GitHub Desktop.
Simple CLI tool to create a systemd service that executes on boot from any command. Usage: sudo bash make-service [name] [description] [command]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat > "/etc/systemd/system/${1}.service" << EOF | |
[Unit] | |
Description=$2 | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=%i | |
ExecStart=$3 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl --system daemon-reload | |
systemctl enable $1 | |
systemctl start $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment