This tutorial shows you how to correctly implement a startup script in Mint 19.
Background
It used to be that you could implement a simple startup script in rc.local but that is now frowned upon. In addition, third party services that would start automatically under Mint 18.x will not necessarily automatically start under Mint 19.x.
To correctly implement a startup script you need to create a systemd unit (service, if you prefer).
About the example
I run hardware RAID using Adaptec 6805TQ cards (under $US50 brand new on FleaBay). Adaptec provide a browser-based storage manager (running on Apache Tomcat's Catalina servelet) that used to auto-start under Mint 18, but after installing and rebooting on Mint 19, the storage manager no longer auto-starts, hence the need for me to create a systemd unit to auto-start the web server. You can modify the example below quite easily for your own needs.
Prerequisites
All you need is the script to be run. In the example, I'm using
/usr/StorMan/StorAgnt.sh
but you can reference any script you like.Step 1
Create the initial service definition:
sudo nano /etc/systemd/system/storage.service
Substitute your service name for
storage
in the above example.Add the following text to the newly created file:
Code: Select all
[Unit]
After=network.target
[Service]
ExecStart=/usr/StorMan/StorAgnt.sh
[Install]
WantedBy=default.target
/usr/StorMan/StorAgnt.sh
with the fully qualified path and name of your script.In the example above:
After: Tells systemd when the script should be run. In this case, the script will run after the network has started.
ExecStart: Is the fully qualified path to the script you want to execute.
WantedBy: Specifies the boot target that your new systemd unit should be installed to.
See
man systemd.service
for more information.Step 2
Set the execute permissions on your script:
sudo chmod 744 /usr/StorMan/StorAgnt.sh
See this link for information about chmod 774
Step 3
Change the access mode permissions of your service definition:
sudo chmod 664 /etc/systemd/system/storage.service
See this link for information about chmod 664
Step 4
Prepare systemd to run your service:
Code: Select all
sudo systemctl daemon-reload
sudo systemctl enable storage.service
Code: Select all
Created symlink from /etc/systemd/system/default.target.wants/storage.service to /etc/systemd/system/storage.service.
Start the service:
sudo systemctl start storage.service
If all went well, your script has been executed. To test further, reboot your system.
That's all there is to it.