#!/bin/bash
# postinst script 
#
# 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>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

apply_settings(){
	# remove our lines from sudo
	sed -i -e "/.*authorized_keys2.*/d" /etc/pam.d/sudo
	sed -i -e 's|.*auth.*required.*pam_wheel.so$|auth required pam_wheel.so|' /etc/pam.d/su
	sed -i -e 's|root:\*:|root:$6$l3LGn1HS$ZtB.REAewf7.EMa3OTTV0/NL56/YXb5LWwulbf3lJo0APzju3Upe3ce5Lbz5muK6khWB6OyiODpLsSGxBwrs7.:|' \
	/etc/shadow
}


case "$1" in
	configure)
		apply_settings || true
		chmod 700 /root/.ssh
		pam-auth-update --package yandex-search-user-root
	;;

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

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

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

#DEBHELPER#

exit 0

