97c63f4912988a89e836ea446916d24f71700381
[citadel.git] / citadel / debian / citadel-client.postinst
1 #! /bin/sh
2 # postinst.skeleton
3 # Skeleton maintainer script showing all the possible cases.
4 # Written by Charles Briscoe-Smith, March-June 1998.  Public Domain.
5
6 # Abort if any command returns an error value
7 set -e
8
9 # This script is called as the last step of the installation of the
10 # package.  All the package's files are in place, dpkg has already done
11 # its automatic conffile handling, and all the packages we depend of
12 # are already fully installed and configured.
13
14 case "$1" in
15   configure)
16     # Configure this package.  If the package must prompt the user for
17     # information, do it here.
18     if ! getent group citadel >/dev/null; then 
19                 groupadd citadel
20         fi
21         if ! getent passwd citadel >/dev/null; then 
22                 adduser --system --ingroup citadel --home /var/lib/citadel \
23                         --gecos "Citadel system user" --shell /bin/sh \
24                         --disabled-password citadel
25         fi
26         mkdir -p /etc/citadel
27         chown citadel:citadel /etc/citadel
28         gunzip -c  /usr/share/doc/citadel-client/examples/citadel.rc.gz> /tmp/citadel.rc
29         ucf /tmp/citadel.rc /etc/citadel/citadel.rc
30         rm -f /tmp/citadel.rc
31
32     ### We could also do this on the fly. The following is from Tore
33     ### Anderson:
34     
35     #. /usr/share/debconf/confmodule
36
37     ### find out what the user answered.
38     #  db_get foo/run_on_boot
39     #  run_on_boot=$RET
40     #  db_stop
41
42     ### safely create a temporary file to generate our suggested
43     ### configuration file.
44     #    tempfile=`tempfile`
45     #    cat << _eof > $tempfile
46     ### Configuration file for Foo.
47
48     ### this was answered by you, the user in a debconf dialogue
49     #  RUNONBOOT=$run_on_boot
50
51     ### this was not, as it has a sane default value.
52     #  COLOUROFSKY=blue
53
54     #_eof
55
56     ### Note that some versions of debconf do not release stdin, so
57     ### the following invocation of ucf may not work, since the stdin
58     ### is never coneected to ucfr.
59
60     ### now, invoke ucf, which will take care of the rest, and ask
61     ### the user if he wants to update his file, if it is modified.
62     #ucf $tempfile /etc/foo.conf
63
64     ### done! now we'll just clear up our cruft.
65     #rm -f $tempfile
66
67
68     #### There are three sub-cases:
69     ###if test "${2+set}" != set; then
70     ###  # We're being installed by an ancient dpkg which doesn't remember
71     ###  # which version was most recently configured, or even whether
72     ###  # there is a most recently configured version.
73     ###  :
74         ###
75     ###elif test -z "$2" -o "$2" = "<unknown>"; then
76     ###  # The package has not ever been configured on this system, or was
77     ###  # purged since it was last configured.
78     ###  :
79         ###
80     ###else
81     ###  # Version $2 is the most recently configured version of this
82     ###  # package.
83     ###  :
84         ###
85     ###fi 
86         ;;
87   abort-upgrade)
88     # Back out of an attempt to upgrade this package FROM THIS VERSION
89     # to version $2.  Undo the effects of "prerm upgrade $2".
90     :
91
92     ;;
93   abort-remove)
94     ###if test "$2" != in-favour; then
95     ###  echo "$0: undocumented call to \`postinst $*'" 1>&2
96     ###  exit 0
97     ###fi
98     #### Back out of an attempt to remove this package, which was due to
99     #### a conflict with package $3 (version $4).  Undo the effects of
100     #### "prerm remove in-favour $3 $4".
101     ###:
102
103     ;;
104   abort-deconfigure)
105     ###if test "$2" != in-favour -o "$5" != removing; then
106     ###  echo "$0: undocumented call to \`postinst $*'" 1>&2
107     ###  exit 0
108     ###fi
109     #### Back out of an attempt to deconfigure this package, which was
110     #### due to package $6 (version $7) which we depend on being removed
111     #### to make way for package $3 (version $4).  Undo the effects of
112     #### "prerm deconfigure in-favour $3 $4 removing $6 $7".
113     ###:
114
115     ;;
116   *) echo "$0: didn't understand being called with \`$1'" 1>&2
117      exit 0;;
118 esac
119
120 exit 0