ba981b6f0efaf645822eb48d21dd32e3d7247b3e
[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         dialog $"Rebuilding Boot CD"
29
30         # Customize the Boot CD : run build.sh on all available bootcd's
31         shopt -s nullglob
32         # xxx nodefamily xxx - might make sense to detect sequel from older installs
33         for bootcd in /usr/share/bootcd-* ; do
34             name=$(basename $bootcd)
35             nodefamily=$(echo $name | sed -e s,bootcd-,,)
36             download=/var/www/html/download-${nodefamily}
37             [ -d ${download} ] || mkdir -p ${download}
38
39             pushd ${download}
40             action $"Rebuilding BootCD" "$name"
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