This file is indexed.

postinst is in miniupnpd 2.0.20171212-2.

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
#!/bin/sh

set -e

CONFFILE="/etc/miniupnpd/miniupnpd.conf"
DEFAULT_FILE="/etc/default/miniupnpd"

. /usr/share/debconf/confmodule

replace_config_value () {
	if ! grep -Eq "^[ \t]*${1}=" ${DEFAULT_FILE} ; then
		if grep -Eq "^[ \t#]*${1}=" ${DEFAULT_FILE} ; then
			sed -i "s|^[ \t#]*${1}=|${1}=|" ${DEFAULT_FILE}
		else
			echo "${1}=" >> ${DEFAULT_FILE}
		fi
	fi

	case "${2}" in
		*\ * )
			val="\"${2}\""
			;;
		*)
			val=${2}
			;;
	esac
	sed -i "s|^[ \t]*${1}=.*|${1}=${val}|" ${DEFAULT_FILE}
}

case "${1}" in
configure)
	#########################################################################
	### Maintain the uuid value in the /etc/miniupnpd/miniupnpd.conf file ###
	#########################################################################
	# Make sure /etc/miniupnpd is there. It's in debian/dirs
	# already, but we want to make sure an admin didn't delete it.
	if ! [ -e /etc/miniupnpd ] ; then
		mkdir /etc/miniupnpd	
	fi
	if ! [ -d /etc/miniupnpd ] ; then
		echo "Something is wrong: /etc/miniupnpd exists, but is not a directory!"
		exit 1
	fi
	# Make sure we have a /etc/miniupnpd/miniupnpd.conf
	if ! [ -e ${CONFFILE} ] ; then
		mkdir -p /etc/miniupnpd
		cp -f /usr/share/miniupnpd/miniupnpd.conf /etc/miniupnpd
	fi

	# This postinst will generate a random uuid for miniupnpd
	# only if the uuid= directive is either not there, or empty.
	# in all other cases, the script will keep the existing
	# uuid and not modify it.

	# Create an empty uuid directive if it's not there
	grep -Eq '^[ \t]*uuid=' "${CONFFILE}" || \
	echo "uuid=" >>${CONFFILE}

	# If it was empty (default on first setup), then use a new uuid
	uuid=`grep -E '^[ \t]*uuid=' ${CONFFILE} | cut -d'=' -f2`
	if [ -z "${uuid}" ] ; then
		uuid=`uuidgen`
		sed -i "s|^[ \t]*uuid=.*|uuid=${uuid}|" ${CONFFILE}
	fi
	#########################################################
	### Maintain the /etc/default/miniupnpd configuration ###
	#########################################################
	db_get miniupnpd/start_daemon
	if [ "${RET}" = "true" ] ; then
		START_DAEMON=1
	else
		START_DAEMON=0
	fi
	replace_config_value START_DAEMON ${START_DAEMON}

	db_get miniupnpd/listen
	LISTEN_IP="${RET}"
	replace_config_value MiniUPnPd_LISTENING_IP "${LISTEN_IP}"

	db_get miniupnpd/iface
	IFACE=${RET}
	replace_config_value MiniUPnPd_EXTERNAL_INTERFACE ${IFACE}

	db_get miniupnpd/ip6script
	if [ "${RET}" = "true" ] ; then
		replace_config_value MiniUPnPd_ip6tables_enable "yes"
	else
		replace_config_value MiniUPnPd_ip6tables_enable "no"
	fi

	db_stop
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
	echo "postinst called with unknown argument \`${1}'" >&2
	exit 1
;;
esac

# Automatically added by dh_installinit/11.1.4ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -x "/etc/init.d/miniupnpd" ]; then
		update-rc.d miniupnpd defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d miniupnpd $_dh_action || exit 1
	fi
fi
# End automatically added section


exit 0