Alternc  latest
Alternc logiel libre pour l'hébergement
alternc_reload
Go to the documentation of this file.
1 #!/bin/bash
2 #
3 # $Id: update_domaines.sh,v 1.31 2005/08/29 19:21:31 anarcat Exp $
4 # ----------------------------------------------------------------------
5 # AlternC - Web Hosting System
6 # Copyright (C) 2002 by the AlternC Development Team.
7 # http://alternc.org/
8 # ----------------------------------------------------------------------
9 # Based on:
10 # Valentin Lacambre's web hosting softwares: http://altern.org/
11 # ----------------------------------------------------------------------
12 # LICENSE
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License (GPL)
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # To read the license please visit http://www.gnu.org/copyleft/gpl.html
25 # ----------------------------------------------------------------------
26 # Original Author of file: Jerome Moinet for l'Autre Net - 14/12/2000
27 # Purpose of file: service reloading
28 # ----------------------------------------------------------------------
29 #
30 
31 PATH=/sbin:/bin:/usr/sbin:/usr/bin
32 
33 set -e
34 
35 umask 022
36 
37 ########################################################################
38 # Constants & Preliminary checks
39 #
40 
41 DOMAIN_LOG_FILE="/var/log/alternc/update_domains.log"
42 exec >>"$DOMAIN_LOG_FILE" 2>&1
43 
44 if [ `whoami` = 'root' ]; then
45  sudo=""
46 else
47  sudo="sudo"
48 fi
49 
50 apache_reload() {
51  if [ -x /usr/sbin/apache2ctl ]; then
52  $sudo /usr/sbin/apache2ctl graceful || echo "Cannot restart apache"
53  fi
54 }
55 
56 dns_restart() {
57  if [ -x /etc/init.d/bind9 ]; then
58  $sudo /etc/init.d/bind9 restart || echo "Cannot restart dns daemon (bind9)"
59  fi
60 }
61 
62 RELOAD_ZONES="$*"
63 echo $RELOAD_ZONES
64 
65 if [ ! -z "$RELOAD_ZONES" ]; then
66  for zone in $RELOAD_ZONES; do
67  case $zone in
68  "all")
69  $sudo rndc reload || echo "Cannot reload bind"
70  apache_reload # keep for compatibility
71  ;;
72  "apache")
73  apache_reload
74  ;;
75  *)
76  # FIXME: should reload only concerned zones
77  #$sudo rndc reload "$zone" || echo "Cannot reload bind for zone $zone"
78  $sudo rndc reload || echo "Cannot reload bind for zone $zone"
79  ;;
80  esac
81  done
82 fi
83