This file is indexed.

postinst is in tftpd-hpa 5.2+20150808-1ubuntu3.

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

set -e

. /usr/share/debconf/confmodule

CONFFILE="/etc/default/tftpd-hpa"

case "${1}" in
	configure)
		db_get tftpd-hpa/username
		TFTP_USERNAME="${RET:-tftp}"

		db_get tftpd-hpa/directory
		TFTP_DIRECTORY="${RET:-/srv/tftp}"

		db_get tftpd-hpa/address
		TFTP_ADDRESS="${RET:-:69}"

		db_get tftpd-hpa/options
		TFTP_OPTIONS="${RET}" # is ok when empty

		db_stop

		if [ ! -e "${CONFFILE}" ]
		then

cat > "${CONFFILE}" << EOF
# /etc/default/tftpd-hpa

TFTP_USERNAME="${TFTP_USERNAME}"
TFTP_DIRECTORY="${TFTP_DIRECTORY}"
TFTP_ADDRESS="${TFTP_ADDRESS}"
TFTP_OPTIONS="${TFTP_OPTIONS} -s"
EOF
		fi

		cp -a -f "${CONFFILE}" "${CONFFILE}.tmp"

		# If the admin deleted or commented some variables but then set
		# them via debconf, (re-)add them to the config file.

		test -z "${TFTP_USERNAME}" || \
		grep -Eq '^ *TFTP_USERNAME=' "${CONFFILE}" || \
		echo "TFTP_USERNAME=" >> "${CONFFILE}"

		test -z "${TFTP_DIRECTORY}" || \
		grep -Eq '^ *TFTP_DIRECTORY=' "${CONFFILE}" || \
		echo "TFTP_DIRECTORY=" >> "${CONFFILE}"

		test -z "${TFTP_ADDRESS}" || \
		grep -Eq '^ *TFTP_ADDRESS=' "${CONFFILE}" || \
		echo "TFTP_ADDRESS=" >> "${CONFFILE}"

		test -z "${TFTP_OPTIONS}" || \
		grep -Eq '^ *TFTP_OPTIONS=' "${CONFFILE}" || \
		echo "TFTP_OPTIONS=" >> "${CONFFILE}"

		sed -e "s|^ *TFTP_USERNAME=.*|TFTP_USERNAME=\"${TFTP_USERNAME}\"|" \
		    -e "s|^ *TFTP_DIRECTORY=.*|TFTP_DIRECTORY=\"${TFTP_DIRECTORY}\"|" \
		    -e "s|^ *TFTP_ADDRESS=.*|TFTP_ADDRESS=\"${TFTP_ADDRESS}\"|" \
		    -e "s|^ *TFTP_OPTIONS=.*|TFTP_OPTIONS=\"${TFTP_OPTIONS}\"|" \
		< "${CONFFILE}" > "${CONFFILE}.tmp"

		mv -f "${CONFFILE}.tmp" "${CONFFILE}"

		if ! getent passwd "${TFTP_USERNAME}" > /dev/null 2>&1
		then
			adduser --system --home $(echo ${TFTP_DIRECTORY} | awk '{ print $1 }') --no-create-home --quiet --gecos 'tftp daemon' --group ${TFTP_USERNAME}
		else
			echo "tftpd user (${TFTP_USERNAME}) already exists, doing nothing."
		fi

		for _DIRECTORY in ${TFTP_DIRECTORY}
		do
			if [ ! -d "${_DIRECTORY}" ]
			then
				mkdir -p "${_DIRECTORY}"
				chown root:nogroup ${_DIRECTORY} -R
			else
				echo
				echo "tftpd-hpa directory (${_DIRECTORY}) already exists, doing nothing."
			fi
		done
		;;

	abort-upgrade|abort-remove|abort-deconfigure)

		;;

	*)
		echo "postinst called with unknown argument \`${1}'" >&2
		exit 1
		;;
esac

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


exit 0