From f673b4f640315c19f73cc4147ce051a59e9504ff Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 14 Dec 2018 22:43:39 +0100 Subject: [PATCH] debian: keep working nicely with split config Drop our configs that say integrated config when there is some pre-existing split config. Signed-off-by: David Lamparter --- debian/frr.postinst | 18 +++++++++++++++ debian/frr.postrm | 2 ++ debian/frr.preinst | 55 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/debian/frr.postinst b/debian/frr.postinst index 9be6f38018..a6dff333aa 100644 --- a/debian/frr.postinst +++ b/debian/frr.postinst @@ -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 diff --git a/debian/frr.postrm b/debian/frr.postrm index bbce0daf18..018f59e1c5 100644 --- a/debian/frr.postrm +++ b/debian/frr.postrm @@ -1,6 +1,8 @@ #!/bin/sh set -e +rm -f /etc/frr/.pkg.frr.nointegrated + if [ "$1" = "purge" ]; then rm -rf /run/frr || true diff --git a/debian/frr.preinst b/debian/frr.preinst index 56ebc707ca..fe087c6a7c 100644 --- a/debian/frr.preinst +++ b/debian/frr.preinst @@ -12,7 +12,7 @@ install|upgrade) if [ "$watchfrr_enable" = no -o \ "$watchfrr_enable" = "0" ]; then - echo >&2 <&2 < 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 < 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