File: postinst

package info (click to toggle)
cpu 1.4.3-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,668 kB
  • sloc: sh: 7,522; ansic: 7,395; makefile: 117
file content (63 lines) | stat: -rw-r--r-- 1,779 bytes parent folder | download | duplicates (2)
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
#! /bin/sh

test $DEBIAN_SCRIPT_DEBUG && set -v -x

set -e

# Source debconf library.
CONFIG=/etc/cpu/cpu.conf


update_var() {
	_field="$1"	_value="$2"
	_record=`printf "%-23s = %s" "$_field" "$_value"`
	sed "s|^$_field.*|$_record|" $CONFIG > $CONFIG.tmp && \
		mv $CONFIG.tmp $CONFIG
}	

escape() {
	# escape sed meta chars and pattern delimiter (|)
	echo "$*" | sed 's|[\|\$\&\.\*\%\^\+\?]|\\&|g'
}	

case "$1" in
    configure)
	. /usr/share/debconf/confmodule
	db_get cpu/do_debconf || true; DO_DEBCONF=$RET
	if [ "$DO_DEBCONF" = "true" ]; then
		db_get cpu/ldap/LDAP_URI || true; LDAP_URI=`escape "$RET"`
		db_get cpu/ldap/BIND_DN || true; BIND_DN=`escape "$RET"`
		db_get cpu/ldap/BIND_PASS || true; BIND_PASS=`escape "$RET"`
		db_get cpu/ldap/USER_BASE || true; USER_BASE=`escape "$RET"`
		db_get cpu/ldap/GROUP_BASE || true; GROUP_BASE=`escape "$RET"`
	fi
	
	# Set the umask to 026 so ucf will create the file with the right mode,
	# but won't override eventual changes by the sysadm
	umask 026
	# this due to debconf not releasing stdin (refer to #193694)
	ucf --debconf-ok /usr/share/cpu/cpu.conf $CONFIG
	
	if [ "$DO_DEBCONF" = "true" ] && [ -f $CONFIG ]; then
		update_var LDAP_URI "$LDAP_URI"
		update_var BIND_DN "$BIND_DN"
		update_var BIND_PASS "$BIND_PASS"
		update_var USER_BASE "$USER_BASE"
		update_var GROUP_BASE "$GROUP_BASE"
	
		if [ -e /var/cache/cracklib/cracklib_dict.pwd ]; then
			sed "s/^#CRACKLIB_DICTIONARY/CRACKLIB_DICTIONARY/" $CONFIG > \
				$CONFIG.tmp && mv $CONFIG.tmp $CONFIG
		else
			sed "s/^CRACKLIB_DICTIONARY/#CRACKLIB_DICTIONARY/" $CONFIG > \
				$CONFIG.tmp && mv $CONFIG.tmp $CONFIG
		fi
	fi	
	db_stop
    ;;
esac

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

#DEBHELPER#