Init.d script for puppet-dashboard

April 9, 2010   

In the #puppet IRC channel on freenode a user was asking if anyone knew of a init.d script for redhat/fedora for puppet-dashboard. I have a blog post about installing puppet-dashboard on Redhat/CentOS and I don’t think there is any init.d script out there. So time to write one

The first thing you will create is the following file

/etc/sysconfig/puppet-dashboard

This is a simple file with the following in it

#
# path to where you installed puppet dashboard
#
DASHBOARD_HOME=/opt/puppet-dashboard

You probably need to change the DASHBOARD_HOME variable to match what you have. Its the root of the project.

Now for the init.d script. Create the file called

/etc/init.d/puppet-dashboard

With the following contents in it.

#!/bin/bash
#
# Init script for puppet-dashboard
#
# chkconfig: - 85 15
# description: Init script for puppet-dashboard

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/puppet-dashboard ]; then
    . /etc/sysconfig/puppet-dashboard
fi

prog=puppet-dashboard
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        /usr/bin/ruby ${DASHBOARD_HOME}/script/server >/dev/null 2>&1 &
        RETVAL=$?
        if [ $RETVAL = 0 ]
        then
            echo $! > /var/run/puppet-dashboard.pid
            echo_success
        else
            echo_failure
        fi 

        echo

        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc puppet-dashboard
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/run/puppet-dashboard.pid
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo $"Usage: $prog {start|stop|restart}"
        exit 1
esac

exit $RETVAL

This might not be perfect but it works nicely



comments powered by Disqus