HTCondor Project List Archives



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Condor-devel] Patch for condor.init on Ubuntu



I don't know if this is useful to you guys, but here's a patch to get the 
condor.init script to work on Ubuntu. It mainly fixes the functions calls for 
the system start/stop functions and to fix the paths to be the standard 
locations needed by Debian's init infrastructure.

I've also added a hack borrowed from condor.boot to get the PID of the 
condor_master, if the Debian start-stop-daemon fails to create the pid file.
-- 
Andy Pavlo
pavlo@xxxxxxxxxxx
--- condor.init.orig	2008-11-16 15:58:53.000000000 -0500
+++ condor.init	2008-11-16 15:59:01.000000000 -0500
@@ -7,7 +7,7 @@
 # 	       platform.
 # processname: condor_master
 # config: /etc/condor/condor_config
-# pidfile: /var/lib/condor/condor_master.pid
+# pidfile: /var/run/condor_master.pid
 
 ### BEGIN INIT INFO
 # Provides: condor
@@ -20,11 +20,11 @@
 # The program being managed
 prog=condor_master
 
-lockfile=/var/lock/subsys/$prog
-pidfile=/var/lib/condor/$prog.pid
+lockfile=/var/lock/$prog
+pidfile=/var/run/$prog.pid
 
 # Source function library
-. /etc/init.d/functions
+. /lib/lsb/init-functions
 
 # Source networking configuration
 [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
@@ -37,29 +37,37 @@
 
 
 start() {
-    echo -n $"Starting Condor daemons: "
-    daemon --pidfile $pidfile --check $prog $prog -pidfile $pidfile
+    log_daemon_msg "Starting Condor daemons" "condor"
+    start_daemon -p "$pidfile" "/usr/sbin/$prog"
     RETVAL=$?
-    echo
     [ $RETVAL -eq 0 ] && touch $lockfile
+    ## Hack for Debian
+    ## We don't seem to get our PID file created correctly, so we'll 
+    ## try to create it ourself
+    if [ ! -f "$pidfile" ]; then
+        PS="/bin/ps auwx"
+        pid=`$PS | grep $prog | grep -v grep | grep -v init | awk '{print $2}'`
+        echo $pid > $pidfile
+    fi
+    
+    log_action_end_msg $RETVAL
     return $RETVAL
 }
 
 stop() {
-    echo -n $"Stopping Condor daemons: "
-    killproc -p $pidfile -d 3 $prog
+    log_daemon_msg "Stopping Condor daemons" "condor"
+    killproc -p "$pidfile" "$prog"
     RETVAL=$?
-    echo
     [ $RETVAL -eq 0 ] && rm -f $lockfile
+    log_action_end_msg $RETVAL
     return $RETVAL
 }
 
 reload() {
-    echo -n $"Reloading Condor daemons: "
+    log_daemon_msg "Reloading Condor daemons" "condor"
     kill -HUP `cat $pidfile` &>/dev/null
     RETVAL=$?
-    echo_success
-    echo
+    log_action_end_msg $RETVAL
     return $RETVAL
 }
 
@@ -113,11 +121,11 @@
 if [ "$1" != "status" ]; then
     # Report that $prog does not exist, or is not executable
     if [ ! -x /usr/sbin/$prog ]; then
-	echo $"$0: error: program not installed"
+	log_action_msg "$0: error: program not installed"
 	exit 5
     fi
 
-    [ $running -eq 4 ] && echo $"$0: error: insufficient privileges" && exit 7
+    [ $running -eq 4 ] && log_action_msg "$0: error: insufficient privileges" && exit 7
 fi
 
 case "$1" in
@@ -144,7 +152,7 @@
 	;;
     reload|force-reload)
 	if [ $running -ne 0 ]; then
-	    echo $"$0: error: $prog is not running"
+	    log_action_msg "$0: error: $prog is not running"
 	    exit 7
 	fi
 	reload
@@ -153,10 +161,10 @@
     status)
 	if [ $running -ne 0 ]; then
 	    case "$running" in
-		1) echo $"$prog dead but pid file exists" ;;
-		2) echo $"$prog dead but subsys locked" ;;
-		3) echo $"$prog is stopped" ;;
-		4) echo $"$prog status is unknown" ;;
+		1) log_action_msg "$prog dead but pid file exists" ;;
+		2) log_action_msg "$prog dead but subsys locked" ;;
+		3) log_action_msg "$prog is stopped" ;;
+		4) log_action_msg "$prog status is unknown" ;;
 	    esac
 
 	    exit $running
@@ -164,7 +172,7 @@
 
 	# WARNING: status uses pidof and may find more pids than it
 	# should.
-	status -p $pidfile $prog
+	status_of_proc -p $pidfile $prog $prog
 	RETVAL=$?
 	;;
     *)