This file is indexed.

postinst is in bandwidthd 2.0.1+cvs20090917-10ubuntu1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh

set -e

if [ "$BANDWIDTHD_PACKAGE_DEBUG" != "" ]; then
	echo "bandwidthd.postinst: $*"
	set -x
fi

# Always source debconf library in postinst.
. /usr/share/debconf/confmodule

# -------------------------------------------------------------
# Create bandwidthd.conf based on debconf data, and install it.
# -------------------------------------------------------------

if [ "$1" = "configure" ]; then

db_get bandwidthd/dev || true
DEV=$RET

db_get bandwidthd/subnet || true
SUBNETS=$RET
# ATTENTION! $SUBNETS needs to be parsed and split.
# Example contents: 192.168.1.0/24, 172.20.0.0 255.255.0.0, 10.0.0.0/8

db_get bandwidthd/outputcdf || true
OUTPUTCDF=$RET

db_get bandwidthd/recovercdf || true
RECOVERCDF=$RET

db_get bandwidthd/metarefresh || true
if [ "$RET" = "" ]; then
	RET=150
fi
METAREFRESH=$RET

db_get bandwidthd/promisc || true
PROMISC=$RET


if [ "$BANDWIDTHD_PACKAGE_DEBUG" != "" ]; then
	echo "This is the bandwidthd postinst script reporting debconf settings:"
	echo "dev: $DEV"
	echo "subnets: $SUBNETS"
	echo "outputcdf: $OUTPUTCDF"
	echo "recovercdf: $RECOVERCDF"
	echo "metarefresh: $METAREFRESH"
	echo "promisc: $PROMISC"
fi

# parse a bandwidthd.conf template and insert dev, subnet and
# recover_cdf rules, then use ucf to install config file.

TMPDIR=$(mktemp -d)
TMPFILE=$TMPDIR/bandwidthd.conf

cp /usr/share/bandwidthd/bandwidthd.conf.template $TMPFILE
chmod 640 $TMPFILE

RULE='s%^#DEBCONF_DEVS#$%dev "'$DEV'"%'
sed -e "$RULE" < $TMPFILE > $TMPFILE.new
mv $TMPFILE.new $TMPFILE

PARSED_SUBNETS=$(echo $SUBNETS | sed -e 's/, */:/g')
#PARSED_SUBNETS=$(echo $PARSED_SUBNETS | sed -e 's/^/subnet /')
OLDIFS=$IFS
IFS=":"
for subnet in $PARSED_SUBNETS ; do
	# CIDR and dotted-quad subnets have different syntax:
	# subnet 1.2.3.4/24
	# subnet 4.3.2.1 255.255.255.0
	subnet=$(echo $subnet | sed -e 's#/\(.*\..*\)# \1#')
	RULE='s%^#DEBCONF_SUBNETS#$%subnet '$subnet'\
#DEBCONF_SUBNETS#%'
	sed -e "$RULE" < $TMPFILE > $TMPFILE.new
	mv $TMPFILE.new $TMPFILE
done
RULE='s%^#DEBCONF_SUBNETS#$%%'
sed -e "$RULE" < $TMPFILE > $TMPFILE.new
mv $TMPFILE.new $TMPFILE
IFS=$OLDIFS

RULE='s%^#DEBCONF_OUTPUTCDF#$%output_cdf '$OUTPUTCDF'%'
sed -e "$RULE" < $TMPFILE > $TMPFILE.new
mv $TMPFILE.new $TMPFILE


RULE='s%^#DEBCONF_RECOVERCDF#$%recover_cdf '$RECOVERCDF'%'
sed -e "$RULE" < $TMPFILE > $TMPFILE.new
mv $TMPFILE.new $TMPFILE

RULE='s%^#DEBCONF_METAREFRESH#$%meta_refresh '$METAREFRESH'%'
sed -e "$RULE" < $TMPFILE > $TMPFILE.new
mv $TMPFILE.new $TMPFILE

RULE='s%^#DEBCONF_PROMISC#$%promiscuous '$PROMISC'%'
sed -e "$RULE" < $TMPFILE > $TMPFILE.new
mv $TMPFILE.new $TMPFILE

# Install new configuration...
chmod 640 $TMPFILE
ucf --debconf-ok $TMPFILE /etc/bandwidthd/bandwidthd.conf
chmod 640 /etc/bandwidthd/bandwidthd.conf

# clean up
rm -rf $TMPDIR

# stop debconf
db_stop


fi # "$1" = "configure"

# ----------------------------------------------------------------------

# move apache configuration file to new location for apache 2.4
dpkg-maintscript-helper mv_conffile \
	/etc/apache2/conf.d/bandwidthd /etc/apache2/conf-available/bandwidthd.conf 2.0.1+cvs20090917-6~ bandwidthd -- "$@"

# From http://wiki.debian.org/Apache/PackagingFor24 :
# "In your postinst maintainer script invoke the enconf handler on fresh installations."
if [ -z "$2" ]; then
	if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
		. /usr/share/apache2/apache2-maintscript-helper
		apache2_invoke enconf bandwidthd.conf
	fi
fi

# reload apache2 config for installed /bandwidthd alias.
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
	. /usr/share/apache2/apache2-maintscript-helper
	apache2_reload
fi

# debhelper autoinserted stuff:

# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/bandwidthd" ]; then
		update-rc.d bandwidthd defaults >/dev/null
		invoke-rc.d bandwidthd start || exit $?
	fi
fi
# End automatically added section