]> git.puffer.fish Git - mirror/frr.git/commitdiff
debian: keep working nicely with split config
authorDavid Lamparter <equinox@diac24.net>
Fri, 14 Dec 2018 21:43:39 +0000 (22:43 +0100)
committerDavid Lamparter <equinox@diac24.net>
Tue, 18 Dec 2018 01:18:18 +0000 (02:18 +0100)
Drop our configs that say integrated config when there is some
pre-existing split config.

Signed-off-by: David Lamparter <equinox@diac24.net>
debian/frr.postinst
debian/frr.postrm
debian/frr.preinst

index 9be6f38018c1b85a5e3c1e69bea6a57b3085ce58..a6dff333aae283f197cbad31e0d262d361edb65f 100644 (file)
@@ -64,10 +64,28 @@ the FRR service but its contents should be migrated to /etc/frr/daemons.
 EOF
 }
 
+rmsum() {
+       fname="$1"
+       test -f "$1" || return 0
+       fhash="`sha1sum \"$fname\"`"
+       fhash="${fhash%% *}"
+       if test "$fhash" = "$2"; then
+               rm "$fname"
+       fi
+}
+
 case "$1" in
 configure)
        check_old_config /etc/frr/daemons.conf
        check_old_config /etc/default/frr
+       if test -f /etc/frr/.pkg.frr.nointegrated; then
+               # remove integrated config setup
+               # (if checksums match, the files match freshly installed
+               # defaults, but the user has split config in place)
+               rmsum /etc/frr/vtysh.conf 5e7e3a488c51751e1ff98f27c9ad6085e1ad9cbb
+               rmsum /etc/frr/frr.conf   dac6f2af4fca9919ba40eb338885a5d1773195c8
+               rm /etc/frr/.pkg.frr.nointegrated
+       fi
        ;;
 esac
 
index bbce0daf182458790728af22dc3a50f5d74cf3d9..018f59e1c5fcf05b6f6c4d1b67fe118831cbd95b 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/sh
 set -e
 
+rm -f /etc/frr/.pkg.frr.nointegrated
+
 if [ "$1" = "purge" ]; then
        rm -rf /run/frr || true
 
index 56ebc707ca3ff70f7498e5402126a89fd5ba28a9..fe087c6a7c7522754306b21d4f7e6209e9a162cd 100644 (file)
@@ -12,7 +12,7 @@ install|upgrade)
 
                if [ "$watchfrr_enable" = no -o \
                        "$watchfrr_enable" = "0" ]; then
-                       echo >&2 <<EOF
+                       cat >&2 <<EOF
 ERROR: Pre-existing frr configuration file disables watchfrr.
 
 This configuration is deprecated upstream and not supported by the Debian
@@ -23,6 +23,59 @@ EOF
                        exit 1
                fi
        )
+       vtysh=''
+       if test -f /etc/frr/vtysh.conf; then
+               if grep -q '^[[:space:]]*service[[:space:]]\+integrated-vtysh-config' /etc/frr/vtysh.conf; then
+                       # existing vtysh.conf with integrated statement
+                       # - do nothing (=> integrated config)
+                       vtysh='i'
+               elif grep -q '^[[:space:]]*no[[:space:]]\+service[[:space:]]\+integrated-vtysh-config' /etc/frr/vtysh.conf; then
+                       # explicit non-integrated
+                       # => need to fix vtysh.conf & frr.conf in postinst
+                       vtysh='ni'
+                       if test -f /etc/frr/frr.conf; then
+                               cat >&2 <<EOF
+ERROR: Pre-existing /etc/frr/vtysh.conf specifies
+"no service integrated-vtysh-config", but /etc/frr/frr.conf exists.  This
+will cause the frr package to malfunction.  Please remove /etc/frr/frr.conf
+or remove the "no service integrated-vtysh-config" statement from
+/etc/frr/vtysh.conf.
+EOF
+                               exit 1
+                       fi
+               else
+                       # vtysh.conf exists but has no statement
+                       :
+               fi
+       fi
+       if test -f /etc/frr/frr.conf; then
+               # vtysh.conf has no explicit statement but frr.conf exists
+               # => integrated config used
+               vtysh='i'
+       elif test -f /etc/frr/zebra.conf \
+               -o -f /etc/frr/bgpd.conf \
+               -o -f /etc/frr/ospfd.conf \
+               -o -f /etc/frr/ospf6d.conf \
+               -o -f /etc/frr/ripd.conf \
+               -o -f /etc/frr/ripngd.conf \
+               -o -f /etc/frr/isisd.conf \
+               -o -f /etc/frr/pimd.conf \
+               -o -f /etc/frr/ldpd.conf \
+               -o -f /etc/frr/nhrpd.conf \
+               -o -f /etc/frr/eigrpd.conf \
+               -o -f /etc/frr/babeld.conf \
+               -o -f /etc/frr/pbrd.conf \
+               -o -f /etc/frr/bfdd.conf; then
+               # no explicit statement, but some split config file exists
+               # => need to fix vtysh.conf & frr.conf in postinst
+               test -n "$vtysh" || vtysh='ni'
+       else
+               # no config at all - use integrated
+               :
+       fi
+       if test "$vtysh" = "ni"; then
+               touch /etc/frr/.pkg.frr.nointegrated
+       fi
        ;;
 abort-upgrade)
        # shouldn't fail an upgrade abort