root/alternc-awstats/trunk/debian/postinst

Revision 2426, 3.8 kB (checked in by engelaere, 4 weeks ago)

close #1167 Séparation du menu du gestionnaire de fichier d'AlternC

  • 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 MENUFILE="/etc/alternc/menulist.txt"
9 LOGAPACHE="/etc/awstats/awstats.log.alternc.conf"
10
11 if [ -x /usr/sbin/apache ]; then
12     APACHEROTATE="/etc/logrotate.d/apache"
13 fi
14
15 if [ -x /usr/sbin/apache2 ]; then
16     APACHEROTATE="/etc/logrotate.d/apache2"
17 fi
18
19 # Add awstats include to the apache configuration file given as argument
20 # function configure {
21 #     if ! grep -Eq "\*\*\*AWSTATS\*\*\*" $1; then
22 #       cp -a -f $1 $1.tmp
23 #       sed -e "s/\*\*\*ALTERNC_ALIASES\*\*\*/&\\
24 #           # ***AWSTATS*** \\
25 #       Include \"\/etc\/apache\/alternc-awstats.conf\"/" < $1 > $1.tmp
26 #       mv -f $1.tmp $1
27 #     fi
28 # }
29 # Configure logrotate.d/apache to create log owned by group www-data :
30 function logrotate_apache {
31         cp -a -f $APACHEROTATE $APACHEROTATE.tmp
32         sed -e 's/create 640 root adm/create 640 root www-data/' < $APACHEROTATE > $APACHEROTATE.tmp
33         mv -f $APACHEROTATE.tmp $APACHEROTATE
34 }
35
36 case "$1" in
37   configure)
38
39     # Then, configure the quota for "aws"
40     db_get alternc-awstats/default_quota_value || true
41     /usr/lib/alternc/quota_init aws $RET
42
43     db_stop
44
45     echo "Installing mysql table"
46     mysql --defaults-file=/etc/alternc/my.cnf \
47         </usr/share/alternc/awstats.sql || true
48
49     # Refresh apache configuration
50     # configure /etc/alternc/templates/apache/httpd.conf
51     # configure /etc/alternc/templates/apache-ssl/httpd.conf
52
53     if [ -x /usr/sbin/apache ]; then
54         if [ ! -h /etc/apache/conf.d/alterncawstats.conf ]; then
55             ln -sf /etc/alternc/alterncawstats.conf \
56                 /etc/apache/conf.d/alterncawstats.conf
57         fi
58         # build awstats.log.alternc.conf if it does not exist
59         if [ ! -f $LOGAPACHE ]; then
60             cat > $LOGAPACHE <<EOF
61 LogFile="/var/log/apache/access.log"
62 LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %other %virtualname"
63 EOF
64             chown www-data:www-data $LOGAPACHE
65             chmod 640 $LOGAPACHE
66         fi
67     fi
68
69     if [ -x /usr/sbin/apache2 ]; then
70         if [ ! -h /etc/apache2/conf.d/alterncawstats.conf ]; then
71             ln -sf /etc/alternc/alterncawstats.conf \
72                 /etc/apache2/conf.d/alterncawstats.conf
73         fi
74         # build awstats.log.alternc.conf if it does not exist
75         if [ ! -f $LOGAPACHE ]; then
76             cat > $LOGAPACHE <<EOF
77 LogFile="/var/log/apache2/access.log"
78 LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"
79 EOF
80             chown www-data:www-data $LOGAPACHE
81             chmod 640 $LOGAPACHE
82         fi
83     fi
84
85     if [ ! -h /etc/apache-ssl/conf.d/alterncawstats.conf ]; then
86         ln -sf /etc/alternc/alterncawstats.conf \
87             /etc/apache-ssl/conf.d/alterncawstats.conf
88     fi
89
90     if [ ! -h /var/alternc/cgi-bin/awstats.pl ]; then
91         ln -sf /usr/lib/cgi-bin/awstats.pl \
92             /var/alternc/cgi-bin/awstats.pl
93     fi
94     alternc.install
95
96     logrotate_apache
97     # Process the language compilation.
98     /usr/share/alternc/install/dopo.sh
99
100     # Add htpasswd :
101     touch /etc/alternc/awstats.htpasswd
102     chown www-data /etc/alternc/awstats.htpasswd /etc/awstats
103     chmod 644 /etc/alternc/awstats.htpasswd
104     chmod 755 /etc/awstats
105     mkdir -p /var/cache/awstats
106     chown www-data:www-data /var/cache/awstats
107
108     # ADD menu item :
109     if ! grep -q "^menu_aws.php$" "$MENUFILE"; then
110         rm -f $MENUFILE.alternc_awstats
111         sed -e "s/menu_sta2.php/&\\
112 menu_aws.php/" <$MENUFILE >$MENUFILE.alternc_awstats
113         mv -f $MENUFILE.alternc_awstats $MENUFILE
114     fi
115     ;;
116
117   abort-upgrade|abort-remove|abort-deconfigure)
118     ;;
119
120   *)
121     echo "postinst called with unknown argument \`$1'" >&2
122     exit 1
123     ;;
124 esac
125
126 # dh_installdeb will replace this with shell code automatically
127 # generated by other debhelper scripts.
128 #DEBHELPER#
129
130 # vim: et sw=4
131
Note: See TracBrowser for help on using the browser.