My favorites | Sign in
Project Logo
                
Search
for
Updated Mar 07, 2008 by tommy.murphy
Labels: Featured, Phase-Deploy
StartupScript  
An Example Startup/Shutdown Script for Ubuntu

Introduction

Instructions to run jab2web as a service under a Unix Environment.

Installation

Download and Unzip jab2web.

tar -zxvf jab2web-v0.1.tar.gz
cd jab2web-v0.1

Move the files to a better place.

sudo mv jab2web.py /bin/jab2web
sudo mv jab2web.conf /etc/jab2web.conf

Make sure that /bin/jab2web is executable.

sudo chmod a+x /bin/jab2web

Edit the configuration file.

sudo vim /etc/jab2web.conf

Make the init.d script.

sudo vim /etc/init.d/jab2web

Make it an executable.

sudo chmod a+x /etc/init.d/jab2web

Make it start at bootup.

sudo update-rc.d jab2web defaults

And you're done!

init.d script

#!/bin/sh
# jabber bot startup script

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/bin/jab2web
NAME=jab2web
DESC=jab2web

CONFIGFILE="/etc/jab2web.conf"

set -e

case "$1" in
    start)
        echo -n "Starting $DESC: " 
        start-stop-daemon --start --pidfile /var/run/$NAME.pid --make-pidfile --background --startas $DAEMON -- $CONFIGFILE
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid
        rm -f /var/run/$NAME.pid
        echo "$NAME."
        ;;
    *)
        echo "Usage: $0 { start | stop }" >&2
        exit 1
        ;;
esac

exit 0

Sign in to add a comment
Hosted by Google Code