This file is indexed.

postinst is in yaws 2.0.4+dfsg-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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#! /bin/sh
# postinst script for yaws
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see /usr/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

case "$1" in
    configure)
	# Create yaws user
	adduser --quiet --system --group --home /var/cache/yaws yaws
	# Moving home directory if it's still in /var/run
	usermod --home /var/cache/yaws --move-home yaws >/dev/null 2>/dev/null

	# Fixing config directory permissions
	for d in yaws yaws/conf.avail yaws/conf.d ; do
	    if ! dpkg-statoverride --list /etc/$d >/dev/null; then
		chown root:yaws /etc/$d
		chmod 750 /etc/$d
	    fi
	done

	# Yaws configs may contain sensitive information (passwords)
	for f in /etc/yaws/yaws.conf /etc/yaws/conf.avail/*.conf ; do
	    if ! dpkg-statoverride --list $f >/dev/null; then
		chown root:yaws $f
		chmod 640 $f
	    fi
	done

	# Create config symlinks
	# Do it only if it's a fresh install or upgrade from version
	# less than 1.66-2 (which is the first version with multiple
	# configs), allowing admin to safely remove it.

	if dpkg --compare-versions "$2" lt "1.66-2" ; then
	    for f in localhost.conf localhost-ssl.conf ; do
		if [ ! -f /etc/yaws/conf.d/$f ] ; then
		    ln -s ../conf.avail/$f /etc/yaws/conf.d/
		fi
	    done
	fi


	# Adding yaws user to the ssl-cert group to use the snakeoil
	# SSL certificate

	if getent group ssl-cert >/dev/null ; then
	    adduser --quiet yaws ssl-cert
	fi

	# Create the homedir if it doesn't exist for some reason
	mkdir -p /var/cache/yaws

	# Only user yaws and root are allowed to create yaws control files
	chown -R yaws:yaws /var/cache/yaws
	chmod 750 /var/cache/yaws

	install -o yaws -g adm  -m 750 -d /var/log/yaws

	# Finish moving /usr/lib/yaws/custom/* to /usr/local/lib/yaws-appmods/
	dira=/usr/lib/yaws-custom.dpkg-backup
	dirb=/usr/local/lib/yaws-appmods
	if [ -d $dira ] ; then
	    # If the /usr/lib/yaws/custom.dpkg-backup directory exists then we
	    # are upgrading from an older version and have to move it to
	    # /usr/local/lib/yaws-appmods

	    echo "Relocating /usr/lib/yaws/custom into $dirb..."

	    (
		while read line; do
		    set -- $line
		    dir="$1"; mode="$2"; user="$3"; group="$4"
		    if [ ! -e "$dir" ]; then
			if mkdir "$dir" 2>/dev/null; then
			    chown "$user":"$group" "$dir"
			    chmod "$mode" "$dir"
			fi
		    fi
		done
	    ) << DATA
/usr/local/lib 2775 root staff
/usr/local/lib/yaws-appmods 2775 root staff
DATA
	    for f in $(ls -A $dira) ; do
		mv -f $dira/$f $dirb/
	    done
	    rmdir $dira
	fi
    ;;

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

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/yaws" ]; then
		update-rc.d yaws defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d yaws $_dh_action || exit $?
	fi
fi
# End automatically added section
# Automatically added by dh_usrlocal
if [ "$1" = configure ]; then
(
	while read line; do
		set -- $line
		dir="$1"; mode="$2"; user="$3"; group="$4"
		if [ ! -e "$dir" ]; then
			if mkdir "$dir" 2>/dev/null; then
				chown "$user":"$group" "$dir"
				chmod "$mode" "$dir"
			fi
		fi
	done
) << DATA
/usr/local/lib 2775 root staff
/usr/local/lib/yaws-appmods 2775 root staff
/usr/local/lib/yaws-appmods/ebin 2775 root staff
/usr/local/lib/yaws-appmods/include 2775 root staff
DATA
fi
# End automatically added section


exit 0