#! /bin/sh # postinst script for yaws # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # 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 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_usrlocal/13.11.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then ( default_mode=0755 default_user=root default_group=root if [ -e /etc/staff-group-for-usr-local ]; then default_mode=02775 default_group=staff fi while read line; do set -- $line dir="$1"; mode="$2"; user="$3"; group="$4" if [ "$mode" = "default" ]; then mode="$default_mode" user="$default_user" group="$default_group" fi if [ ! -e "$dir" ]; then if mkdir "$dir" 2>/dev/null; then if chown "$user":"$group" "$dir" ; then chmod "$mode" "$dir" || true fi fi fi done ) << DATA /usr/local/lib default /usr/local/lib/yaws-appmods default /usr/local/lib/yaws-appmods/ebin default /usr/local/lib/yaws-appmods/include default DATA fi # End automatically added section # Automatically added by dh_installinit/13.11.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -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 --skip-systemd-native yaws $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'yaws.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'yaws.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'yaws.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'yaws.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'yaws.service' >/dev/null || true fi fi # End automatically added section exit 0