X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=build.sh;h=ee4bd32dbc6b63d6ecc192d19a92a1d8d1346bb1;hb=d531cfaf5185ca1e74a5f15c2e3b1254968200de;hp=2334f2a0734559144f072cdd8a3ae79e1f418e72;hpb=2c02d23b234503e709b804cde1534dcf7cbad0b6;p=bootmanager.git diff --git a/build.sh b/build.sh index 2334f2a..ee4bd32 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,111 @@ #!/bin/bash +# +# Builds bootmanager.sh[.sgn], which is the PlanetLab Boot Manager script. +# +# The bootmanager.sh script contains in it a uuencoded tarball of the +# Boot Manager, customized for this PLC installation. +# +# Aaron Klingaman +# Mark Huang +# Marc E. Fiuczynski +# Copyright (C) 2004-2007 The Trustees of Princeton University +# -rm -f *.fo *.pdf pdn-titlepage.xsl +# Source PLC configuration +. /etc/planetlab/plc_config -#xsltproc -output pdn-titlepage.xsl \ -# /usr/share/sgml/docbook/xsl-stylesheets/template/titlepage.xsl \ -# pdn-titlepage.xml +# Do not tolerate errors +set -e + +# this is set by plc.d/bootmanager +DEPLOYMENT=$1 + +BOOTSTRAPDIR="/boot" + +# Change to our source directory +cd $(dirname $0) + +# Source bootmanager configuration +. source/configuration + +# Write boot script. nodeconfig/boot/index.php retrieves the contents of this script +# after checking the node id + +BMDIR=/var/www/html/boot +mkdir -p $BMDIR + +DEST_SCRIPT="$BMDIR/bootmanager_${DEPLOYMENT}.sh" +# Remove the old version or any sym links prior to re-writing +rm -f ${DEST_SCRIPT} +rm -f ${DEST_SCRIPT}.sgn + + +# hard code 443 here. +sed -i -e "s@^BOOT_API_SERVER.*@BOOT_API_SERVER=https://$PLC_API_HOST:443/$PLC_API_PATH/@" source/configuration + +sed -i -e "s@^BOOT_SERVER.*@BOOT_SERVER=$PLC_BOOT_HOST@" source/configuration +if [ "$PLC_MONITOR_ENABLED" = "1" ]; then + MONITOR_SERVER=$PLC_MONITOR_HOST +else + MONITOR_SERVER=$PLC_BOOT_HOST +fi +sed -i -e "s@^MONITOR_SERVER.*@MONITOR_SERVER=$MONITOR_SERVER@" source/configuration + +install -D -m 644 $PLC_BOOT_CA_SSL_CRT source/cacert/$PLC_BOOT_HOST/cacert.pem +if [ -f "$PLC_MONITOR_CA_SSL_CRT" ] ; then + install -D -m 644 "$PLC_MONITOR_CA_SSL_CRT" source/cacert/$PLC_MONITOR_HOST/cacert.pem +fi + +# Replace the default debug SSH key +if [ -f "$PLC_DEBUG_SSH_KEY_PUB" ] ; then + install -D -m 644 "$PLC_DEBUG_SSH_KEY_PUB" source/debug_files/debug_root_ssh_key +fi + +# Add python code from the following packages +# make sure they are in the 'Requires' header of the specfile +required_rpms="pypcilib pyplnet" +extra_libs=`mktemp -d "/tmp/.bootmanager.XXXXXX"` +mkdir $extra_libs/source +cp -p $(rpm -ql $required_rpms | grep -v '\.py[co]$') $extra_libs/source + + +########## create the bootmanager script +cat < $DEST_SCRIPT +#!/bin/bash +# +# PlanetLab Boot Manager $VERSION +# +# DO NOT EDIT. Generated by $USER@$HOSTNAME at +# $(date) +# + +# Do not tolerate errors +set -e + +(/usr/bin/uudecode | /bin/tar -C /tmp -xj) << _EOF_ +EOF + + +# Embed the uuencoded tarball in the script +tar -cj source/ -C $extra_libs source/ | uuencode -m - >> $DEST_SCRIPT + +# wrap up the script +echo '_EOF_' >> $DEST_SCRIPT +echo 'cd /tmp/source' >> $DEST_SCRIPT +echo 'chmod +x BootManager.py && ./BootManager.py' >> $DEST_SCRIPT + +# Remove temp directory +rm -fr $extra_libs + +# Sign the whole script, if the keyring is on this machine. +if [ -f "$PLC_ROOT_GPG_KEY" -a -f "$PLC_ROOT_GPG_KEY_PUB" ] ; then + gpg --homedir=/root \ + --no-default-keyring \ + --keyring "$PLC_ROOT_GPG_KEY_PUB" \ + --secret-keyring "$PLC_ROOT_GPG_KEY" \ + --yes --sign --output $DEST_SCRIPT.sgn \ + $DEST_SCRIPT +else + echo "Warning: Remember to sign $PWD/$DEST_SCRIPT!" >&2 +fi -xmlto -x pdn-pdf-style.xsl pdf boot-manager-pdn.xml