Add script GRMLBASE/37-portmap to work around bug in #317358
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 37-portmap
1 #!/bin/sh
2 # Filename:      /etc/grml/fai/config/scripts/GRMLBASE/37-portmap
3 # Purpose:       configure portmap of live-system
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 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
13 [ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
14
15 # Work around a bug in the portmap package, see
16 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=317358
17
18 CONFFILE="$target/etc/default/portmap"
19
20 if [ -r "$CONFFILE" ] ; then
21  # modify it iff we have portmap's default configuration
22  if grep -q '^OPTIONS="-i 127.0.0.1"' "$CONFFILE" ; then
23    # disable the "-i 127.0.0.1" configuration so it works e.g. with
24    # grml-terminalserver OOTB:
25    printf "Removing loopback-interface-only option (workaround #317358) in /etc/default/portmap: "
26    sed -i 's/^OPTIONS.*/# OPTIONS="-i 127.0.0.1"/' "$CONFFILE" && echo OK || echo ERROR
27  fi
28 else # no /etc/default/portmap available yet:
29  printf "Building fresh /etc/default/portmap configuration file."
30  cat > "$CONFFILE" << EOF
31 # Portmap configuration file
32 #
33 # Note: if you manually edit this configuration file,
34 # portmap configuration scripts will avoid modifying it
35 # (for example, by running 'dpkg-reconfigure portmap').
36
37 # If you want portmap to listen only to the loopback
38 # interface, uncomment the following line (it will be
39 # uncommented automatically if you configure this
40 # through debconf).
41 # OPTIONS="-i 127.0.0.1"
42 EOF
43 fi
44
45 ## END OF FILE #################################################################
46 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3