2a3469b3cd269963d8fbf5a2bc1afa4dc6012871
[bootcd.git] / plc.d / bootcd
1 #!/bin/bash
2 #
3 # priority: 1000
4 #
5 # Rebuild the Boot CD
6 #
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
9 #
10 # $Id$
11 # $URL$
12 #
13
14 # Source function library and configuration
15 . /etc/plc.d/functions
16 . /etc/planetlab/plc_config
17
18 # Be verbose
19 set -x
20
21 case "$1" in
22     start)
23         if [ "$PLC_BOOT_ENABLED" != "1" -a \
24              "$PLC_WWW_ENABLED" != "1" ] ; then
25             exit 0
26         fi
27
28         MESSAGE=$"Rebuilding Boot CD"
29         dialog "$MESSAGE"
30
31         # Customize the Boot CD : run build.sh on all available bootcd's
32         shopt -s nullglob
33         # xxx nodefamily xxx - might make sense to detect sequel from older installs
34         for bootcd in /usr/share/bootcd-* ; do
35             name=$(basename $bootcd)
36             nodefamily=$(echo $name | sed -e s,bootcd-,,)
37             download=/var/www/html/download-${nodefamily}
38             [ -d ${download} ] || mkdir -p ${download}
39
40             pushd ${download}
41             ${bootcd}/build.sh ${PLC_BUILD_ALL_BOOTCDS:+-a}
42             check
43             popd
44         
45         done
46
47         # just issue a warning about legacy locations
48         for legacy in /usr/share/bootcd /var/www/html/download ; do
49             [ -e $legacy ] && echo "WARNING: found legacy location $legacy -- ignored"
50         done
51
52         result "$MESSAGE"
53         ;;
54 esac
55
56 exit $ERRORS