# ddclient init.d script

## Xamot

Anyone have a gentoo style init.d script to run ddclient in daemon mode?  And if so shouldn't this be added to the ebuild to create this file?

If not, I try to write my own, but I'm pretty new to gentoo. What do I need to know when going about writing an init.d script? Tips? Tricks? Warnings?

Thanks,

Xamot

----------

## Xamot

Outta curiosity and impatience I wrote one.  :Very Happy:   This is my first attempt ever at a 'runscript' so feedback would be appreciated.

```

#!/sbin/runscript

# Copyright 1999-2002 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License, v2 or later

#NB: Config is in /etc/conf.d/ddclient

depend() {

        need net

}

checkconfig() {

        if [ ! -f /etc/ddclient/ddclient.conf ]

        then

                eerror "Please create /etc/ddclient/ddclient.conf"

                return 1

        fi

        return 0

}

start() {

        checkconfig || return $?

        ebegin "Starting ddclient"

        /sbin/start-stop-daemon --start --quiet \

                --pidfile /var/run/ddclient.pid \

                --exec /usr/sbin/ddclient -- ${DDCLIENT_OPTS}

        eend $? "Failed to start ddclient"

}

stop() {

        ebegin "Stopping ddclient"

        /sbin/start-stop-daemon --stop --quiet --pidfile /var/run/ddclient.pid

        eend $? "Failed to stop ddclient"

        # clean stale pidfile

        if [ -f /var/run/ddclient.pid ]

        then

                rm -f /var/run/ddclient.pid

        fi

}

```

----------

## Xamot

I don't see any reason for ddclient to run as root what is the proper way to change this?

I tried creating a ddclient user and group, chowning the /etc/ddclient/ddclient.conf file to that user and group and finally using --startas in the init.d script. but that complained about a directory not found error.

```

bluegill ddclient # /etc/init.d/ddclient restart

 * Stopping ddclient...                                                         [ ok ]

 * Starting ddclient...

/sbin/start-stop-daemon: Unable to start ddclient: No such file or directory

 * Failed to start ddclient                                                     [ !! ]

```

----------

