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 <equinox@diac24.net>
This commit is contained in:
David Lamparter 2018-12-14 22:43:39 +01:00
parent d29f324aa8
commit f673b4f640
3 changed files with 74 additions and 1 deletions

18
debian/frr.postinst vendored
View 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

2
debian/frr.postrm vendored
View 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

55
debian/frr.preinst vendored
View 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