Git Repositories

Commit Initial
[animeka-installation.git] / Animeka / Installation / Serveur_Web / Apache / mkvhost
1 #!/bin/sh
2 cd $(dirname "$0")
3 VHOST="$1"
4 if [ -z "$VHOST" ]; then
5   echo "mkvhost vhost_name [alias1] [alias2]" >&2
6   exit 1
7 elif [ -d "$VHOST" ]; then
8   echo "$VHOST already exist" >&2
9   exit 2
10 elif echo "$VHOST" | grep -q ' '; then
11   echo "vhost name cannot contains spaces" >&2
12   exit 3
13 else
14   shift
15   VALIASES="$@"
16   mkdir -p $VHOST/pages $VHOST/logs
17   touch $VHOST/logs/access.log $VHOST/logs/error.log
18   chown www-data: $VHOST/logs/access.log $VHOST/logs/error.log
19   chown :www-data $VHOST/pages
20   chmod g+w $VHOST/pages
21   if [ -n "$VALIASES" ]; then
22     ALIASES=$(/bin/echo -e "\n  ServerAlias $VALIASES")
23   else
24     ALIASES=""
25   fi
26   cat <<EOF > /etc/apache2/sites-available/$VHOST
27 <VirtualHost *:80>
28   ServerName $VHOST$ALIASES
29   ServerAdmin admin@animeka.com
30   DocumentRoot /var/vhosts/$VHOST/pages/
31   <Directory /var/vhosts/$VHOST/pages/>
32     Options Indexes Includes FollowSymLinks MultiViews
33     AllowOverride All
34     Order allow,deny
35     allow from all
36   </Directory>
37   ErrorLog /var/vhosts/$VHOST/logs/error.log
38   # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
39   LogLevel warn
40   CustomLog /var/vhosts/$VHOST/logs/access.log combined
41 </VirtualHost>
42 EOF
43   /bin/echo -e "To enable it, type:\na2ensite $VHOST\n"
44 fi