350f613dbf86391dcabf16d3a25bcfc22a8f0816
[grml-live.git] / patches / fai_chroot_update.patch
1 --- subroutines.orig    2007-12-16 11:20:12.000000000 +0000
2 +++ subroutines 2007-12-16 11:23:01.000000000 +0000
3 @@ -294,6 +294,10 @@
4             echo Performing FAI system update. All data may be overwritten!
5             task softupdate
6             ;;
7 +       chrootupdate)
8 +           echo Performing FAI chroot update. All data may be overwritten!
9 +           task chrootupdate
10 +           ;;
11         sysinfo)
12             echo Showing system information.
13             task sysinfo
14 @@ -568,6 +572,49 @@
15  }
16  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17  
18 +task_chrootupdate() {
19 +
20 +    local stamp=/var/run/fai/fai_chrootupdate_is_running
21 +
22 +    [ -f "$stamp" ] && die "Another fai chrootupdate is already running. Aborting."
23 +    echo $$ > $stamp
24 +    # if the system had been installed using fai < 3.0 disk_var.sh is found in /etc/fai
25 +    if [ ! -f /var/lib/fai/disk_var.sh -a -f /etc/fai/disk_var.sh ] ; then
26 +      mv /etc/fai/disk_var.sh /var/lib/fai/
27 +    fi
28 +    # the following copy operation is required to make $LOGDIR a reliable source
29 +    # for disk_var.sh
30 +    # use the last disk_var during update if available
31 +    [ -f /var/lib/fai/disk_var.sh ] && cp -p /var/lib/fai/disk_var.sh $LOGDIR 
32 +
33 +    defnop wait_for_jobs
34 +    save_dmesg
35 +
36 +    task mirror
37 +    task debconf
38 +    task configure
39 +    date
40 +    echo "The $FAI_ACTION took $[$(cut -d . -f 1 /proc/uptime)-$start_seconds] seconds."
41 +
42 +    rm -f $stamp
43 +    # save again, because new messages could be created
44 +    save_dmesg
45 +    task savelog
46 +
47 +    if [ -f $stamp ]; then
48 +       echo "Error while executing commands in subshell."
49 +       echo -n "$stamp was not removed. PID of running process: "
50 +       cat $stamp
51 +       sendmon "TASKERROR chrootupdate 21"
52 +       die "Please look at the log files in $LOGDIR for errors."
53 +    fi
54 +    echo $FAI_CONFIG_SRC | grep -q ^nfs://
55 +    if [ $? -eq 0 ]; then
56 +       grep -q ^$FAI /etc/mtab && umount $FAI
57 +    fi
58 +}
59 +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60 +
61  catnc() {
62      # cat but no comment lines
63      egrep -v "^#" $@