#!/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 db_input high iperf3/start_daemon || true db_go # 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 exit 0