wrong name.
[monitor.git] / monitor-runlevelagent.init
1 #!/bin/bash
2 #
3 # monitor-runlevelagent starts the RunlevelAgent in production mode.
4 #
5 # Load before nm, vcached, and vservers, vserver-reference
6 # chkconfig: 3 14 85
7 # description: Start RunlevelAgent to report the current Runlevel to PLC at
8 #               periodic intervals.
9 #
10 # Stephen Soltesz <soltesz@cs.princeton.edu>
11 # Copyright (C) 2008 The Trustees of Princeton University
12 #
13 # $Id$
14 #
15
16 case "$1" in
17     start|restart|reload)
18         ;;
19     stop|status)
20         exit 0
21         ;;
22     *)
23         echo $"Usage: $0 {start|stop|restart|status}"
24         exit 1
25         ;;
26 esac
27
28 # NOTE: If user already exists, this just exists with status 9.  I think it's
29 # ok to simply let this command check and error out.
30 # Parse PLC configuration
31 if [ -r /etc/planetlab/plc_config ] ; then
32     . /etc/planetlab/plc_config
33 else
34     PLC_NAME="PlanetLab"
35     PLC_SLICE_PREFIX="pl"
36     PLC_BOOT_HOST="boot.planet-lab.org"
37 fi
38
39 USER="${PLC_SLICE_PREFIX}_monitor"
40 /usr/sbin/useradd -p "" -m $USER &> /dev/null || : 
41
42 if [ ! -d /home/$USER/.ssh ] ; then
43         mkdir /home/$USER/.ssh
44         chmod 700 /home/$USER/.ssh
45         chown $USER.$USER /home/$USER/.ssh
46 fi
47
48 URL="http://${PLC_BOOT_HOST}/PlanetLabConf/keys.php?$USER"
49 curl -s "$URL" > /home/$USER/.ssh/authorized_keys
50 chown $USER.$USER /home/$USER/.ssh/authorized_keys