4

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.

15

Ubuntu 16 LTS uses systemd as the init system. This assumes you have already downloaded & installed the noip2 update client.

  1. 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
    
  2. Reload the init daemon:

    sudo systemctl daemon-reload
    
  3. Enable the service:

    sudo systemctl enable noip2
    
  4. Start the service:

    sudo systemctl start noip2
    

Derived from this readme

3

I used the sysvinit guide from Jonas Friedmann.

  1. 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)
  2. 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
  3. 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.)

  4. Make it executable:
    sudo chmod a+x /etc/init.d/noip
  5. Enable it:
    sudo update-rc.d noip defaults
  6. Configure it:
    sudo service noip configure
  7. Start it:
    sudo service noip start
  8. Check it:
    sudo service noip status

Feedback is welcome.

1
  • 2
    For the record, I should have done it as a systemd service. – Walf Jul 18 '17 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.