rework resolvconf handling
[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     case "$(readlink -f ${target}/etc/resolv.conf)" in
28       /run/*) # resolvconf with /run
29         mkdir -p $target/run/resolvconf
30         cat /etc/resolv.conf >> $target/run/resolvconf/resolv.conf
31         ;;
32       /lib/*) # resolvconf without /run
33         # sanity check to avoid "input file is output file",
34         # see http://bts.grml.org/grml/issue984
35         if ! [ -L $target/etc/resolvconf/run/resolv.conf ] ; then
36           cat /etc/resolv.conf >> $target/etc/resolvconf/run/resolv.conf
37         else
38           echo "Error: /etc/resolvconf/run/resolv.conf in chroot should not be a symlink." >&2
39           echo "       Looks like something is wrong, please fix manually." >&2
40           exit 1
41         fi
42         ;;
43       *) # no resolvconf
44         if ! [ -L $target/etc/resolv.conf ] ; then
45           cat /etc/resolv.conf >> $target/etc/resolv.conf
46         else
47           echo "Error: /etc/resolv.conf in chroot should not be a symlink (resolvconf not installed)." >&2
48           exit 1
49         fi
50         ;;
51     esac
52   fi
53
54   if [ -x $target/usr/sbin/apt-listbugs -a -x $target/usr/bin/apt-show-source ] && \
55      [ -x $target/etc/apt/grml/listbugs ] ; then
56      for severity in critical grave serious ; do
57          SEVERITY=$severity $ROOTCMD /etc/apt/grml/listbugs > \
58          /var/log/fai/$HOSTNAME/last/bugs.${severity} || true # make sure it does not fail
59      done
60   fi
61
62 fi
63
64 ## END OF FILE #################################################################
65 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2