-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·111 lines (86 loc) · 2.98 KB
/
build.sh
File metadata and controls
executable file
·111 lines (86 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/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 <alk@absarokasoft.com>
# Mark Huang <mlhuang@cs.princeton.edu>
# Marc E. Fiuczynski <mef@cs.princeton.edu>
# Copyright (C) 2004-2007 The Trustees of Princeton University
#
# Source PLC configuration
. /etc/planetlab/plc_config
# 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 <<EOF > $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