File: postinst

package info (click to toggle)
ntlmaps 0.9.9-2sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 424 kB
  • ctags: 219
  • sloc: python: 2,525; sh: 138; makefile: 39
file content (103 lines) | stat: -rw-r--r-- 3,272 bytes parent folder | download
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
#!/bin/sh -e

. /usr/share/debconf/confmodule

# write selected values into config file
CONFIG_FILE=/etc/ntlmaps/server.cfg
cp -a -f $CONFIG_FILE $CONFIG_FILE.tmp

LISTENPORT_ENTRY=LISTEN_PORT
PARENTPROXY_ENTRY=PARENT_PROXY
PARENTPROXYPORT_ENTRY=PARENT_PROXY_PORT
NTDOMAIN_ENTRY=NT_DOMAIN
NTUSER_ENTRY=USER
NTPASSWD_ENTRY=PASSWORD



LISTENPORT=5865
db_get ntlmaps/listen_port
LISTENPORT="$RET"
# insert the entry, if it is missing (which it ought not to be)
grep -Eq "^[[:blank:]]*$LISTENPORT_ENTRY:" $CONFIG_FILE || \
    echo "$LISTENPORT_ENTRY: $LISTENPORT" >> $CONFIG_FILE 

PARENTPROXY=your_parentproxy
db_get ntlmaps/parent_proxy
PARENTPROXY="$RET"
# insert the entry, if it is missing (which it ought not to be)
grep -Eq "^[[:blank:]]*$PARENTPROXY_ENTRY:" $CONFIG_FILE || \
    echo "$PARENTPROXY_ENTRY: $PARENTPROXY" >> $CONFIG_FILE 

PARENTPROXYPORT=8080
db_get ntlmaps/parent_proxy_port
PARENTPROXYPORT="$RET"
# insert the entry, if it is missing (which it ought not to be)
grep -Eq "^[[:blank:]]*$PARENTPROXYPORT_ENTRY:" $CONFIG_FILE || \
    echo "$PARENTPROXYPORT_ENTRY: $PARENTPROXYPORT" >> $CONFIG_FILE 

NTDOMAIN=your_domain
db_get ntlmaps/nt_domain
NTDOMAIN="$RET"
# insert the entry, if it is missing (which it ought not to be)
grep -Eq "^[[:blank:]]*$NTDOMAIN_ENTRY:" $CONFIG_FILE || \
    echo "$NTDOMAIN_ENTRY: $NTDOMAIN" >> $CONFIG_FILE 

NTUSER=username_to_use
db_get ntlmaps/username
NTUSER="$RET"
# insert the entry, if it is missing (which it ought not to be)
grep -Eq "^[[:blank:]]*$NTUSER_ENTRY:" $CONFIG_FILE || \
    echo "$NTUSER_ENTRY: $NTUSER" >> $CONFIG_FILE 

# update to the new values
sed -e "s/^[[:blank:]]*$LISTENPORT_ENTRY:.*/$LISTENPORT_ENTRY: $LISTENPORT/" \
    -e "s/^[[:blank:]]*$PARENTPROXY_ENTRY:.*/$PARENTPROXY_ENTRY: $PARENTPROXY/" \
    -e "s/^[[:blank:]]*$PARENTPROXYPORT_ENTRY:.*/$PARENTPROXYPORT_ENTRY: $PARENTPROXYPORT/" \
    -e "s/^[[:blank:]]*$NTDOMAIN_ENTRY:.*/$NTDOMAIN_ENTRY: $NTDOMAIN/" \
    -e "s/^[[:blank:]]*$NTUSER_ENTRY:.*/$NTUSER_ENTRY: $NTUSER/" \
    < $CONFIG_FILE > $CONFIG_FILE.tmp

mv -f $CONFIG_FILE.tmp $CONFIG_FILE


# to help improve security, treat the password separately.
# The administrator may have chosen not to set it using debconf,
# by leaving it blank.

NTPASSWD=your_nt_password
db_get ntlmaps/password
NTPASSWD="$RET"
# insert the entry, if it is missing (which it ought not to be)
grep -Eq "^[[:blank:]]*$NTPASSWD_ENTRY:" $CONFIG_FILE || \
    echo "$NTPASSWD_ENTRY: $NTPASSWD" >> $CONFIG_FILE 

# only process the passwork if it is not empty
if [ "$NTPASSWD" ]; then
    # remove the password from the deconf database
    db_set ntlmaps/password "password written to config file"

    # copy config file here in order to preserve permissions when actually
    # building the tmp file in the sed step
    cp -a -f $CONFIG_FILE $CONFIG_FILE.tmp

    sed -e "s/^[[:blank:]]*$NTPASSWD_ENTRY:.*/$NTPASSWD_ENTRY: $NTPASSWD/" \
	< $CONFIG_FILE > $CONFIG_FILE.tmp
    mv -f $CONFIG_FILE.tmp $CONFIG_FILE

fi

# extra safety check: ensure passwords in config file cannot be read by anyone
chmod o-r $CONFIG_FILE



# must indicate we are done with debconf, or the script will hang when the
# server is started below (DEBHELPER section, via dh_installinit).
db_stop


#DEBHELPER#

exit 0