Alternc  latest
Alternc logiel libre pour l'hébergement
alternc-awstats.postinst
Go to the documentation of this file.
1 #!/bin/bash -e
2 
3 # Uses debconf
4 . /usr/share/debconf/confmodule
5 
6 LOGAPACHE="/etc/alternc/awstats.log.alternc.conf"
7 APACHEROTATE="/etc/logrotate.d/apache2"
8 
9 logrotate_apache() {
10  cp -a -f $APACHEROTATE $APACHEROTATE.tmp
11  sed -e 's/create 640 root adm/create 640 root www-data/' < $APACHEROTATE > $APACHEROTATE.tmp
12  mv -f $APACHEROTATE.tmp $APACHEROTATE
13 }
14 
15 case "$1" in
16  configure)
17 
18  # Then, configure the quota for "aws"
19  db_get alternc-awstats/default_quota_value || true
20  /usr/lib/alternc/quota_init aws $RET
21 
22  db_stop
23 
24  echo "Installing mysql table"
25  mysql --defaults-file=/etc/alternc/my.cnf \
26  </usr/share/alternc/awstats.sql || true
27 
28  # Refresh apache configuration
29  # configure /etc/alternc/templates/apache/httpd.conf
30  # configure /etc/alternc/templates/apache-ssl/httpd.conf
31 
32  if [ -d /etc/apache2/conf-enabled ]; then
33  if [ ! -L /etc/apache2/conf-enabled/alterncawstats.conf ]; then
34  ln -sf /etc/alternc/alterncawstats.conf \
35  /etc/apache2/conf-enabled/alterncawstats.conf
36  fi
37  # build awstats.log.alternc.conf if it does not exist
38  if [ ! -f $LOGAPACHE ]; then
39  cat > $LOGAPACHE <<EOF
40 #LogFile directive isn't important here :
41 #Awstats is launched with the good "LogFile" directive when called
42 LogFile="/var/log/apache2/access.log"
43 LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %other %virtualname"
44 EOF
45  fi
46  chown alterncpanel:root $LOGAPACHE
47  chmod 644 $LOGAPACHE
48  fi
49 
50  logrotate_apache
51 
52  # Add htpasswd :
53  touch /etc/alternc/awstats.htpasswd
54  chown alterncpanel /etc/alternc/awstats.htpasswd /etc/awstats
55  chmod 640 /etc/alternc/awstats.htpasswd
56  chmod 755 /etc/awstats
57  mkdir -p /var/cache/awstats
58  chown alterncpanel:www-data /var/cache/awstats
59  chmod 770 /var/cache/awstats
60 
61  # Update rights on previous user's awstats configuration files
62  chown alterncpanel:root /etc/awstats/awstats.*.conf > /dev/null 2>&1 || true
63 
64  echo -e "\033[31m**********************************************"
65  echo "* ALTERNC-AWSTATS ACTION REQUESTED *"
66  echo "* If you add an autorized user called 'admin'*"
67  echo "* in statistics section, he will access *"
68  echo "* every stats of every users *"
69  echo "* *"
70  echo "* Please run alternc.install to fully deploy *"
71  echo "**********************************************"
72  echo -e "\033[0m"
73  ;;
74 
75  abort-upgrade|abort-remove|abort-deconfigure)
76  ;;
77 
78  *)
79  echo "postinst called with unknown argument \`$1'" >&2
80  exit 1
81  ;;
82 esac
83 
84 # dh_installdeb will replace this with shell code automatically
85 # generated by other debhelper scripts.
86 #DEBHELPER#
87 
88 # vim: et sw=4