Import Debian changes 1.8.5-1
[hcoop/debian/openafs.git] / debian / openafs-client.postinst
1 #! /bin/sh
2
3 set -e
4
5 # Load debconf.
6 . /usr/share/debconf/confmodule
7 db_version 2.0
8
9 # Create the standard AFS mount point if it doesn't exist.
10 test -d /afs || mkdir /afs
11
12 # Configure alternatives for pagsh and klog.
13 update-alternatives --install /usr/bin/pagsh pagsh \
14 /usr/bin/pagsh.openafs 100 \
15 --slave /usr/share/man/man1/pagsh.1.gz pagsh.1.gz \
16 /usr/share/man/man1/pagsh.openafs.1.gz
17
18 # Set the local cell. If ThisCell already exists, the config script will have
19 # set the debconf database parameter accordingly.
20 db_get openafs-client/thiscell
21 THISCELL="$RET"
22 if [ -n "$THISCELL" ] ; then
23 echo "$THISCELL" > /etc/openafs/ThisCell
24 fi
25
26 # On initial installation, or when afsdb is not configured, ensure that we
27 # have a CellServDB file.
28 db_get openafs-client/afsdb
29 afsdb="$RET"
30 if [ "$afsdb" = 'false' ] || { [ "$1" = 'configure' ] && [ -z "$2" ] ; } ; then
31 if [ ! -f /etc/openafs/CellServDB ] ; then
32 cp /usr/share/openafs/CellServDB /etc/openafs
33 fi
34 fi
35
36 # If ThisCell is not in CellServDB and the user is not using afsdb, we want to
37 # prompt the user for the VLDB servers. Unfortunately, we can't do this in
38 # config because we need the CellServDB file, which is part of the package.
39 havecell=
40 if [ -n "$THISCELL" ] ; then
41 if grep -qF "$THISCELL" /etc/openafs/CellServDB 2>/dev/null ; then
42 havecell=true
43 fi
44 fi
45 if [ "$afsdb" = 'false' ] && [ -z "$havecell" ] ; then
46 db_input critical openafs-client/cell-info || true
47 db_input high openafs-client/run-client || true
48 db_go
49 db_get openafs-client/cell-info
50 if [ "x$RET" != "x" ] ; then
51 echo ">$THISCELL" > /etc/openafs/CellServDB.new
52 perl -MSocket -e 'foreach (@ARGV) {' \
53 -e '@a=gethostbyname($_) and ' \
54 -e 'printf("%s\t\t# %s\n",inet_ntoa($a[4]),$a[0]) }' $RET \
55 >>/etc/openafs/CellServDB.new
56 if [ `wc -l </etc/openafs/CellServDB.new` -eq 1 ] ; then
57 echo 'None of the hostnames resolved to an address' 2>&1
58 db_reset openafs-client/cell-info || true
59 rm /etc/openafs/CellServDB.new
60 else
61 cat /etc/openafs/CellServDB.new /etc/openafs/CellServDB \
62 > /etc/openafs/CellServDB.tmp
63 mv /etc/openafs/CellServDB.tmp /etc/openafs/CellServDB
64 rm /etc/openafs/CellServDB.new
65 fi
66 fi
67 fi
68
69 # Our config script will have already taken care of extracting the cache size
70 # from the cacheinfo file and using it as the default for the debconf prompt,
71 # but the mount point and cache directory have no debconf prompts. For those,
72 # we need to get the default from the file.
73 mountpoint=/afs
74 cachedir=/var/cache/openafs
75 if [ -r /etc/openafs/cacheinfo ] ; then
76 IFS=: read mountpoint cachedir cachesize < /etc/openafs/cacheinfo
77 fi
78 db_get openafs-client/cachesize
79 echo "${mountpoint}:${cachedir}:${RET}" > /etc/openafs/cacheinfo
80
81 # Create the /etc/openafs/afs.conf.client configuration file, which stores
82 # most of the debconf results.
83 echo <<'EOF' > /etc/openafs/afs.conf.client
84 # This file is managed by debconf. You may change the parameters set below,
85 # but any additional lines or comments will be lost when the package is
86 # upgraded or reconfigured. Local modifications other than setting the
87 # following parameters should be made in /etc/openafs/afs.conf instead.
88
89 EOF
90 db_get openafs-client/run-client
91 echo AFS_CLIENT="$RET" > /etc/openafs/afs.conf.client
92 echo AFS_AFSDB="$afsdb" >> /etc/openafs/afs.conf.client
93 db_get openafs-client/crypt
94 echo AFS_CRYPT="$RET" >> /etc/openafs/afs.conf.client
95 db_get openafs-client/dynroot
96 echo AFS_DYNROOT="$RET" >> /etc/openafs/afs.conf.client
97 db_get openafs-client/fakestat
98 echo AFS_FAKESTAT="$RET" >> /etc/openafs/afs.conf.client
99
100 # Prepopulate the systemd EnvironmentFile
101 /usr/share/openafs/openafs-client-precheck
102
103 #DEBHELPER#
104
105 exit 0