snippet: view plain - save this
1 #!/bin/bash
2 ###############################################################################
3 #
4 # a2dissite : Reprise du a2dissite 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 # Quel site ?
36 if [ -z $1 ]; then
37 echo "Quel site voulez vous désactiver ?"
38 echo "Votre choix est : "
39 for site in $SYSCONF_PATH/$SITE_ENABLED/*; do
40 echo -e "\t$site" | sed -e "s,$SYSCONF_PATH/$SITE_ENABLED/,,g"
41 done;
42 echo -n "Nom du site ? "
43 read SITENAME
44 else
45 SITENAME=$1
46 fi
47
48
49 # Site par défaut
50 if [ $SITENAME = "default" ]; then
51 PRIORITY="000"
52 fi
53
54
55 # Déjà désactivé ?
56 if ! [ -e $SYSCONF_PATH/$SITE_ENABLED/$SITENAME -o \
57 -e $SYSCONF_PATH/$SITE_ENABLED/"$PRIORITY"-"$SITENAME" ]; then
58 echo "Ce site est déjà désactivé ! ! !"
59 exit 1
60 fi
61
62
63 # Traitement :
64 if ! rm $SYSCONF_PATH/$SITE_ENABLED/$SITENAME 2>/dev/null; then
65 rm -f $SYSCONF_PATH/$SITE_ENABLED/"$PRIORITY"-"$SITENAME"
66 fi
67
68
69 # Relancer apache ?
70 echo -n "Relancer Apache ? [o]/n : "
71 read RELOAD
72 if ! [ $RELOAD = "n" ]; then
73 $HTTPD_RELOAD
74 echo "Site $SITENAME désinstallé et configuration rechargée."
75 else
76 echo "Site $SITENAME désinstallé. Veuillez relancer apache !"
77 fi

0 comments