Index: /trunk/Makefile
===================================================================
--- /trunk/Makefile	(revision 434)
+++ /trunk/Makefile	(revision 435)
@@ -110,11 +110,13 @@
 rpm-jobarchived:	${REQUIRED}
 	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d >/dev/null
-	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/bin >/dev/null
+	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/sysconfig >/dev/null
+	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin >/dev/null
 	mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/share/jobarchived >/dev/null
-	install -m 755 jobarchived/jobarchived.py ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/bin
-	( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/bin; \
+	install -m 755 jobarchived/jobarchived.py ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin
+	( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin; \
 	ln -s jobarchived.py jobarchived || true)
 	install jobarchived/jobarchived.conf ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc
-	install pkg/init.d/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d
+	install pkg/rpm/init.d/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d
+	install pkg/rpm/sysconfig/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/sysconfig
 	install jobarchived/job_dbase.sql \
 	${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/share/jobarchived
Index: /trunk/jobarchived/jobarchived.py
===================================================================
--- /trunk/jobarchived/jobarchived.py	(revision 434)
+++ /trunk/jobarchived/jobarchived.py	(revision 435)
@@ -32,10 +32,24 @@
 import getopt, syslog, ConfigParser
 
+def usage():
+
+	print
+	print 'usage: jobarchived [options]'
+	print 'options:'
+	print '      --config, -c      configuration file'
+	print '      --pidfile, -p     pid file'
+	print '      --help, -h        help'
+	print
+
 def processArgs( args ):
 
-        SHORT_L	= 'c:'
-        LONG_L	= 'config='
+        SHORT_L	= 'p:hc:'
+        LONG_L	= [ 'help', 'config=', 'pidfile=' ]
 
         config_filename = None
+
+	global PIDFILE
+
+	PIDFILE	= None
 
         try:
@@ -53,4 +67,13 @@
 
                         config_filename = value
+
+		if opt in [ '--pidfile', '-p' ]:
+
+			PIDFILE         = value
+
+		if opt in [ '--help', '-h' ]:
+
+			usage()
+			sys.exit( 0 )
 
         if not config_filename:
@@ -1887,4 +1910,6 @@
 		sys.exit(0)  # end parent
 
+	write_pidfile()
+
 	# Go to the root directory and set the umask
 	#
@@ -1977,4 +2002,16 @@
 	return time.strftime("%a %d %b %Y %H:%M:%S")
 
+def write_pidfile():
+
+	# Write pidfile if PIDFILE exists
+	if PIDFILE:
+
+		pid     = os.getpid()
+
+		pidfile = open(PIDFILE, 'w')
+
+		pidfile.write( str( pid ) )
+		pidfile.close()
+
 # Ooohh, someone started me! Let's go..
 if __name__ == '__main__':
Index: /trunk/pkg/rpm/init.d/jobarchived
===================================================================
--- /trunk/pkg/rpm/init.d/jobarchived	(revision 434)
+++ /trunk/pkg/rpm/init.d/jobarchived	(revision 435)
@@ -1,42 +1,71 @@
-#! /bin/sh
+#!/bin/sh
+#
+# Init file for the Job Archiving Daemon
+#
+# chkconfig: 2345 20 80
+# description: jobarchived archives information on nodes in RRDS and batch jobs in SQL
+#
+# processname: jobarchived
+# config: /etc/jobarchived.conf
+# config: /etc/sysconfig/jobarchived
+# pidfile: /var/run/jobarchived
 
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/usr/bin/jobarchived
-NAME=jobarchived
-DESC="Job Archive Daemon"
+# Source function library.
+. /etc/rc.d/init.d/functions
 
-export PYTHONPATH=/usr/share/jobarchived:$PYTHONPATH
+RETVAL=0
+name=jobarchived
+prog=/usr/sbin/jobarchived
+desc="Job Archiving Daemon"
 
-test -x $DAEMON || exit 0
+if [ -r /etc/sysconfig/$name ]; then
+	source /etc/sysconfig/$name
+fi
 
-set -e
+start() {
+	echo -n $"Starting $desc: "
+	daemon $prog -p /var/run/$name.pid $OPTIONS
+	RETVAL=$?
+	echo
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$name
+	return $RETVAL
+}
+
+stop() {
+	echo -n $"Stopping $desc: "
+	killproc $prog
+	RETVAL=$?
+	echo
+	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$name
+	return $RETVAL
+}
+
+restart() {
+	stop
+	start
+}
 
 case "$1" in
-  start)
-	echo -n "Starting $DESC: "
-	start-stop-daemon --start --quiet -m --pidfile /var/run/$NAME.pid \
-		--exec $DAEMON 
-	sleep 1
-	ps -ef | grep jobarchived$ | awk '{ print $2 }' >/var/run/$NAME.pid
-	echo "$NAME."
-	;;
-  stop)
-	echo -n "Stopping $DESC: "
-        start-stop-daemon --stop  --quiet --oknodo --name $DAEMON \
-                2>&1 > /dev/null
-	sleep 1
-	test -f /var/run/$NAME.pid && MYPID=`cat /var/run/$NAME.pid`
-	test ! -z $MYPID && ps $MYPID 2>&1 > /dev/null && kill -9 $MYPID 2>&1 > /dev/null
-	echo "$NAME."
-	;;
-  restart|force-reload)
-	$0 stop
-	$0 start
-	;;
-  *)
-	echo "Usage: $N {start|stop|restart}" >&2
-	exit 1
-	;;
+	start)
+		start
+		;;
+	stop)
+		stop
+		;;
+	restart)
+		restart
+		;;
+	condrestart)
+		[ -e /var/lock/subsys/$name ] && restart
+		RETVAL=$?
+		;;
+	status)
+		status python
+		RETVAL=$?
+		;;
+	*)
+		echo $"Usage: $0 {start|stop|restart|condrestart|status}"
+		RETVAL=1
 esac
 
-exit 0
+exit $RETVAL
Index: /trunk/pkg/rpm/jobmonarch-jobarchived.spec
===================================================================
--- /trunk/pkg/rpm/jobmonarch-jobarchived.spec	(revision 434)
+++ /trunk/pkg/rpm/jobmonarch-jobarchived.spec	(revision 435)
@@ -40,11 +40,4 @@
 
 /etc/init.d/jobarchived stop
-
-
-%postun
-#!/bin/sh
-
-PATH=/bin:/sbin:/usr/bin:/usr/sbin
-
 chkconfig jobarchived off
 
@@ -56,8 +49,9 @@
 
 %files
-"/usr/bin/jobarchived.py"
+"/usr/sbin/jobarchived.py"
+"/usr/sbin/jobarchived"
 "/etc/init.d/jobarchived"
-"/etc/jobarchived.conf"
-"/usr/bin/jobarchived"
+%config "/etc/jobarchived.conf"
+%config "/etc/sysconfig/jobarchived"
 %dir "/usr/share/jobarchived/"
 "/usr/share/jobarchived/job_dbase.sql"
