* Added debian build directory (submitted by W. Goesgens)
[citadel.git] / webcit / debian / citadel-webcit.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 . /usr/share/debconf/confmodule
9
10 # This script is called as the last step of the installation of the
11 # package.  All the package's files are in place, dpkg has already done
12 # its automatic conffile handling, and all the packages we depend of
13 # are already fully installed and configured.
14
15 # The following idempotent stuff doesn't generally need protecting
16 # against being run in the abort-* cases.
17
18 #### Install info files into the dir file
19 ###: install-info --quiet --section "section pattern" "Section Title" \
20 ###:              --description="Name of the document" /usr/info/foo.info
21 ###
22 #### Create stub directories under /usr/local
23 ###: if test ! -d /usr/local/lib/foo; then
24 ###:   if test ! -d /usr/local/lib; then
25 ###:     if mkdir /usr/local/lib; then
26 ###:       chown root.staff /usr/local/lib || true
27 ###:       chmod 2775 /usr/local/lib || true
28 ###:     fi
29 ###:   fi
30 ###:   if mkdir /usr/local/lib/foo; then
31 ###:     chown root.staff /usr/local/lib/foo || true
32 ###:     chmod 2775 /usr/local/lib/foo || true
33 ###:   fi
34 ###: fi
35 ###
36 #### Ensure the menu system is updated
37 ###: [ ! -x /usr/bin/update-menus ] || /usr/bin/update-menus
38 ###
39 #### Arrange for a daemon to be started at system boot time
40 ###: update-rc.d foo default >/dev/null
41 ###
42 case "$1" in
43   configure)
44     # Configure this package.  If the package must prompt the user for
45     # information, do it here.
46     
47         mkdir -p /var/lib/citadel/www/static
48     # Activate menu-methods script
49     #: chmod a+x /etc/menu-methods/foo
50
51     # Update ld.so cache
52     #: ldconfig
53
54     # Make our version of a program available
55     #: update-alternatives \
56     #:       --install /usr/bin/program program /usr/bin/alternative 50 \
57     #:       --slave /usr/share/man/man1/program.1.gz program.1.gz \
58     #:               /usr/share/man/man1/alternative.1.gz
59
60     # Tell ucf that the file in /usr/share/foo is the latest
61     # maintainer version, and let it handle how to manage the real
62     # confuguration file in /etc. This is how a static configuration
63     # file can be handled:
64         cd /var/lib/citadel/www/static; md5sum * |grep -v ".gz" |grep -v md5sums>/tmp/md5sums
65         gunzip -c /usr/share/doc/citadel-webcit/examples/static/md5sums  > /tmp/newsums
66         if diff /tmp/newsums /tmp/md5sums >/dev/null; then
67                 echo >/dev/null
68         else
69                 cd /usr/share/doc/citadel-webcit/examples/static; for i in `echo *|sed "s;md5sums.gz;;"`; do 
70                         case $i in 
71                                 *.gz)
72                                         j=`echo $i|sed "s;.gz;;"`
73                                         gunzip -c  "/usr/share/doc/citadel-webcit/examples/static/$i" >"/tmp/$j"
74                                         i=$j
75                                         ;;
76                                 *)
77                                         cp "/usr/share/doc/citadel-webcit/examples/static/$i" "/tmp"
78                                         ;;
79                         esac
80                         origsum=`grep " $i" /tmp/md5sums |sed "s; .*;;"`
81                         newsum=`grep " $i" /tmp/newsums |sed "s; .*;;"`
82                         if test -z "$origsum"; then
83                                 ucf "/tmp/$i" "/var/lib/citadel/www/static/$i"
84                         else
85                                 if test "$origsum" != "$newsum"; then
86                                         ucf "/tmp/$i" "/var/lib/citadel/www/static/$i"
87                                 fi
88                         fi
89                 done
90         fi
91         rm -f /tmp/newsums /tmp/md5sums
92         if test ! -d /var/lib/citadel/keys; then
93                 mkdir -p /var/lib/citadel/keys
94         fi
95         if test ! -d /var/run/citadel/keys; then
96                 mkdir -p /var/run/citadel/keys
97         fi
98
99         db_get citadel/WebcitHttpPort && http_port="$RET"
100         db_get citadel/WebcitHttpsPort && https_port="$RET"     
101         set >/tmp/testfoo
102         echo "aplying your settings"
103         if grep -q "webserver" /etc/inittab; then
104                 echo "/usr/sbin
105 Yes
106 $http_port
107 $https_port
108 No
109 127.0.0.1
110 504
111 "|/usr/lib/citadel-webcit/setup -q
112         else 
113                 echo "/usr/sbin
114 " |/usr/lib/citadel-webcit/setup -q
115
116         fi
117
118     #### There are three sub-cases:
119     ###if test "${2+set}" != set; then
120     ###  # We're being installed by an ancient dpkg which doesn't remember
121     ###  # which version was most recently configured, or even whether
122     ###  # there is a most recently configured version.
123     ###  :
124         ###
125     ###elif test -z "$2" -o "$2" = "<unknown>"; then
126     ###  # The package has not ever been configured on this system, or was
127     ###  # purged since it was last configured.
128     ###  :
129         ###
130     ###else
131     ###  # Version $2 is the most recently configured version of this
132     ###  # package.
133     ###  :
134         ###
135     ###fi 
136         ;;
137   abort-upgrade)
138     # Back out of an attempt to upgrade this package FROM THIS VERSION
139     # to version $2.  Undo the effects of "prerm upgrade $2".
140     #:
141
142     ;;
143   abort-remove)
144     ###if test "$2" != in-favour; then
145     ###  echo "$0: undocumented call to \`postinst $*'" 1>&2
146     ###  exit 0
147     ###fi
148     #### Back out of an attempt to remove this package, which was due to
149     #### a conflict with package $3 (version $4).  Undo the effects of
150     #### "prerm remove in-favour $3 $4".
151     ###:
152
153     ;;
154   abort-deconfigure)
155     ###if test "$2" != in-favour -o "$5" != removing; then
156     ###  echo "$0: undocumented call to \`postinst $*'" 1>&2
157     ###  exit 0
158     ###fi
159     #### Back out of an attempt to deconfigure this package, which was
160     #### due to package $6 (version $7) which we depend on being removed
161     #### to make way for package $3 (version $4).  Undo the effects of
162     #### "prerm deconfigure in-favour $3 $4 removing $6 $7".
163     ###:
164
165     ;;
166   *) echo "$0: didn't understand being called with \`$1'" 1>&2
167      exit 0;;
168 esac
169
170 exit 0