password generation utility was still python2
[bootcd.git] / plc.d / bootcd-kernel
1 #!/bin/bash
2 # $Id$
3 # $URL$
4 #
5 # priority: 999
6 #
7 # Build BootCD variants with kernels specified in /etc/planetlab/bootcd-variants
8 #
9
10 # Source function library and configuration
11 . /etc/plc.d/functions
12
13 # Be verbose
14 set -x
15
16 case "$1" in
17     start)
18         MESSAGE=$"Creating BootCD variants"
19         dialog "$MESSAGE"
20
21         success=0
22         for i in /usr/share/bootcd-*; do
23                 pushd $i
24                 basearch=$(echo $i | awk -F- '{ print $NF }')
25                 arch=$(echo $basearch | sed 's/i386/i686/')
26                 for j in $(ls -d /etc/planetlab/bootcd-variants/* 2> /dev/null); do
27                         name="${j##*/}"
28                         url=$(cat "$j" | sed "s!@BASEARCH@!$basearch!g;s!@ARCH@!$arch!g")
29                         if test -d "$name"; then
30                                 test build/isofs/bootcd.img -nt "$name/isofs/bootcd.img" || continue
31                         elif test "$name" = default; then
32                                 # Not ideal, but...
33                                 grep -q support@ build/isofs/kernel || continue
34                         fi
35                         if test "$url" != $(echo "$url" | sed s#[:/]##); then
36                                 ./kvariant.sh "$name" "$url"
37                         else
38                                 dir=$(mktemp -d -p /var/tmp)
39                                 yumdownloader --destdir "$dir" "$url"
40                                 ./kvariant.sh "$name" "$dir"/"$url"*
41                                 rm -fr "$dir"
42                         fi
43                         if test "$name" = default; then
44                                 rm -fr orig
45                                 mv build orig
46                                 mv default build
47                         fi
48                 done
49                 popd
50         done
51         test $success = 0
52         check
53
54         result "$MESSAGE"
55         ;;
56 esac
57
58 exit $ERRORS