How do I set up No-IP as a proper service?
There is an example service shell script in the download, but it seems limited and relies on killproc
which doesn't exist by default on Ubuntu 16 LTS.
Solution 1:
Ubuntu 16 LTS uses systemd
as the init system. This assumes you have already downloaded & installed the noip2
update client.
-
Create the file
/etc/systemd/system/noip2.service
as follows:[Unit] Description=No-Ip Dynamic DNS Update Service After=network.target [Service] Type=forking ExecStart=/usr/local/bin/noip2 [Install] WantedBy=multi-user.target
-
Reload the init daemon:
sudo systemctl daemon-reload
-
Enable the service:
sudo systemctl enable noip2
-
Start the service:
sudo systemctl start noip2
Derived from this readme
Solution 2:
I used the sysvinit
guide from Jonas Friedmann.
- Download and untar the No-IP DUC:
wget https://www.noip.com/client/linux/noip-duc-linux.tar.gz
tar -xf noip-duc-linux.tar.gz --exclude='._*'
(excludes Mac dotfiles) - Make and install it:
cd noip-x.y
(where x.y is version)make
(errors here may mean you're missing compilation packages)sudo make install
-
Create the file
/etc/init.d/noip
with these contents:#!/bin/sh ### BEGIN INIT INFO # Provides: noip # Required-Start: $local_fs $network $syslog # Required-Stop: $local_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: no-ip DUC # Description: Update DNS for dynamic IP on noip.com ### END INIT INFO NAME="noip" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" APPDIR="/" APPBIN="/usr/local/bin/noip2" PIDFILE="/var/run/${NAME}-customservice.pid" # Include functions set -e . /lib/lsb/init-functions start() { printf "Starting '$NAME'... " start-stop-daemon --start --background --make-pidfile --pidfile "$PIDFILE" --chdir "$APPDIR" --exec "$APPBIN" || true printf "done\n" } #We need this function to ensure the whole process tree will be killed killtree() { local _pid=$1 local _sig=${2-TERM} for _child in $(ps -o pid --no-headers --ppid ${_pid}); do killtree ${_child} ${_sig} done kill -${_sig} ${_pid} } stop() { printf "Stopping '$NAME'... " [ -z `cat "$PIDFILE" 2>/dev/null` ] || \ while test -d /proc/$(cat "$PIDFILE"); do killtree $(cat "$PIDFILE") 15 sleep 0.5 done [ -z `cat "$PIDFILE" 2>/dev/null` ] || rm "$PIDFILE" printf "done\n" } status() { "$APPBIN" -S } configure() { "$APPBIN" -C } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; configure) configure ;; *) echo "Usage: $NAME {start|stop|restart|status|configure}" >&2 exit 1 ;; esac exit 0
(I used
sudo vim /etc/init.d/noip
.) - Make it executable:
sudo chmod a+x /etc/init.d/noip
- Enable it:
sudo update-rc.d noip defaults
- Configure it:
sudo service noip configure
- Start it:
sudo service noip start
- Check it:
sudo service noip status
Feedback is welcome.