summaryrefslogtreecommitdiffstats
path: root/debian/frr.preinst
blob: 2af5a4ed8f703907791d1790f6047055c26052c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
set -e
# bash is required since /etc/frr/daemons.conf used a bash array in some
# previous versions.

# NOTE: this code exists specifically to make migrations from Quagga to
# FRR easier.  FRR is able to load most Quagga configurations, but the
# config handling itself has changed with the move towards the "integrated"
# /etc/frr/frr.conf approach instead of separate per-daemon config files.
#
# That said, with this in place there's a good chance users can use a
# preexisting Quagga config with little hassle.

case "$1" in
install|upgrade)
	(
		test -f /etc/frr/daemons      && . /etc/frr/daemons
		test -f /etc/frr/daemons.conf && . /etc/frr/daemons.conf
		test -f /etc/default/frr      && . /etc/default/frr

		if [ "$watchfrr_enable" = no -o \
			"$watchfrr_enable" = "0" ]; then
			cat >&2 <<EOF
ERROR: Pre-existing frr configuration file disables watchfrr.

This configuration is deprecated upstream and not supported by the Debian
FRR package.  Refusing to $1 in order to not break running setups.
Please change your setup to use watchfrr and remove the "watchfrr_enable"
option from /etc/frr/daemons, /etc/frr/daemons.conf and/or /etc/default/frr.
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/pathd.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
	;;
esac

#DEBHELPER#