[Techtalk] script run on bootup

drichter at fastmail.fm drichter at fastmail.fm
Mon May 8 19:10:53 EST 2006


Hi everyone.

I wrote a script to start the subversion daemon when the machine boots.
It works when I run it from a login shell as root, but when I put it in
/etc/init.d and the machine boots, it fails at this point:

   su svn -c '/usr/bin/svnserve -d -r ~svn' && success || failure

It says it can't execute /bin/bash. What's the problem?

(The machine runs Fedora Core 4, if that matters.)

Here is the full script. You'll notice that I've adapted the sshd
startup
script to this purpose.


#!/bin/bash

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

prog='Subversion daemon'

do_restart_sanity_check()     # Not used right now.
{
	# TODO: this
	$SSHD -t
	RETVAL=$?
	if [ ! "$RETVAL" = 0 ]; then
		failure $"Configuration file or keys are invalid"
		echo
	fi
}

start()
{
	echo -n $"Starting $prog: "
	su svn -c '/usr/bin/svnserve -d -r ~svn' && success || failure
	RETVAL=$?
	echo
}

stop()
{
	echo -n $"Stopping $prog: "

	# Hack: should do this better, using pidfileofproc.
	su svn -c 'killall svnserve' && success || failure

	RETVAL=$?
	echo
}

reload()     # Not used right now.
{
	# TODO: this
	echo -n $"Reloading $prog: "
	if [ -n "`pidfileofproc $SSHD`" ] ; then
	    killproc $SSHD -HUP
	else
	    failure $"Reloading $prog"
	fi
	RETVAL=$?
	echo
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
#       reload)
#               reload
#               ;;
#       status)
#               status $SSHD
#               RETVAL=$?
#               ;;
	*)
		echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
		RETVAL=1
esac
exit $RETVAL
-- 
  
  drichter at fastmail.fm

-- 
http://www.fastmail.fm - Access your email from home and the web



More information about the Techtalk mailing list