webcit_before_automake is now the trunk
[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         rm -f /tmp/md5sums
65         touch /tmp/md5sums
66         cd /var/lib/citadel/www/; 
67         for i in `find -type f `; do 
68                 md5sum "$i" >>/tmp/md5sums
69         done
70
71         cd /usr/share/doc/citadel-webcit/examples/
72         # if target dirs don't exist, create them.
73         for i in `find -type d` ; do 
74                 if test ! -d /var/lib/citadel/www/$i; then
75                         mkdir -p /var/lib/citadel/www/$i 
76                 fi
77         done
78
79         gunzip -c md5sums  > /tmp/newsums
80         if diff /tmp/newsums /tmp/md5sums >/dev/null; then
81                 echo ''>/dev/null
82         else
83                 cd /usr/share/doc/citadel-webcit/examples/
84                 for i in `cat /tmp/newsums |sed "s;.* \./;;"`; do 
85                         if test -f $i.gz; then 
86                                 j=`basename $i|sed -e "s;.gz;;" `
87                                 gunzip -c  "/usr/share/doc/citadel-webcit/examples$REL_PATH/$i" >"/tmp/$j"
88                                 i=`dirname $i`/$j
89                         else
90                                 j=`basename $i`
91                                 cp "/usr/share/doc/citadel-webcit/examples/$i" "/tmp"
92                         fi
93                         if test -f /var/lib/citadel/www/$i; then
94                                 origsum=`grep "$i" /tmp/md5sums |sed "s; .*;;"`
95                                 newsum=`grep "$i" /tmp/newsums |sed "s; .*;;"`
96                                 if test -z "$origsum"; then
97                                         ucf "/tmp/$j" "/var/lib/citadel/www/$i"
98                                 else
99                                         if test "$origsum" != "$newsum"; then
100                                                 ucf "/tmp/$j" "/var/lib/citadel/www/$i"
101                                         fi
102                                 fi
103                         else
104                                 ucf "/tmp/$j" "/var/lib/citadel/www/$i"
105                         fi
106                         rm -f "/tmp/$j"
107                 done
108         fi
109         rm -f /tmp/newsums /tmp/md5sums
110         if test ! -d /var/lib/citadel/keys; then
111                 mkdir -p /var/lib/citadel/keys
112         fi
113         if test ! -d /var/run/citadel/keys; then
114                 mkdir -p /var/run/citadel/keys
115         fi
116
117         db_get citadel/WebcitHttpPort && http_port="$RET"
118         db_get citadel/WebcitHttpsPort && https_port="$RET"     
119         set >/tmp/testfoo
120         echo "aplying your settings"
121         if grep -q "webserver" /etc/inittab; then
122                 echo "/usr/sbin
123 Yes
124 $http_port
125 $https_port
126 No
127 127.0.0.1
128 504
129 "|/usr/lib/citadel-webcit/setup -q
130                 echo "/usr/sbin
131 Yes
132 $http_port
133 $https_port
134 No
135 127.0.0.1
136 504
137 /usr/lib/citadel-webcit/setup -q" >>/tmp/foo
138         else 
139                 echo "/usr/sbin
140 " |/usr/lib/citadel-webcit/setup -q
141
142         fi
143
144     #### There are three sub-cases:
145     ###if test "${2+set}" != set; then
146     ###  # We're being installed by an ancient dpkg which doesn't remember
147     ###  # which version was most recently configured, or even whether
148     ###  # there is a most recently configured version.
149     ###  :
150         ###
151     ###elif test -z "$2" -o "$2" = "<unknown>"; then
152     ###  # The package has not ever been configured on this system, or was
153     ###  # purged since it was last configured.
154     ###  :
155         ###
156     ###else
157     ###  # Version $2 is the most recently configured version of this
158     ###  # package.
159     ###  :
160         ###
161     ###fi 
162         ;;
163   abort-upgrade)
164     # Back out of an attempt to upgrade this package FROM THIS VERSION
165     # to version $2.  Undo the effects of "prerm upgrade $2".
166     #:
167
168     ;;
169   abort-remove)
170     ###if test "$2" != in-favour; then
171     ###  echo "$0: undocumented call to \`postinst $*'" 1>&2
172     ###  exit 0
173     ###fi
174     #### Back out of an attempt to remove this package, which was due to
175     #### a conflict with package $3 (version $4).  Undo the effects of
176     #### "prerm remove in-favour $3 $4".
177     ###:
178
179     ;;
180   abort-deconfigure)
181     ###if test "$2" != in-favour -o "$5" != removing; then
182     ###  echo "$0: undocumented call to \`postinst $*'" 1>&2
183     ###  exit 0
184     ###fi
185     #### Back out of an attempt to deconfigure this package, which was
186     #### due to package $6 (version $7) which we depend on being removed
187     #### to make way for package $3 (version $4).  Undo the effects of
188     #### "prerm deconfigure in-favour $3 $4 removing $6 $7".
189     ###:
190
191     ;;
192   *) echo "$0: didn't understand being called with '$1'" 1>&2
193      exit 0;;
194 esac
195
196 exit 0