File: postinst

package info (click to toggle)
argus 1%3A2.0.6.fixes.1-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,960 kB
  • ctags: 4,025
  • sloc: ansic: 23,022; sh: 5,712; makefile: 378; yacc: 255; lex: 234
file content (105 lines) | stat: -rw-r--r-- 2,618 bytes parent folder | download
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
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
set -e
. /usr/share/debconf/confmodule

OK=0
CONFIG=/etc/default/argus-server
PATH=/bin:/sbin:/usr/bin:/usr/sbin
PIDFILE=/var/run/argus.pid
VALIDVALUES="both none dialup boot"

db_get argus/startup || true
DEBSTARTUP=$RET
db_get argus/overwrite_conffile || true
OVERWRITE=$RET
db_stop

if [ ! -f "$CONFIG" -a "$OVERWRITE" = "no" ]; then
    . $CONFIG
fi

for i in $VALIDVALUES; do
    if [ "$i" = "$STARTUP" ]; then
	OK=1
    fi
done

if [ $OK != 1 ]; then
    STARTUP=$DEBSTARTUP
fi

PPP_INTERFACES=`ifconfig -a | awk '{print $1}' | grep ppp || true`

case "$1" in
	install)
	    ;;
	upgrade)
		if [ -f $PIDFILE ] && [ -n `ps ax | grep ^\`cat $PIDFILE\` | grep argus` ]; then
		    invoke-rc.d argus-server stop /dev/null 2>/dev/null  || true
		elif [ "$STARTUP" = "dialup" ] || [ "$STARTUP" = "both" ]; then
		    for i in $PPP_INTERFACES; do
			echo -n "Stopping network auditing daemon on $i: "
			test -f /var/run/argus.${i} && \
			    PPP_IFACE=$i /etc/ppp/ip-down.d/argus-server > /dev/null 2>&1 || true
			    echo "argus."
		    done
		fi
	    ;;
	configure)
		# Remove old /etc/logrotate.d/argus file left after 2.0.6.rc3-2
		if [ -e /etc/logrotate.d/argus ] && [ -e /etc/logrotate.d/argus-server ]; then
			rm -f /etc/logrotate.d/argus
		fi
		update-rc.d argus-server defaults 20 > /dev/null
		if [ "$STARTUP" = "none" ]; then
		    invoke-rc.d argus-server stop /dev/null 2>/dev/null || true
		    for i in $PPP_INTERFACES; do
			echo -n "Stopping network auditing daemon on $i: "
			PPP_IFACE=$i /etc/ppp/ip-down.d/argus-server > /dev/null 2>&1|| true
			echo "argus."
		    done
		fi
		if [ "$STARTUP" = "dialup" ]; then
		    invoke-rc.d argus-server stop 2>/dev/null || true
		fi
		if [ "$STARTUP" = "boot" ]; then
		    for i in $PPP_INTERFACES; do
			echo -n "Stopping network auditing daemon on $i: "
			PPP_IFACE=$i /etc/ppp/ip-down.d/argus-server > /dev/null 2>&1 || true
			echo "argus."
		    done
		    
		fi
		
		if [ ! -f "$CONFIG" -o "$OVERWRITE" = "true" ]; then
				cat << __EOF__ > $CONFIG
# This file is automatically generated. 
# Use dpkg-reconfigure argus-server to modify the settings
STARTUP=$STARTUP
__EOF__
		fi

 		;;
	*)
		#
		#	Unknown action - do nothing.
		#
		exit 0
		;;
esac

if [ "$STARTUP" = "dialup" ] || [ "$STARTUP" = "both" ]; then
    for i in $PPP_INTERFACES; do
	echo -n "Starting network auditing daemon on $i: "
	PPP_IFACE=$i /etc/ppp/ip-up.d/argus-server > /dev/null 2>&1 || true
	echo "argus."
    done
fi

if [ "$STARTUP" = "boot" ] || [ "$STARTUP" = "both" ]; then
    invoke-rc.d argus-server start 2>/dev/null || true
fi

#DEBHELPER#

exit 0