clearer names for actions, and infer actions better
[monitor.git] / monitor-runlevelagent.init
index f22d587..165f7e8 100644 (file)
 # $Id$
 #
 
+function start_rla ()
+{
+       args=$1
+       ret=$( pgrep -f -l RunlevelAgent )
+       if [[ -z $ret ]] ; then
+           echo "Starting RunlevelAgent"
+               if [[ -f RunlevelAgent.py ]] ; then 
+                       RLA="/usr/bin/python ./RunlevelAgent.py"
+               else
+                       RLA=/usr/bin/RunlevelAgent.py
+               fi
+               $RLA $args > /var/log/rla.log 2>&1 &
+       fi
+}
+
 case "$1" in
     start|restart|reload)
+
+               start_rla $2
+
        ;;
     stop|status)
-       exit 0
+               pkill -f RunlevelAgent
+               exit 0
        ;;
     *)
-       echo $"Usage: $0 {start|stop|restart|status}"
+               echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
        ;;
 esac
 
-# NOTE: If user already exists, this just exists with status 9.  I think it's
-# ok to simply let this command check and error out.
-# Parse PLC configuration
-if [ -r /etc/planetlab/plc_config ] ; then
-    . /etc/planetlab/plc_config
-else
-    PLC_NAME="PlanetLab"
-    PLC_SLICE_PREFIX="pl"
-    PLC_BOOT_HOST="boot.planet-lab.org"
-fi
-
-USER="${PLC_SLICE_PREFIX}_monitor"
-/usr/sbin/useradd -p "" -m $USER &> /dev/null || : 
-
-if [ ! -d /home/$USER/.ssh ] ; then
-       mkdir /home/$USER/.ssh
-       chmod 700 /home/$USER/.ssh
-       chown $USER.$USER /home/$USER/.ssh
-fi
-
-URL="http://${PLC_BOOT_HOST}/PlanetLabConf/keys.php?$USER"
-curl -s "$URL" > /home/$USER/.ssh/authorized_keys
-chown $USER.$USER /home/$USER/.ssh/authorized_keys