File: postinst

package info (click to toggle)
fprobe 1.1-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, trixie
  • size: 764 kB
  • sloc: sh: 3,165; ansic: 2,177; makefile: 15
file content (48 lines) | stat: -rw-r--r-- 1,356 bytes parent folder | download | duplicates (3)
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
#! /bin/sh -e
# postinst script for fprobe

# Use debconf.
. /usr/share/debconf/confmodule

# generate default file if it doesn't exist
if [ ! -e /etc/default/fprobe ]; then
	cat > /etc/default/fprobe <<-END
	#fprobe default configuration file
	
	INTERFACE="eth0"
	FLOW_COLLECTOR="localhost:2055"	
	
	#fprobe can't distinguish IP packet from other (e.g. ARP)
	OTHER_ARGS="-fip"
	END
fi

if [ "$1" = "configure" ]; then
    db_get fprobe/interface && interface="$RET"
    db_get fprobe/collector && collector="$RET"
		
    # If the admin deleted or commented some variables but then set
    # them via debconf, (re-)add them to the conffile.
    test -z "$interface" || grep -Eq '^ *INTERFACE=' /etc/default/fprobe || \
    	echo "INTERFACE=" >> /etc/default/fprobe
    test -z "$collector" || grep -Eq '^ *FLOW_COLLECTOR=' /etc/default/fprobe || \
	    echo "FLOW_COLLECTOR=" >> /etc/default/fprobe

    sed -i "s/^INTERFACE=.*$/INTERFACE=\"$interface\"/" /etc/default/fprobe
    sed -i "s/^FLOW_COLLECTOR=.*$/FLOW_COLLECTOR=\"$collector\"/" /etc/default/fprobe
fi	

#close all fd's
db_stop

if [ "$1" = "configure" ] && [ -f /etc/init.d/fprobe-ng ]; then
        echo "I: Removing fprobe-ng configuration files"
	rm -f /etc/init.d/fprobe-ng
	rm -f /etc/default/fprobe-ng
        update-rc.d fprobe-ng remove >/dev/null || exit 0
fi


#DEBHELPER#

exit 0