summaryrefslogtreecommitdiffstats
path: root/debian/iperf3.config
blob: 3673940ea6951c28e77e32d1f292d6520e4505bf (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
#!/bin/sh

set -e

DEFAULT_FILE="/etc/default/iperf3"

do_default() {
	cat <<-EOF > $DEFAULT_FILE
	#
	# This file is not used if systemd is being used
	# you should run 'dpkg-reconfigure iperf3' instead of editing this file
	# set START_DAEMON="yes" to start iperf3 as a daemon
	#
	START_DAEMON="$1"
	EOF
}

do_initrc() {
	if [ "$1" = "enable" ]; then action="defaults"; else action="remove"; fi
	update-rc.d iperf3 $action || true
}
do_systemd() {
	action="$1"
	DPKG_MAINTSCRIPT_PACKAGE=iperf3 deb-systemd-helper unmask 'iperf3.service' >/dev/null || true
	DPKG_MAINTSCRIPT_PACKAGE=iperf3 deb-systemd-helper $action 'iperf3.service' >/dev/null || true
}

. /usr/share/debconf/confmodule

# fetch data from debconf if any
db_get iperf3/start_daemon
if [ "$RET" = 'true' ] ; then
	db_set iperf3/start_daemon true
else
	db_set iperf3/start_daemon false
fi

if [ "$TERM" ]; then
	db_input high iperf3/start_daemon || true
	db_go || true
fi

# fetch data from debconf if any
db_get iperf3/start_daemon
if [ "$RET" = 'true' ] ; then
	do_default yes
	do_systemd reenable
	do_initrc enable
	if [ -d /run/systemd/system ]; then
		deb-systemd-invoke start 'iperf3.service' || true
	else
		invoke-rc.d iperf3 start || true
	fi
else
	do_default no
	do_systemd disable
	do_initrc disable
	if [ -d /run/systemd/system ]; then
		deb-systemd-invoke stop 'iperf3.service' || true
	else
		invoke-rc.d iperf3 stop || true
	fi
fi
db_stop || true

exit 0