ryczypior wrote:Yes, I know this is old topic, but for newest ubuntu 16.04 none of above works for me.
I've created a simple service script for systemd:
1. Create file /lib/systemd/system/serviio.service (as root - sudo):
- Code:
$ sudo touch /lib/systemd/system/serviio.service
2. Put these lines of code into created file:
- Code:
[Unit]
Description=Serviio daemon
[Service]
Type=simple
Environment=statedir=/opt/serviio #path to serviio environment
ExecStart=/opt/serviio/bin/serviio.sh #path to serviio.sh on your FS
[Install]
WantedBy=multi-user.targetroot
3. Enable service for autostart:
- Code:
sudo systemctl enable serviio.service
From now, you should be able to do for start serviio service:
- Code:
sudo service serviio start
and for for stop serviio service:
- Code:
sudo service serviio stop
Also status and restart should work.
If your OS uses systemd, it should works for you
I just created this account to comment on this post. First of all, that you very much for providing this code, it really helped me understand how services are managed in systemd-based distributions. However, I can say that for the "enable"-command to work properly on my new Ubuntu Server 16.04.1 install, I had to remove the "root" at the very end of the last line in the
serviio.service file. I found out by navigating to
/etc/systemd/system and discovering that there was no
multi-user.targetroot.wants directory. There was a directory named
multi-user.target.wants, however, and after removing "root" in the service file, the
sudo systemctl enable serviio.service worked flawlessly, and serviio does indeed start correctly at boot.
So just to clarify, the following code works on my system:
- Code:
[Unit]
Description=Serviio daemon
[Service]
Type=simple
Environment=statedir=/opt/serviio #path to serviio environment
ExecStart=/opt/serviio/bin/serviio.sh #path to serviio.sh on your FS
[Install]
WantedBy=multi-user.target