root/alternc-awstats/tags/0.4/debian/postinst

Revision 1083, 2.2 kB (checked in by benjamin, 3 years ago)

db_stop on postinst

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/sh
2
3 set -e
4
5 # Uses debconf
6 . /usr/share/debconf/confmodule
7
8 CONFIGFILE="/etc/alternc/local.sh"
9 MENUFILE="/etc/alternc/menulist.txt"
10 APACHEROTATE="/etc/logrotate.d/apache"
11
12 # Add awstats include to the apache configuration file given as argument
13 function configure {
14     if ! grep -Eq "\*\*\*AWSTATS\*\*\*" $1; then
15         cp -a -f $1 $1.tmp
16         sed -e "s/\*\*\*ALTERNC_ALIASES\*\*\*/&\\
17             # ***AWSTATS*** \\
18         Include \"\/etc\/apache\/alternc-awstats.conf\"/" < $1 > $1.tmp
19         mv -f $1.tmp $1
20     fi
21 }
22 # Configure logrotate.d/apache to create log owned by group www-data :
23 function logrotate_apache {
24         cp -a -f $APACHEROTATE $APACHEROTATE.tmp
25         sed -e 's/create 640 root adm/create 640 root www-data/' < $APACHEROTATE > $APACHEROTATE.tmp
26         mv -f $APACHEROTATE.tmp $APACHEROTATE
27 }
28
29 case "$1" in
30   configure)
31     . "$CONFIGFILE"
32
33     # Then, configure the quota for "aws"
34     db_get alternc-awstats/default_quota_value || true
35     /usr/lib/alternc/quota_init aws $RET
36
37     db_stop
38
39     echo "Installing mysql table"
40     mysql -h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE" \
41         </usr/share/alternc/awstats.sql || true
42    
43     # Refresh apache configuration
44     configure /etc/alternc/templates/apache/httpd.conf
45     configure /etc/alternc/templates/apache-ssl/httpd.conf
46     ln /usr/lib/cgi-bin/awstats.pl /var/alternc/cgi-bin/ -sf
47     alternc.install
48
49     logrotate_apache
50     # Process the language compilation.
51     /usr/share/alternc/install/dopo.sh
52    
53     # Add htpasswd :
54     touch /etc/alternc/awstats.htpasswd
55     chown www-data /etc/alternc/awstats.htpasswd /etc/awstats
56     chmod 644 /etc/alternc/awstats.htpasswd
57     chmod 755 /etc/awstats
58
59     # ADD menu item :
60     if ! grep -q "^menu_aws.php$" "$MENUFILE"; then
61         rm -f $MENUFILE.alternc_awstats
62         sed -e "s/menu_brouteur.php/&\\
63 menu_aws.php/" <$MENUFILE >$MENUFILE.alternc_awstats
64         mv -f $MENUFILE.alternc_awstats $MENUFILE
65     fi
66     ;;
67
68   abort-upgrade|abort-remove|abort-deconfigure)
69     ;;
70
71   *)
72     echo "postinst called with unknown argument \`$1'" >&2
73     exit 1
74     ;;
75 esac
76
77 # dh_installdeb will replace this with shell code automatically
78 # generated by other debhelper scripts.
79 #DEBHELPER#
80
81 # vim: et sw=4
82
Note: See TracBrowser for help on using the browser.