A script to easily make any script startup on Linux using SYSTEMD
- Pop_!OS 22.04 (LTS)
- Linux Mint (older version)
- Fedora (older version, with SELinux set to permissive)
- Arch Linux (older)
After executing this script you'll have to do the following:
- Enter full path for the needed script
- Decide if you want to move it to other directory or not
- Decide if to execute startup script as root or as user
- Check if everything's fine (check if needed file exists, contains shebang, etc...)
- It will move your script to other directory (if you want to)
- Make it executable
- Create and edit service file
- Reload daemon
- Enable service file
- Print useful commands to manage the service file
You can run install.sh (it'll simply move the script to a bin directory), but it's not obligatory
sudo rm $(which makeit-startup)
Simply execute the script without any arguments (with BASH):
sudo bash makeit-startup.sh
You can encounter problems.
To check if you have some problems with this script or not, you can try making script test.py or test.sh startup.
So
- If after typing:
systemctl status YOUR-SERVICE-FILE
You recive an error which is saying something like: Permissions denied (will happen on SELinux distros) , then you probably need to edit /etc/selinux/config and change line:
SELINUX=enforcing
with
SELINUX=permissive
And reboot your system
- If you recive an error which is saying that you have a bad Unit file, you can edit your service file and try changing: [Unit] with [UNIT] or with [unit]
If you encounter more problems, please tell me by creating an issue.
- If you don't know what you are doing then don't run it, or try it out in a VM
- You can try this out on a virtual machine before making any changes on your host, for better stability
- Before making any script startup, make sure it has a shebang
- If you want to understand how to manually make any script startup, here some links that will help you:
https://stackoverflow.com/questions/12973777/how-to-run-a-shell-script-at-startup