f299168179dcb122d90f9548a240bb2ce7e7d4ab
[openafs.git] / src / packaging / Debian / openafs-client.postinst
1 #! /bin/sh
2
3 set -e
4
5 if [ "$1" = configure ] || [ "$1" = reconfigure ] ; then
6     update-alternatives --install /usr/bin/pagsh pagsh \
7         /usr/bin/pagsh.openafs 100  \
8         --slave /usr/share/man/man1/pagsh.1.gz pagsh.1.gz \
9         /usr/share/man/man1/pagsh.openafs.1.gz
10     update-alternatives --install /usr/bin/klog klog \
11         /usr/bin/klog.afs 10 \
12         --slave /usr/share/man/man1/klog.1.gz klog.1.gz \
13         /usr/share/man/man1/klog.afs.1.gz
14
15     test -d /afs || mkdir /afs
16
17     . /usr/share/debconf/confmodule
18     db_version 2.0
19
20     db_get openafs-client/thiscell
21     THISCELL="$RET"
22     if [ -n "$THISCELL" ] ; then
23         echo "$THISCELL" > /etc/openafs/ThisCell
24     fi
25
26     if [ ! -f /etc/openafs/CellServDB ] ; then
27         cp /usr/share/openafs/CellServDB /etc/openafs
28     fi
29
30     # If ThisCell is not in CellServDB, we have to prompt the user for the
31     # VLDB servers.  Unfortunately, we can't do this in config because we
32     # need the CellServDB file, which is part of the package.
33     #
34     # If the user is using afsdb for cell location, don't worry about
35     # prompting them for cells for their local system.
36     db_get openafs-client/afsdb
37     afsdb="$RET"
38     if grep -q -F "$THISCELL" /etc/openafs/CellServDB \
39            && [ "x$THISCELL" != "x" ] ; then
40         :
41     elif [ x"$afsdb" != xtrue ] ; then
42         db_input critical openafs-client/cell-info || true
43         db_input high openafs-client/run-client || true
44         db_go
45         db_get openafs-client/cell-info
46         if [ "x$RET" != "x" ] ; then
47             echo ">$THISCELL" > /etc/openafs/CellServDB.new
48             perl -MSocket -e 'foreach (@ARGV) {' \
49                 -e '@a=gethostbyname($_) and ' \
50                 -e 'printf("%s\t\t# %s\n",inet_ntoa($a[4]),$a[0]) }' $RET \
51                     >>/etc/openafs/CellServDB.new
52             if [ `wc -l </etc/openafs/CellServDB.new` -eq 1 ] ; then
53                 echo None of the hostnames resolved to an address 2>&1
54                 db_reset openafs-client/cell-info || true
55                 rm /etc/openafs/CellServDB.new
56             else
57                 cat /etc/openafs/CellServDB.new /etc/openafs/CellServDB \
58                     > /etc/openafs/CellServDB.tmp
59                 mv /etc/openafs/CellServDB.tmp /etc/openafs/CellServDB
60                 rm /etc/openafs/CellServDB.new
61             fi
62         fi
63     fi
64                     
65     db_get openafs-client/cachesize
66     echo /afs:/var/cache/openafs:$RET >/etc/openafs/cacheinfo
67
68     echo <<'EOF' > /etc/openafs/afs.conf.client
69 # This file is managed by debconf.  You may change the parameters set below,
70 # but any additional lines or comments will be lost when the package is
71 # upgraded or reconfigured.  Local modifications other than setting the
72 # following parameters should be made in /etc/openafs/afs.conf instead.
73
74 EOF
75
76     db_get openafs-client/run-client
77     echo AFS_CLIENT="$RET" > /etc/openafs/afs.conf.client
78     echo AFS_AFSDB="$afsdb" >> /etc/openafs/afs.conf.client
79     db_get openafs-client/crypt
80     echo AFS_CRYPT="$RET" >> /etc/openafs/afs.conf.client
81     db_get openafs-client/dynroot
82     echo AFS_DYNROOT="$RET" >> /etc/openafs/afs.conf.client
83     db_get openafs-client/fakestat
84     echo AFS_FAKESTAT="$RET" >> /etc/openafs/afs.conf.client
85 fi
86
87 #DEBHELPER#
88
89 exit 0