#!/bin/bash # postinst script for mlat-client-adsbfi # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package NAME=mlat-client-adsbfi CONFIGFILE=/etc/default/$NAME TEMPLATECONFIG=/usr/share/$NAME/config-template SEDSCRIPT=$CONFIGFILE.sed.tmp subvar_raw() { # $1 = db var value # $2 = config var name # if not present in the config file, add it if grep -Eq "^ *$2=" $CONFIGFILE then # Already present true else echo "# $2 added automatically on upgrade" >> $CONFIGFILE echo "$2=" >> $CONFIGFILE fi # add to the sedscript echo "s@^ *$2=.*@$2=\"$1\"@" >>$SEDSCRIPT } subvar() { # $1 = db var name # $2 = config var name db_get $NAME/$1 subvar_raw "$RET" "$2" } subvar_yn() { # $1 = db var name # $2 = config var name db_get $NAME/$1 if [ "$RET" = "true" ]; then subvar_raw "yes" "$2"; else subvar_raw "no" "$2"; fi } case "$1" in configure) . /usr/share/debconf/confmodule # Generate config file, if it doesn't exist. if [ ! -e $CONFIGFILE ]; then tail -n +4 $TEMPLATECONFIG >$CONFIGFILE fi rm -f $SEDSCRIPT subvar_yn start-client START_CLIENT subvar run-as-user RUN_AS_USER subvar server-hostport SERVER_HOSTPORT subvar server-user SERVER_USER subvar input-type INPUT_TYPE subvar input-hostport INPUT_HOSTPORT subvar receiver-lat LAT subvar receiver-lon LON subvar receiver-alt ALT subvar results RESULTS subvar log-file LOGFILE subvar extra-args EXTRA_ARGS cp -a -f $CONFIGFILE $CONFIGFILE.tmp sed -f $SEDSCRIPT < $CONFIGFILE > $CONFIGFILE.tmp mv -f $CONFIGFILE.tmp $CONFIGFILE rm $SEDSCRIPT db_get $NAME/run-as-user RUNAS="$RET" if ! getent passwd "$RUNAS" >/dev/null then adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RUNAS" fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. # Automatically added by dh_python3 if command -v py3compile >/dev/null 2>&1; then py3compile -p mlat-client-adsbfi:amd64 fi if command -v pypy3compile >/dev/null 2>&1; then pypy3compile -p mlat-client-adsbfi:amd64 || true fi # End automatically added section # Automatically added by dh_installinit/13.24.2 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "$DPKG_ROOT" ] && [ -x "/etc/init.d/mlat-client-adsbfi" ]; then update-rc.d mlat-client-adsbfi defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native mlat-client-adsbfi $_dh_action || exit 1 fi fi # End automatically added section if [ "$1" = "configure" ]; then db_stop; fi exit 0