| 1 |
#! /bin/sh -e |
| 2 |
# postinst script for fprobe |
| 3 |
|
| 4 |
# Use debconf. |
| 5 |
. /usr/share/debconf/confmodule |
| 6 |
|
| 7 |
# generate default file if it doesn't exist |
| 8 |
if [ ! -e /etc/default/fprobe ]; then |
| 9 |
cat > /etc/default/fprobe <<-END |
| 10 |
#fprobe default configuration file |
| 11 |
|
| 12 |
INTERFACE="eth0" |
| 13 |
FLOW_COLLECTOR="localhost:2055" |
| 14 |
|
| 15 |
#fprobe can't distinguish IP packet from other (e.g. ARP) |
| 16 |
OTHER_ARGS="-fip" |
| 17 |
END |
| 18 |
fi |
| 19 |
|
| 20 |
if [ "$1" = "configure" ]; then |
| 21 |
db_get fprobe/interface && interface="$RET" |
| 22 |
db_get fprobe/collector && collector="$RET" |
| 23 |
|
| 24 |
# If the admin deleted or commented some variables but then set |
| 25 |
# them via debconf, (re-)add them to the conffile. |
| 26 |
test -z "$interface" || grep -Eq '^ *INTERFACE=' /etc/default/fprobe || \ |
| 27 |
echo "INTERFACE=" >> /etc/default/fprobe |
| 28 |
test -z "$collector" || grep -Eq '^ *FLOW_COLLECTOR=' /etc/default/fprobe || \ |
| 29 |
echo "FLOW_COLLECTOR=" >> /etc/default/fprobe |
| 30 |
|
| 31 |
sed -i "s/^INTERFACE=.*$/INTERFACE=\"$interface\"/" /etc/default/fprobe |
| 32 |
sed -i "s/^FLOW_COLLECTOR=.*$/FLOW_COLLECTOR=\"$collector\"/" /etc/default/fprobe |
| 33 |
fi |
| 34 |
|
| 35 |
#close all fd's |
| 36 |
db_stop |
| 37 |
|
| 38 |
if [ "$1" = "configure" ] && [ -f /etc/init.d/fprobe-ng ]; then |
| 39 |
echo "I: Removing fprobe-ng configuration files" |
| 40 |
rm -f /etc/init.d/fprobe-ng |
| 41 |
rm -f /etc/default/fprobe-ng |
| 42 |
update-rc.d fprobe-ng remove >/dev/null || exit 0 |
| 43 |
fi |
| 44 |
|
| 45 |
|
| 46 |
#DEBHELPER# |
| 47 |
|
| 48 |
exit 0 |