Skip to content

Start Yadoms on boot

jmb42 edited this page Apr 2, 2018 · 9 revisions

How to start Yadoms on boot

Linux

Create a file named yadoms located at /etc/init.d/ as administrator

sudo nano /etc/init.d/yadoms

Set the right path of yadoms and copy the following text into the file.

#!/bin/bash
### BEGIN INIT INFO
# Provides:          yadoms
# Required-Start:    $local_fs $remote_fs $network ntp
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Yadoms daemon
# Description:       Yadoms is an opensource domotic server solution.
### END INIT INFO

case "$1" in
    start)
        # Stop the ntp service
        sudo /etc/init.d/ntp stop
        # force the time synchronization
        sudo ntpdate -s -t 20 fr.pool.ntp.org
        # restart the ntp service
        sudo /etc/init.d/ntp start
        # Executed commands launched with "start" parameter (during boot, so it take root rights)
        /opt/yadoms/yadoms --daemon
        # To run it as another user : example for the user pi on a raspberryPI 
        # sudo -u pi '/opt/yadoms/yadoms'  --daemon

        ;;
    stop)
        # Executed commands launched with "stop" parameter (during system halt)
		killall yadoms
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0

Make script executable :

sudo chmod +x /etc/init.d/yadoms
sudo update-rc.d yadoms defaults

Remove the yadoms service

sudo update-rc.d yadoms remove

Clone this wiki locally