Implement -D option to set configuration directory; fai.conf: don't set variables...
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 96-apt-listbugs
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/96-apt-listbugs
3 # Purpose:       retreive list of bugreports of installed packages inside chroot
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -u
10 set -e
11
12 if [ -r $target/etc/apt/apt.conf.d/10apt-listbugs ] ; then
13   if [ -x $target/usr/sbin/apt-listbugs ] ; then
14     sed -i 's#//DPkg::#DPkg::#' $target/etc/apt/apt.conf.d/10apt-listbugs
15   fi
16 fi
17
18 set +u
19 if ifclass RELEASE ; then
20 set -u
21   HOSTNAME=''
22   [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
23   [ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
24   [ -n "$HOSTNAME" ] || HOSTNAME=grml
25
26   if [ -r /etc/resolv.conf ] ; then
27     if [ -d $target/etc/resolvconf/run ] ; then # resolvconf without /run
28       # sanity check to avoid "input file is output file",
29       # see http://bts.grml.org/grml/issue984
30       if ! [ -L $target/etc/resolvconf/run/resolv.conf ] ; then
31         cat /etc/resolv.conf >> $target/etc/resolvconf/run/resolv.conf
32       else
33         echo "Error: /etc/resolvconf/run/resolv.conf in chroot should not be a symlink." >&2
34         echo "       Looks like something is wrong, please fix manually." >&2
35         exit 1
36       fi
37     elif [ -L $target/etc/resolvconf/run ] ; then # resolvconf with /run
38       # /etc/resolvconf/run symlinks to /run/resolvconf
39       mkdir -p $target/run/resolvconf
40       cat /etc/resolv.conf >> $target/run/resolvconf/resolv.conf
41     else # no resolvconf installed in chroot
42       if ! [ -L $target/etc/resolv.conf ] ; then
43         cat /etc/resolv.conf >> $target/etc/resolv.conf
44       else
45         echo "Error: /etc/resolv.conf in chroot should not be a symlink (resolvconf not installed)." >&2
46         exit 1
47       fi
48     fi
49   fi
50
51   if [ -x $target/usr/sbin/apt-listbugs -a -x $target/usr/bin/apt-show-source ] && \
52      [ -x $target/etc/apt/grml/listbugs ] ; then
53      for severity in critical grave serious ; do
54          SEVERITY=$severity $ROOTCMD /etc/apt/grml/listbugs > \
55          /var/log/fai/$HOSTNAME/last/bugs.${severity} || true # make sure it does not fail
56      done
57   fi
58
59 fi
60
61 ## END OF FILE #################################################################
62 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2