Prva inacica paketa za Debian jessie distribuciju.
[apache2-cn.git] / debian / postinst
1 #!/bin/sh
2
3 set -e
4
5 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
6
7 # Source debconf library.
8 . /usr/share/debconf/confmodule
9
10 case "$1" in
11     configure)
12         # continue below
13         ;;
14
15     abort-upgrade|abort-remove|abort-deconfigure)
16         exit 0
17         ;;
18
19     *)
20         echo "postinst called with unknown argument \`$1'" >&2
21         exit 0
22         ;;
23 esac
24
25
26 # Include CARNet functions.
27 . /usr/share/carnet-tools/functions.sh
28
29 PKG="apache2-cn"
30 VERSION="2.4.10+1"
31 CONFDIR="/etc/apache2"
32 CONF="$CONFDIR/apache2.conf"
33 PORTCONF="$CONFDIR/ports.conf"
34 A2CNDIR=/usr/share/apache2-cn
35 TMPLDIR=$A2CNDIR/templates
36 CERTDIR=/etc/ssl/certs
37
38 HOST=$(hostname)
39 FQDN=$(hostname --fqdn)
40 WEBMASTER="webmaster@$FQDN"
41 DOMAIN=$(hostname -d)
42 BACKUPDIR="/var/backups/apache2-cn"
43
44 need_restart=0
45 apache2_sslcf=
46 apache2_sslckf=
47 apache2_sslccf=
48 has_vhosts=0
49 temp_files=
50 has_listen_ssl=0
51 listen_ssl_mask=
52
53
54 # cleanup()
55 #
56 #   Cleanup all temp files.
57 #
58 cleanup () {
59     if [ -n "$temp_files" ]; then
60         for item in $temp_files; do
61             if [ -e "$item" ]; then
62                 rm -f $item
63             fi
64         done
65     fi
66 }
67
68 # tag_conf()
69 #
70 #   Add CARNet package info lines to config's header.
71 #
72 tag_conf () {
73     local conf_file
74     conf_file="$1"
75
76     if [ -e "$conf_file" ]; then
77         cat >> $conf_file <<EOF
78 ## Begin - Generated by CARNet package apache2-cn
79 #
80 #  REMOVE this whole block if you DON'T WANT apache2-cn
81 #  to edit your configuration file.
82 #
83 ## End - Generated by CARNet package apache2-cn
84 EOF
85     fi
86 }
87
88 # chk_conf_tag ()
89 #
90 #   Check if configuration file has CARNet package info lines.
91 #   return:  $RET => 0 - tagged
92 #                    1 - not tagged or file does not exists
93 #                    2 - file exists, but it is not tagged
94 #
95 chk_conf_tag () {
96     local conf_file
97     conf_file="$1"
98     RET=1
99
100     if [ -f "$conf_file" ]; then
101         if egrep -q "^## Begin - Generated by CARNet package apache2-cn$" "$conf_file"; then
102             RET=0
103         else
104             RET=2
105         fi
106     fi
107 }
108
109 # generate_ssl()
110 #
111 #   Generate Apache2 web server SSL certificate.
112 #
113 generate_ssl () {
114     generate_ssl_output=$($A2CNDIR/carnet-generate-ssl ignore "$FQDN" "$WEBMASTER" "$DOMAIN" 2> /dev/null)
115     cp_echo "$generate_ssl_output"
116     need_restart=1
117 }
118
119 # listen_ssl()
120 #
121 #   Check if port 443 is configured in ports.conf file.
122 #
123 listen_ssl() {
124
125     if [ ! -f "$PORTCONF" ] || ! egrep -iq "^[[:space:]]*Listen[[:space:]]+443$" "$PORTCONF"; then
126
127         cp_echo "CN: Enabling SSL port (443) for Apache2 web server."
128
129         out=$(mktemp ${PORTCONF}.XXXXXX)
130         temp_files="${temp_files} ${out}"
131
132         if [ -f "$PORTCONF" ]; then
133             cp $PORTCONF $out
134         fi
135
136         echo "Listen 443" >> $out
137         cp_mv $out $PORTCONF
138         chmod 644 $PORTCONF
139
140         need_restart=1
141     fi
142 }
143
144 # install_conf()
145 #
146 #   Install specified Apache2 configuration file.
147 #
148 install_conf() {
149     conftmpl="$A2CNDIR/$1.conf"
150     conf="$CONFDIR/conf-available/$2.conf"
151
152     if [ ! -e "$conf" ]; then
153         cp_echo "CN: Generating CARNet specific configuration."
154         cp "$conftmpl" "$conf"
155     else
156         cp_echo "CN: $conf already exists, left untouched." 1>&2
157     fi
158
159     cp_echo "CN: Enabling CARNet specific configuration."
160     a2enconf -m -q "$2"
161     need_restart=1
162 }
163
164 # install_vhost()
165 #
166 #   Install specified VirtualHost for Apache2 web server.
167 #
168 #   Invocation:
169 #
170 #   install_vhost [-nvh] [-d] [-s docroot_symlink_dest] template site site-enabled-symlink
171 #
172 #     -nvh - add NameVirtualHost
173 #     -d   - mkdir DocumentRoot
174 #     -r   - set DocumentRoot
175 #     -n   - set ServerName
176 #     -s X - symlink DocumentRoot to X (all in /var/www)
177 #
178 #   site - host part of ServerName unless -r or -n is used
179 #   site-enabled-symlink - name of file/symlink in sites-available/sites-enabled
180 #                          (without .conf suffix)
181 #
182 install_vhost() {
183     add_namevirthost=
184     mkdir_docroot=
185     symlink_docroot=
186     docroot=
187     vhostname=
188
189     while echo "x$1" | grep -q '^x-'; do
190         case "$1" in
191             -nvh)
192                 add_namevirthost=1
193                 shift
194                 ;;
195             -d)
196                 mkdir_docroot=1
197                 shift
198                 ;;
199             -s)
200                 shift
201                 symlink_docroot="$1"
202                 shift
203                 ;;
204             -r)
205                 shift
206                 docroot="$1"
207                 if ! echo "$docroot" | grep -q /; then
208                     docroot="/var/www/$docroot"
209                 fi
210                 shift
211                 ;;
212             -n)
213                 shift
214                 vhostname="$1"
215                 shift
216                 ;;
217         esac
218     done
219
220     vhosttmpl="$1.template"
221     vhost="$2"
222     vsite="$3"
223     venabled="$3.conf"
224     [ -z "$vhostname" ] && vhostname=$(echo "$vhost"| awk -F. '{print $1}')
225     force_vhost=
226
227     vhostdir=$CONFDIR/sites-available
228     venabledir=$CONFDIR/sites-enabled
229
230     if [ ! -e "$TMPLDIR/${vhosttmpl}" ]; then
231         echo "E: vhost template ${vhosttmpl} not found in $TMPLDIR!" 1>&2
232         exit 2
233     fi
234
235     [ -z "$docroot" ] && docroot="/var/www/$vhostname.$DOMAIN"
236
237     # if we were broken mid-installation, force
238     if [ ! -e "$docroot" -a \( -n "$mkdir_docroot" -o -n "$symlink_docroot" \) ]; then
239         force_vhost=1
240     fi
241
242     # add vhost if either of these is true
243     # - adding is forced OR
244     # - it doesn't exist
245     #
246     if [ -n "$force_vhost" -o \( ! -e "$vhostdir/$venabled" -a ! -e "$venabledir/$venabled" \) ]; then
247
248         cp_echo "CN: Adding $vhost VirtualHost."
249         out=$(mktemp $vhostdir/$venabled.XXXXXX)
250         temp_files="${temp_files} ${out}"
251
252         # CARNet header.
253         tag_conf "$out"
254
255         if [ "$add_namevirthost" ]; then
256             nvh=$(awk -F'[ >]' '/^<VirtualHost/ {print $2}' $TMPLDIR/$vhosttmpl |\
257                 sed "s/IPADDR/$MYIP/g")
258             echo "NameVirtualHost $nvh" >> $out
259         fi
260
261         sed "s/HOST/$vhostname/g; s/DOMAIN/$DOMAIN/g;
262             s#DOCROOT#$docroot#g; s/IPADDR/$MYIP/g" < $TMPLDIR/$vhosttmpl >> $out
263         cp_mv $out $vhostdir/$venabled
264         chmod 644 $vhostdir/$venabled
265         a2ensite -m -q "$vsite"
266
267         if [ -n "$mkdir_docroot" -a ! -d "$docroot" ]; then
268             mkdir "$docroot"
269             echo '<html><body><h1>Radi!</h1></body></html>' > "$docroot/index.html"
270         elif [ -n "$symlink_docroot" ]; then
271             ln -fs "$symlink_docroot" "$docroot"
272         fi
273
274         need_restart=1
275     fi
276 }
277
278 # backup_conf()
279 #
280 #   Backup configuration files located in specified directory.
281 #
282 backup_conf () {
283     local dir file backup_dir
284
285     dir="$1"
286
287     if [ -d "${dir}" ] && [ -n "$(ls -A ${dir}/)" ]; then
288         cp_echo "CN: Doing backup for all files in $dir"
289         for file in ${dir}/*; do
290             if [ -f "$file" ]; then
291                 if [ -z "$(echo $file | egrep '^/.*~')" ]; then
292                     backup_dir="$BACKUPDIR/$(basename $(dirname "$file"))"
293                     cp_backup_conffile -d "$backup_dir" -p "$file"
294                 fi
295             fi
296         done
297     fi
298 }
299
300 # move_conf()
301 #
302 #   Move configuration files from one directory to another. The .conf suffix
303 #   will be added. Will try to enable the configuration if -e is specified.
304 #
305 move_conf () {
306     local toenable ctype dir newdir file newfile
307
308     if [ "$1" = "-e" ]; then
309         toenable="$1"
310         shift
311     fi
312
313     ctype="$1"
314     dir="$2"
315     newdir="$3"
316
317     case "$ctype" in
318         site|conf)
319             # continue below
320             ;;
321         *)
322             return 1
323             ;;
324     esac
325
326     if [ -z "$newdir" ]; then
327         newdir="$dir"
328     fi
329
330     if [ -d "${dir}" ] && [ -n "$(ls -A ${dir}/)" ]; then
331         mkdir -p "$newdir"
332         for file in ${dir}/*; do
333             newfile="${newdir}/$(basename "$file" .conf).conf"
334             if [ ! -e "$newfile" ]; then
335                 cp_echo "CN: Preserving changes to $newfile (renamed from $file)."
336                 cp_mv "$file" "$newfile"
337                 if [ -n "$toenable" ]; then
338                     cp_echo "CN: Enabling configuration $newfile"
339                     a2en$ctype -m -q "$(basename "$newfile" .conf)" || true
340                 fi
341                 need_restart=1
342             fi
343         done
344     fi
345 }
346
347 # rename_conf()
348 #
349 #   Append the .conf suffix to all configuration files located in specified
350 #   available and enabled directories. Updated symlinks if necessary.
351 #
352 #
353 rename_conf () {
354     local ctype adir edir afile efile newfile
355
356     ctype="$1"
357     adir="$2"
358     edir="$3"
359
360     case "$ctype" in
361         site|conf)
362             # continue below
363             ;;
364         *)
365             return 1
366             ;;
367     esac
368
369     if [ -d "${edir}" ] && [ -n "$(ls -A ${edir}/)" ]; then
370         mkdir -p "$adir"
371         for efile in ${edir}/*; do
372             [ ! -e "${edir}/$(basename "$efile" .conf).conf" ] || continue
373
374             afile="$(readlink -q -m "$efile")"
375
376             [ "$(dirname "$afile")" = "$adir" ] || continue
377             [ "$(basename "$afile" .conf)" = "$(basename "$efile" .conf)" ] || continue
378
379             newfile="${adir}/$(basename "$afile" .conf).conf"
380             [ ! -e "$newfile" ] || continue
381
382             cp_echo "CN: Preserving changes to $newfile (renamed from $afile)."
383             cp_mv "$afile" "$newfile"
384
385             cp_echo "CN: Removing obsolete symlink $efile"
386             rm -f "$efile"
387
388             cp_echo "CN: Enabling configuration $newfile"
389             a2en$ctype -m -q "$(basename "$newfile" .conf)" || true
390             need_restart=1
391         done
392     fi
393 }
394
395
396 # Set trap for deleting all temp files.
397 #
398 trap cleanup 0 1 2 15
399
400
401 # Backup all configuration located in /etc/apache2/conf.d/,
402 # /etc/apache2/conf-available/ and /etc/apache2/sites-available/
403 # directories.
404 #
405 if [ -e "$CONF" ]; then
406     cp_echo "CN: Doing backup for $CONF"
407     cp_backup_conffile -d $BACKUPDIR -p $CONF
408 fi
409
410 backup_conf $CONFDIR/conf.d
411 backup_conf $CONFDIR/conf-available
412 backup_conf $CONFDIR/sites-available
413
414 cp_echo "CN: Backup is located in directory: $BACKUPDIR/"
415
416
417 # Enable Apache2 web server modules (mpm_prefork, cgi, rewrite, userdir, suexec, php5, ssl).
418 #
419 if [ -e "$CONF" ]; then
420     cp_echo "CN: Enabling the prefork Apache2 MPM."
421     if [ "$(a2query -M || true)" != "prefork" ]; then
422         a2dismod -m -q "mpm_$(a2query -M || true)"
423         a2enmod -m -q mpm_prefork
424     fi
425
426     cp_echo "CN: Enabling required Apache2 web server modules."
427     a2enmod -m -q cgi
428     a2enmod -m -q rewrite
429     a2enmod -m -q userdir
430     a2enmod -m -q suexec
431     a2enmod -m -q php5
432     a2enmod -m -q ssl
433 fi
434
435
436 # Make sure configuration files have the .conf suffix. Move them
437 # to appropriate locations.
438 #
439 if [ -d "$CONFDIR/conf.d" ]; then
440     cp_echo "CN: Obsolete configuration directory $CONFDIR/conf.d/ found."
441     move_conf -e conf $CONFDIR/conf.d $CONFDIR/conf-available
442 fi
443
444 rename_conf site $CONFDIR/sites-available $CONFDIR/sites-enabled
445
446
447 # Check and add IncludeOptional lines to /etc/apache2/apache2.conf:
448 #
449 #   IncludeOptional conf-enabled/*.conf
450 #   IncludeOptional sites-enabled/*.conf
451 #
452 if [ -e "$CONF" ]; then
453
454     cp_echo "CN: Checking IncludeOptional lines in $CONF"
455
456     CONFTMP=`mktemp $CONF.tmp.XXXXXX`
457     temp_files="${temp_files} ${CONFTMP}"
458     cp "$CONF" "$CONFTMP"
459
460     sed -r -i 's#^[[:space:]]*Include(Optional)?[[:space:]]+(/etc/apache2/)?conf\.d(/)?$#IncludeOptional conf-enabled/\*\.conf#I' \
461         "$CONFTMP"
462     sed -r -i 's#^[[:space:]]*Include(Optional)?[[:space:]]+(/etc/apache2/)?sites-enabled(/)?$#IncludeOptional sites-enabled/\*\.conf#I' \
463         "$CONFTMP"
464
465     if ! egrep -iq "^[[:space:]]*IncludeOptional[[:space:]]+conf-enabled/\*\.conf$" "$CONFTMP"; then
466         echo 'IncludeOptional conf-enabled/*.conf' >> "$CONFTMP"
467     fi
468     if ! egrep -iq "^[[:space:]]*IncludeOptional[[:space:]]+sites-enabled/\*\.conf$" "$CONFTMP"; then
469         echo 'IncludeOptional sites-enabled/*.conf' >> "$CONFTMP"
470     fi
471
472     if ! cmp -s "$CONFTMP" "$CONF"; then
473         cp_mv "$CONFTMP" "$CONF"
474         need_restart=1
475     fi
476     rm -f "$CONFTMP"
477 fi
478
479
480 # Install CARNet specific configuration file.
481 #
482 install_conf carnet 000-carnet
483
484 # Enable SSL port (443).
485 #
486 listen_ssl
487
488 # Disable default site configuration.
489 #
490 if [ -e "$CONF" ]; then
491     cp_echo "CN: Disabling default site configuration."
492     a2dissite -m -f -q 000-default || true
493     need_restart=1
494 fi
495
496
497 # Apache2 SSL certificate.
498 #
499 if [ -d "$CONFDIR/conf-enabled" ] && [ -n "$(ls -A $CONFDIR/conf-enabled/)" ]; then
500     listen_ssl_mask=$CONFDIR/conf-enabled/*.conf
501 fi
502 if [ -d "$CONFDIR/sites-enabled" ] && [ -n "$(ls -A $CONFDIR/sites-enabled/)" ]; then
503     listen_ssl_mask=$listen_ssl_mask" "$CONFDIR/sites-enabled/*.conf
504 fi
505
506 for file in $CONF $listen_ssl_mask; do
507     if [ -f "$file" ]; then
508         if egrep -iq '^[[:space:]]*<VirtualHost .*443[[:space:]]*>' $file; then
509             has_listen_ssl=1
510             break
511         fi
512     fi
513 done
514
515 if [ $has_listen_ssl -eq 0 ]; then
516
517     db_get apache2-cn/sslcf || true
518     apache2_sslcf="$RET"
519
520     if [ -n "$apache2_sslcf" ]; then
521
522         db_get apache2-cn/sslckf || true
523         apache2_sslckf="$RET"
524
525         db_get apache2-cn/sslccf || true
526         apache2_sslccf="$RET"
527
528         need_restart=1
529     else
530
531         # Generate new SSL certificate files.
532         generate_ssl
533
534         apache2_sslcf=
535         apache2_sslckf=
536         apache2_sslccf=
537     fi
538 fi
539
540
541 # Add VirtualHosts.
542 # - on fresh install
543 #
544 if [ -z "$2" ]; then
545
546     db_get apache2-cn/wwwhost || true
547     if [ "$RET" = "true" ]; then
548
549         # Add WWW VirtualHost.
550         if [ -f "$CONFDIR/sites-available/000-$FQDN.conf" ]; then
551             cp_backup_conffile -d $BACKUPDIR/sites-available -p $CONFDIR/sites-available/000-$FQDN.conf
552         fi
553         if [ -f "$CONFDIR/sites-available/www.$DOMAIN.conf" ]; then
554             cp_backup_conffile -d $BACKUPDIR/sites-available -p $CONFDIR/sites-available/www.$DOMAIN.conf
555         fi
556
557         chk_conf_tag "$CONFDIR/sites-available/000-$FQDN.conf"
558         if [ ! -f "$CONFDIR/sites-available/000-$FQDN.conf" ] || [ $RET -eq 0 ]; then
559             if egrep -qi "^[[:space:]]*NameVirtualHost[[:space:]]+\*:80$" "$PORTCONF"; then
560                 install_vhost -d -r www.$DOMAIN default $FQDN 000-$FQDN
561             else
562                 install_vhost -nvh -d -r www.$DOMAIN default $FQDN 000-$FQDN
563             fi
564             need_restart=1
565         fi
566
567         chk_conf_tag "$CONFDIR/sites-available/www.$DOMAIN.conf"
568         if [ ! -f "$CONFDIR/sites-available/www.$DOMAIN.conf" ] || [ $RET -eq 0 ]; then
569             install_vhost default www.$DOMAIN www.$DOMAIN
570             need_restart=1
571         fi
572     else
573
574         # No WWW VirtualHost.
575         if [ -f "$CONFDIR/sites-available/000-$FQDN.conf" ]; then
576             cp_backup_conffile -d $BACKUPDIR/sites-available -p $CONFDIR/sites-available/000-$FQDN.conf
577         fi
578
579         chk_conf_tag "$CONFDIR/sites-available/000-$FQDN.conf"
580         if [ ! -f "$CONFDIR/sites-available/000-$FQDN.conf" ] || [ $RET -eq 0 ]; then
581             if egrep -qi "^[[:space:]]*NameVirtualHost[[:space:]]+\*:80$" "$PORTCONF"; then
582                 install_vhost -d -r $FQDN default $FQDN 000-$FQDN
583             else
584                 install_vhost -nvh -d -r $FQDN default $FQDN 000-$FQDN
585             fi
586             need_restart=1
587         fi
588     fi
589 fi
590
591
592 # Add VirtualHost for SSL?
593 #
594 if [ $has_listen_ssl -eq 0 ]; then
595
596     if [ -f "$CONFDIR/sites-available/001-ssl.conf" ]; then
597         cp_backup_conffile -d $BACKUPDIR/sites-available -p $CONFDIR/sites-available/001-ssl.conf
598     fi
599
600     # No active SSL VirtualHosts found - add new one.
601     chk_conf_tag "$CONFDIR/sites-available/001-ssl.conf"
602     if [ ! -f "$CONFDIR/sites-available/001-ssl.conf" ] || [ $RET -eq 0 ]; then
603
604         db_get apache2-cn/wwwhost || true
605         if [ "$RET" = "true" ]; then
606             install_vhost -r www.$DOMAIN -n $HOST ssl ssl 001-ssl
607         else
608             install_vhost -r $FQDN -n $HOST ssl ssl 001-ssl
609         fi
610         need_restart=1
611     fi
612 fi
613
614
615 # Check SSL certificates location for VirtualHosts.
616 #
617 if [ $has_listen_ssl -eq 0 ]; then
618
619     chk_conf_tag "${CONFDIR}/sites-available/001-ssl.conf"
620     if [ $RET -eq 0 ] && [ -n "$apache2_sslcf" ]; then
621
622         SSLTMP=$(mktemp ${CONFDIR}/ssltmp.XXXXXX)
623         temp_files="${temp_files} ${SSLTMP} ${SSLTMP}.cn-old"
624         cp ${CONFDIR}/sites-available/001-ssl.conf $SSLTMP
625
626         # SSLCertificateFile
627         cp_check_and_sed "^[[:space:]]*SSLCertificateFile \/etc\/ssl\/certs\/apache2\.pem" \
628             "s#SSLCertificateFile /etc/ssl/certs/apache2.pem#SSLCertificateFile $apache2_sslcf #g" \
629         $SSLTMP || true
630
631         # SSLCertificateKeyFile
632         cp_check_and_sed "^[[:space:]]*SSLCertificateKeyFile \/etc\/ssl\/private\/apache2\.key" \
633             "s#SSLCertificateKeyFile /etc/ssl/private/apache2.key#SSLCertificateKeyFile $apache2_sslckf #g" \
634         $SSLTMP || true
635
636         # SSLCertificateChainFile
637         if [ -n "$apache2_sslccf" ]; then
638             cp_check_and_sed "^[[:space:]]*# SSLCertificateChainFile \/etc\/ssl\/certs\/(sureserverEDU|cert-chain)\.pem" \
639                 "s#\# SSLCertificateChainFile /etc/ssl/certs/\(sureserverEDU\|cert-chain\).pem#SSLCertificateChainFile $apache2_sslccf #g" \
640             $SSLTMP || true
641         fi
642
643         cp_mv $SSLTMP ${CONFDIR}/sites-available/001-ssl.conf
644
645         need_restart=1
646
647         # Just to be sure.
648         [ -e "${SSLTMP}" ] && rm -f ${SSLTMP}
649         [ -e "${SSLTMP}.cn-old" ] && rm -f ${SSLTMP}.cn-old
650     fi
651 fi
652
653
654 # Check file access permissions for SSL certificates.
655 #
656 cp_echo "CN: Checking file access permissions for Apache2 SSL certificates."
657 sslkey=/etc/ssl/private
658 sslcerts="${sslkey}/ca.key ${sslkey}/apache2-ca.key ${sslkey}/apache2.key"
659 for certf in $sslcerts; do
660     if [ -f "$certf" ]; then
661         chmod 600 $certf
662     fi
663 done
664
665
666 # Check and remove obsolete "Include /etc/apache2/sites-enabled/[^.#]*" from
667 # /etc/apache2/apache2.conf.
668 #
669 if egrep -iq "^[[:space:]]*Include[[:space:]]+\/etc\/apache2\/sites-enabled\/\[\^\.\#\]\*$" "$CONF"; then
670
671     cp_echo "CN: Fixing obsolete Include line in $CONF."
672     CONFTMP=`mktemp $CONF.tmp.XXXXXX`
673     temp_files="${temp_files} ${CONFTMP}"
674
675     sed -r "/^[[:space:]]*Include[[:space:]]+\/etc\/apache2\/sites-enabled\/\[\^\.\#\]\*$/Id" \
676         "$CONF" > "$CONFTMP"
677
678     if ! egrep -iq "^[[:space:]]*Include[[:space:]]+\/etc\/apache2\/sites-enabled\/$" "$CONFTMP"; then
679         echo "Include /etc/apache2/sites-enabled/" >> "$CONFTMP"
680     fi
681
682     cp_mv "$CONFTMP" "$CONF"
683     need_restart=1
684 fi
685
686
687 db_stop || true
688
689
690 # Remove old AOSI configuration for Apache: aosi-www.conf, aosi.conf.
691 #
692 if [ -e "$CONFDIR/conf.d/aosi-www.conf" ] || [ -e "$CONFDIR/conf.d/aosi.conf" ]; then
693     cp_echo "CN: Removing old AOSI configuration files for Apache2."
694     rm -f $CONFDIR/conf.d/aosi-www.conf
695     rm -f $CONFDIR/conf.d/aosi.conf
696     need_restart=1
697 fi
698
699
700 # Restart Apache2 web server if needed.
701 #
702 if [ $need_restart -eq 1 ]; then
703
704     # Check Apache2 web server configuration.
705     if apache2ctl configtest 2>/dev/null; then
706
707         # Restart Apache2 web server.
708         service apache2 reload || true
709     else
710
711         # Something is broken.
712         cp_echo "CN: Your Apache2 configuration seems to be broken."
713         cp_echo "CN: Please, check the service after the installation finishes!"
714     fi
715 fi
716
717
718 # Mail root
719 #
720 cp_mail "$PKG"
721
722
723 # (re)generate monit.d files if monit-cn is installed.
724 #
725 if [ -x "/usr/sbin/update-monit.d" ]; then
726     cp_echo "CN: Updating monit configuration..."
727     update-monit.d || true
728 fi
729
730 #DEBHELPER#
731
732 exit 0