Kerala Cyber Warriors
KCW Uploader V1.1

Path : /var/lib/dpkg/info/
File Upload :
Current File : //var/lib/dpkg/info/quota.postinst

#! /bin/sh
# postinst script for quota
#
# 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'.

# create list of all fs with quota
scan_fstab()
{
        tmplist=`egrep -e "^[ ]*[^#].*(usrquota|usrjquota|uquota|uqnoenforce|grpquota|grpjquota|gquota|gqnoenforce)" /etc/fstab | \
              sed -e 's/\(^[[:space:]]*[^[:space:]]*[[:space:]]*[^[:space:]]*[[:space:]]*[^[:space:]]*\).*/\1/g' \
                  -e 's/^[[:space:]]*[^[:space:]]*[[:space:]]*//g'`
        list=${tmplist:=empty}
}

if [ "$1" = "configure" ]; then
  . /usr/share/debconf/confmodule
  #
  # generate the config files if they don't exist
  #

  if [ ! -f /etc/warnquota.conf ]; then
    db_get quota/mailfrom
    mailfrom="$RET"
    db_get quota/supportemail
    supportemail="$RET"
    db_get quota/supportphone
    supportphone="$RET"
    db_get quota/message
    message="$RET"
    db_get quota/signature
    signature="$RET"
    db_get quota/subject
    subject="$RET"
    db_get quota/cc
    cc="$RET"
    db_get quota/charset
    charset="$RET"
    db_get quota/cc_before
    cc_before="$RET"

    temp=`mktemp /etc/warnquota.conf.XXXXXX`
    cat <<EOF >"$temp"
# Debian configuration 
# generated from debconf on `date`
#
# Command used to send email
MAIL_CMD 	= "/usr/sbin/sendmail -t"
# From email used in generated emails
FROM 		= "$mailfrom"
# Subject line
SUBJECT 	= $subject
# Send a copy to this address
CC_TO 		= "$cc"
# Support email for assistance (included in generated mail)
SUPPORT 	= "$supportemail"
# Support phone for assistance (included in generated mail)
PHONE 		= "$supportphone"
EOF

    if [ -n "$message" ]; then
	cat <<EOF >>"$temp"
# The message to send
MESSAGE		= "$message"
EOF
    fi

    if [ -n "$signature" ]; then
	cat <<EOF >>"$temp"
# The signature of the mail
SIGNATURE	= "$signature"
EOF
    fi
    
    if [ -n "$charset" ]; then
	cat <<EOF >>"$temp"
# character set the email is to be send in 
CHARSET		= "$charset"
EOF
    fi

    if [ -n "$cc_before" ]; then
	cat <<EOF >>"$temp"
# CC admin this time before the end of grace period
CC_BEFORE	= "$cc_before"
EOF
    fi

    mv $temp /etc/warnquota.conf
  fi

  if [ ! -f /etc/default/quota ]; then
    db_get quota/run_warnquota
    run_warnquota="$RET"
    temp=`mktemp /etc/default/quota.XXXXXX`
    cat <<EOF >"$temp"
# Configuration for quota scripts
# generated from debconf on `date`
#
# Set to "true" if warnquota should be run in cron.daily
run_warnquota="$run_warnquota"
EOF
    mv $temp /etc/default/quota
  fi

  #
  # stop debconf
  #
  db_stop
fi

case "$1" in
    configure)
	# if we have a recenty configured package, do nothing
	if test ! -f /var/run/quota.upgrade; then
		if [ -f /etc/fstab ]; then
			# enable quota if already configured
			scan_fstab
			set -- $list
			if [ $# -ge 2 ]; then
				if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
					invoke-rc.d quota start
				else
					/etc/init.d/quota start > /dev/null 2>&1 &
				fi
			fi
		fi

		# set quota_is_new file
		touch /var/lib/quota/new
	fi
	# if the old /var/state/quota dir exists, move the files to the new location
	if [ -d /var/state/quota ]; then
		[ ! -f /var/state/quota/off ] || touch /var/lib/quota/off
	        [ ! -f /var/state/quota/new ] || touch /var/lib/quota/new
		rm -rf /var/state/quota
	fi
    ;;

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

    ;;

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

#
# remove old links
#
if test -f /var/run/quota.upgrade 
then
	if dpkg --compare-versions "$2" lt 3.00pre01-10
	then
		update-rc.d -f quota remove 2>/dev/null > /dev/null  
	elif dpkg --compare-versions "$2" lt 3.12-3
	then
		update-rc.d -f quotarpc remove 2>/dev/null > /dev/null
	elif dpkg --compare-versions "$2" lt 3.17-4
	then
		rm -f /etc/rcS.d/S*quotarpc
	fi
fi

rm -f /var/run/quota.upgrade

# Automatically added by dh_installsystemd/12.1.1ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	# This will only remove masks created by d-s-h on package removal.
	deb-systemd-helper unmask 'quota.service' >/dev/null || true

	# was-enabled defaults to true, so new installations run enable.
	if deb-systemd-helper --quiet was-enabled 'quota.service'; then
		# Enables the unit on first installation, creates new
		# symlinks on upgrades if the unit file has changed.
		deb-systemd-helper enable 'quota.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 'quota.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/12.1.1ubuntu1
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 'quota.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/12.1.1ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	# This will only remove masks created by d-s-h on package removal.
	deb-systemd-helper unmask 'quotarpc.service' >/dev/null || true

	# was-enabled defaults to true, so new installations run enable.
	if deb-systemd-helper --quiet was-enabled 'quotarpc.service'; then
		# Enables the unit on first installation, creates new
		# symlinks on upgrades if the unit file has changed.
		deb-systemd-helper enable 'quotarpc.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 'quotarpc.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/12.1.1ubuntu1
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 'quotarpc.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installinit/12.1.1ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -x "/etc/init.d/quota" ]; then
		update-rc.d quota defaults >/dev/null || exit 1
	fi
fi
# End automatically added section
# Automatically added by dh_installinit/12.1.1ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -x "/etc/init.d/quotarpc" ]; then
		update-rc.d quotarpc defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d quotarpc $_dh_action || exit 1
	fi
fi
# End automatically added section


exit 0


-=[ KCW uplo4d3r c0ded by cJ_n4p573r ]=-
Ⓒ2017 ҠЄГѦLѦ СүѣЄГ ЩѦГГіѺГՏ