How to write/hack together an init.d script (Ubuntu)

I needed a quick way to start a specific subversion line at boot time so i threw together this script.

I will probably go through it again and add the lines to stop the daemon…maybe

———————Start of Script—————————————

#!/bin/bash
#
# /etc/rc.d/init.d/extras
# extras This shell script takes care of starting and stopping
# The SVN daemon and restarting samba (needed for some reason)
# The samba line will be removed when the prob is fixed
#
#
#

start() {

echo -n “Starting SVN and restarting Samba: ”
svnserve -d -r /mnt/data/SVN/
/etc/init.d/samba restart

return
}

stop() {

echo -n “Shutting down Extra Scripts (This does Nothing): “

}

case “$1” in

start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo “Usage: {start|stop|restart}”
exit 1
;;

esac
exit $?

———————End of Script—————————————-

Dont forget yau will need to add execute permissions for it to actualy run

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s