3 # Builds bootmanager.sh[.sgn], which is the PlanetLab Boot Manager script.
5 # The bootmanager.sh script contains in it a uuencoded tarball of the
6 # Boot Manager, customized for this PLC installation.
8 # Aaron Klingaman <alk@absarokasoft.com>
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # Marc E. Fiuczynski <mef@cs.princeton.edu>
11 # Copyright (C) 2004-2007 The Trustees of Princeton University
14 # Source PLC configuration
15 . /etc/planetlab/plc_config
17 # Do not tolerate errors
20 # this is set by plc.d/bootmanager
25 # Change to our source directory
28 # Source bootmanager configuration
29 . source/configuration
31 # Write boot script. nodeconfig/boot/index.php retrieves the contents of this script
32 # after checking the node id
34 BMDIR=/var/www/html/boot
37 DEST_SCRIPT="$BMDIR/bootmanager_${DEPLOYMENT}.sh"
38 # Remove the old version or any sym links prior to re-writing
40 rm -f ${DEST_SCRIPT}.sgn
44 sed -i -e "s@^BOOT_API_SERVER.*@BOOT_API_SERVER=https://$PLC_API_HOST:443/$PLC_API_PATH/@" source/configuration
46 sed -i -e "s@^BOOT_SERVER.*@BOOT_SERVER=$PLC_BOOT_HOST@" source/configuration
47 if [ "$PLC_MONITOR_ENABLED" = "1" ]; then
48 MONITOR_SERVER=$PLC_MONITOR_HOST
50 MONITOR_SERVER=$PLC_BOOT_HOST
52 sed -i -e "s@^MONITOR_SERVER.*@MONITOR_SERVER=$MONITOR_SERVER@" source/configuration
54 install -D -m 644 $PLC_BOOT_CA_SSL_CRT source/cacert/$PLC_BOOT_HOST/cacert.pem
55 if [ -f "$PLC_MONITOR_CA_SSL_CRT" ] ; then
56 install -D -m 644 "$PLC_MONITOR_CA_SSL_CRT" source/cacert/$PLC_MONITOR_HOST/cacert.pem
59 # Replace the default debug SSH key
60 if [ -f "$PLC_DEBUG_SSH_KEY_PUB" ] ; then
61 install -D -m 644 "$PLC_DEBUG_SSH_KEY_PUB" source/debug_files/debug_root_ssh_key
64 # Add python code from the following packages
65 # make sure they are in the 'Requires' header of the specfile
66 required_rpms="pypcilib pyplnet"
67 extra_libs=`mktemp -d "/tmp/.bootmanager.XXXXXX"`
68 mkdir $extra_libs/source
69 cp -p $(rpm -ql $required_rpms | grep -v '\.py[co]$') $extra_libs/source
72 ########## create the bootmanager script
73 cat <<EOF > $DEST_SCRIPT
76 # PlanetLab Boot Manager $VERSION
78 # DO NOT EDIT. Generated by $USER@$HOSTNAME at
82 # Do not tolerate errors
85 (/usr/bin/uudecode | /bin/tar -C /tmp -xj) << _EOF_
89 # Embed the uuencoded tarball in the script
90 tar -cj source/ -C $extra_libs source/ | uuencode -m - >> $DEST_SCRIPT
93 echo '_EOF_' >> $DEST_SCRIPT
94 echo 'cd /tmp/source' >> $DEST_SCRIPT
95 echo 'chmod +x BootManager.py && ./BootManager.py' >> $DEST_SCRIPT
97 # Remove temp directory
100 # Sign the whole script, if the keyring is on this machine.
101 if [ -f "$PLC_ROOT_GPG_KEY" -a -f "$PLC_ROOT_GPG_KEY_PUB" ] ; then
102 gpg --homedir=/root \
103 --no-default-keyring \
104 --keyring "$PLC_ROOT_GPG_KEY_PUB" \
105 --secret-keyring "$PLC_ROOT_GPG_KEY" \
106 --yes --sign --output $DEST_SCRIPT.sgn \
109 echo "Warning: Remember to sign $PWD/$DEST_SCRIPT!" >&2