snippet: view plain - save this
1 #!/bin/bash
2 ###############################################################################
3 #
4 # a2ensite : Reprise du a2ensite de la distribution Debian
5 #
6 # by Guillaume Kulakowski a.k.a LLaumgui <guillaume at llaumgui dot com>
7 # based on a Debian's script less anotation about owner.
8 # Version 1.0
9 #
10 ###############################################################################
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not,
23 # - write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 # - See http://www.gnu.org/licenses/gpl.html
26 ###############################################################################
27
28
29 # Varibles
30 SYSCONF_PATH='/etc/httpd' # Chemin vers la conf apache
31 HTTPD_RELOAD='/etc/init.d/httpd reload' # Commande pour relancer apache
32 SITE_AVAILABLE='sites-available' # Site en attente
33 SITE_ENABLED='sites-enabled' # Site activés
34
35
36 # Quel site ?
37 if [ -z $1 ]; then
38 echo "Quel site voulez vous activer ?"
39 echo "Votre choix est : "
40 for site in $SYSCONF_PATH/$SITE_AVAILABLE/*; do
41 echo -e "\t$site" | sed -e "s,$SYSCONF_PATH/$SITE_AVAILABLE/,,g"
42 done;
43 echo -n "Nom du site ? "
44 read SITENAME
45 else
46 SITENAME=$1
47 fi
48
49
50 # Site par défaut
51 if [ $SITENAME = "default" ]; then
52 PRIORITY="000"
53 fi
54
55
56 # Déjà activé ?
57 if [ -e $SYSCONF_PATH/$SITE_ENABLED/$SITENAME -o \
58 -e $SYSCONF_PATH/$SITE_ENABLED/"$PRIORITY"-"$SITENAME" ]; then
59 echo "Ce site est déjà activé ! ! !"
60 exit 0
61 fi
62
63
64 # Présent ?
65 if ! [ -e $SYSCONF_PATH/$SITE_AVAILABLE/$SITENAME ]; then
66 echo "Ce site n'existe pas ! ! !"
67 exit 1
68 fi
69
70
71 # Traitement :
72 if [ $SITENAME = "default" ]; then
73 ln -sf $SYSCONF_PATH/$SITE_AVAILABLE/$SITENAME \
74 $SYSCONF_PATH/$SITE_ENABLED/"$PRIORITY"-"$SITENAME"
75 else
76 ln -sf $SYSCONF_PATH/$SITE_AVAILABLE/$SITENAME $SYSCONF_PATH/$SITE_ENABLED/$SITENAME
77 fi
78
79
80 # Relancer apache ?
81 echo -n "Relancer Apache ? [o]/n : "
82 read RELOAD
83 if ! [ $RELOAD = "n" ]; then
84 $HTTPD_RELOAD
85 echo "Site $SITENAME installé et configuration rechargée."
86 else
87 echo "Site $SITENAME installé. Veuillez relancer apache !"
88 fi

0 comments