| 1 | #!/bin/sh |
|---|
| 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 | |
|---|
| 43 | if [ `whoami` = 'root' ]; then |
|---|
| 44 | sudo="env" |
|---|
| 45 | else |
|---|
| 46 | sudo="sudo" |
|---|
| 47 | fi |
|---|
| 48 | |
|---|
| 49 | function apache_reload() { |
|---|
| 50 | if [ -x /usr/sbin/apache2ctl ]; then |
|---|
| 51 | $sudo /usr/sbin/apache2ctl graceful > /dev/null || echo "Cannot restart apache" >> "$DOMAIN_LOG_FILE" |
|---|
| 52 | fi |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | RELOAD_ZONES="$*" |
|---|
| 56 | |
|---|
| 57 | if [ ! -z "$RELOAD_ZONES" ]; then |
|---|
| 58 | for zone in $RELOAD_ZONES; do |
|---|
| 59 | case $zone in |
|---|
| 60 | "all") |
|---|
| 61 | $sudo rndc reload > /dev/null || echo "Cannot reload bind" >> "$DOMAIN_LOG_FILE" |
|---|
| 62 | apache_reload # keep for compatibility |
|---|
| 63 | ;; |
|---|
| 64 | "apache") |
|---|
| 65 | apache_reload |
|---|
| 66 | ;; |
|---|
| 67 | *) |
|---|
| 68 | $sudo rndc reload "$zone" > /dev/null || echo "Cannot reload bind for zone $zone" >> "$DOMAIN_LOG_FILE" |
|---|
| 69 | ;; |
|---|
| 70 | esac |
|---|
| 71 | done |
|---|
| 72 | fi |
|---|
| 73 | |
|---|