From 1716d14b235624871213d6620deb7c07621c1cea Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Tue, 17 Jul 2018 18:50:18 +0200 Subject: [PATCH] [cleanup] removing all unused files from former update_domains.sh --- src/functions_dns.sh | 223 -------------------------------------- src/functions_hosting.sh | 225 --------------------------------------- src/update_domains.sh | 170 ----------------------------- 3 files changed, 618 deletions(-) delete mode 100755 src/functions_dns.sh delete mode 100644 src/functions_hosting.sh diff --git a/src/functions_dns.sh b/src/functions_dns.sh deleted file mode 100755 index 7ec2f602..00000000 --- a/src/functions_dns.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/bash -# dns.sh next-gen by Fufroma - -# Init some vars -. /etc/alternc/local.sh -. /usr/lib/alternc/functions.sh - -# Init some other vars -ZONE_TEMPLATE="/etc/alternc/templates/bind/templates/zone.template" -NAMED_TEMPLATE="/etc/alternc/templates/bind/templates/named.template" -NAMED_CONF="/var/lib/alternc/bind/automatic.conf" -RNDC="/usr/sbin/rndc" - -dns_zone_file() { - echo "/var/lib/alternc/bind/zones/$1" -} - -dns_is_locked() { - local domain=$1 - if [ ! -r "$(dns_zone_file $domain)" ] ; then - return 1 - fi - grep "LOCKED:YES" "$(dns_zone_file $domain)" - return $? -} - -dns_get_serial() { - local domain=$1 - local serial=$(( $(grep "; serial" $(dns_zone_file $domain) 2>/dev/null|awk '{ print $1;}') + 1 )) - local serial2=$(date +%Y%m%d00) - if [ $serial -gt $serial2 ] ; then - echo $serial - else - echo $serial2 - fi -} - -dns_get_zonettl() { - local domain=$1 - local zonettl=$( - $MYSQL_DO "SELECT zonettl FROM domaines d WHERE d.domaine='$domain';" - ) - # default value - if [ "$zonettl" == "" ] ; then - zonettl="86400" - fi - if [ "$zonettl" -eq "0" ] ; then - zonettl="86400" - fi - echo $zonettl -} - -dns_chmod() { - local domain=$1 - chgrp bind $(dns_zone_file $domain) - chmod 640 $(dns_zone_file $domain) - return 0 -} - -dns_named_conf() { - local domain=$1 - - if [ ! -f "$(dns_zone_file $domain)" ] ; then - echo Error : no file $(dns_zone_file $domain) - return 1 - fi - - # Add the entry - grep -q "\"${domain/./\\.}\"" "$NAMED_CONF" - if [ $? -ne 0 ] ; then - local tempo=$(cat "$NAMED_TEMPLATE") - tempo=${tempo/@@DOMAINE@@/$domain} - tempo=${tempo/@@ZONE_FILE@@/$(dns_zone_file $domain)} - echo $tempo >> "$NAMED_CONF" - # Kindly ask Bind to reload its configuration - # (the zone file is already created and populated) - $RNDC reconfig - # Hook it ! - run-parts --arg=dns_reconfig --arg="$domain" /usr/lib/alternc/reload.d - fi - -} - -dns_delete() { - local domain=$1 - - # Delete the zone file - if [ -w "$(dns_zone_file $domain)" ] ; then - rm -f "$(dns_zone_file $domain)" - fi - - local reg_domain=${domain/./\\.} - - # Remove from the named conf - local file=$(cat "$NAMED_CONF") - echo -e "$file" |grep -v "\"$reg_domain\"" > "$NAMED_CONF" - - # Remove the conf from openDKIM - rm -rf "/etc/opendkim/keys/$domain" - grep -v "^$reg_domain\$" /etc/opendkim/TrustedHosts >/etc/opendkim/TrustedHosts.alternc-tmp && mv /etc/opendkim/TrustedHosts.alternc-tmp /etc/opendkim/TrustedHosts - grep -v "^alternc\._domainkey\.$reg_domain " /etc/opendkim/KeyTable >/etc/opendkim/KeyTable.alternc-tmp && mv /etc/opendkim/KeyTable.alternc-tmp /etc/opendkim/KeyTable - grep -v "^$domain alternc\._domainkey\.$reg_domain\$" /etc/opendkim/SigningTable >/etc/opendkim/SigningTable.alternc-tmp && mv /etc/opendkim/SigningTable.alternc-tmp /etc/opendkim/SigningTable - - # Ask the dns server for restart - $RNDC reconfig - # Hook it ! - run-parts --arg=dns_reconfig --arg="$domain" /usr/lib/alternc/reload.d -} - -# DNS regenerate -dns_regenerate() { - local domain=$1 - local manual_tag=";;; END ALTERNC AUTOGENERATE CONFIGURATION" - local zone_file=$(dns_zone_file $domain) - - # Check if locked - dns_is_locked "$domain" - if [ $? -eq 0 ]; then - echo "DNS $domain LOCKED" - return 1 - fi - - # Get the serial number if there is one - local serial=$(dns_get_serial "$domain") - - # Get the zone ttl - local zonettl=$(dns_get_zonettl "$domain") - - # Generate the headers with the template - local file=$(cat "$ZONE_TEMPLATE") - - # Add the entry - file=$( - echo -e "$file" - $MYSQL_DO "select distinct replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) as entry from sub_domaines sd,domaines_type dt where sd.type=dt.name and sd.domaine='$domain' and sd.enable in ('ENABLE', 'ENABLED') order by entry ;" - ) - - ##### Mail autodetect for thunderbird / outlook - START - # If $file contain DEFAULT_MX - if [ ! -z "$(echo -e "$file" |egrep 'DEFAULT_MX' )" ] ; then - # If $file ! contain autoconfig -> add entry - if [ -z "$(echo -e "$file" |egrep '^autoconfig' )" ] ; then - file="$(echo -e "$file" ; echo -e "autoconfig IN CNAME $FQDN.\n")" - fi - # if $file ! contain autodiscover -> add entry - if [ -z "$(echo -e "$file" |egrep '^autodiscover' )" ] ; then - file="$(echo -e "$file" ; echo -e "autodiscover IN CNAME $FQDN.\n")" - fi - fi # End if containt DEFAULT_MX - ##### Mail autodetect for thunderbird / outlook - END - - ##### OpenDKIM signature management - START - # If $file contain DEFAULT_MX - if [ ! -z "$(echo -e "$file" |egrep 'DEFAULT_MX' )" ] ; then - # If necessary, we generate the key: - if [ ! -d "/etc/opendkim/keys/$domain" ] ; then - mkdir -p "/etc/opendkim/keys/$domain" - - pushd "/etc/opendkim/keys/$domain" >/dev/null - opendkim-genkey -r -d "$domain" -s "alternc" - chown opendkim:opendkim alternc.private - popd - - local reg_domain=${domain/./\\.} - - grep -q "^$reg_domain\$" /etc/opendkim/TrustedHosts || echo "$domain" >>/etc/opendkim/TrustedHosts - grep -q "^alternc\._domainkey\.$reg_domain " /etc/opendkim/KeyTable || echo "alternc._domainkey.$domain $domain:alternc:/etc/opendkim/keys/$domain/alternc.private" >> /etc/opendkim/KeyTable - grep -q "^$domain alternc\._domainkey\.$reg_domain\$" /etc/opendkim/SigningTable || echo "$domain alternc._domainkey.$domain" >> /etc/opendkim/SigningTable - fi - # we add alternc._domainkey with the proper key - - if [ -r "/etc/opendkim/keys/$domain/alternc.txt" ] ; then - file="$(echo -e "$file" ; cat "/etc/opendkim/keys/$domain/alternc.txt")" - fi - fi - ##### OpenDKIM signature management - END - - # Replace the vars by their values - # Here we can add dynamic value for the default MX - file=$( echo -e "$file" | sed -e " - s/%%fqdn%%/$FQDN/g; - s/%%ns1%%/$NS1_HOSTNAME/g; - s/%%ns2%%/$NS2_HOSTNAME/g; - s/%%DEFAULT_MX%%/$DEFAULT_MX/g; - s/%%DEFAULT_SECONDARY_MX%%/$DEFAULT_SECONDARY_MX/g; - s/@@fqdn@@/$FQDN/g; - s/@@ns1@@/$NS1_HOSTNAME/g; - s/@@ns2@@/$NS2_HOSTNAME/g; - s/@@DEFAULT_MX@@/$DEFAULT_MX/g; - s/@@DEFAULT_SECONDARY_MX@@/$DEFAULT_SECONDARY_MX/g; - s/@@DOMAINE@@/$domain/g; - s/@@SERIAL@@/$serial/g; - s/@@PUBLIC_IP@@/$PUBLIC_IP/g; - s/@@ZONETTL@@/$zonettl/g; - " ) - - # Add the manually entered resource records (after the special tag ;;; END ALTERNC AUTOGENERATE CONFIGURATION) - if [ -r "$zone_file" ] ; then - file=$( - echo -e "$file" - grep -A 10000 "$manual_tag" "$zone_file" - ) - fi - # Add the special tag at the end of the zone, if it is not here yet: - if ! echo -e "$file" | grep -q "$manual_tag" - then - file=$(echo -e "$file"; echo "$manual_tag") - fi - - # Init the file - echo -e "$file" > "$zone_file" - - # And set his rights - dns_chmod $domain - # Add it to named conf - dns_named_conf $domain - - # Hook it ! - run-parts --arg=dns_reload_zone --arg="$domain" /usr/lib/alternc/reload.d - - # ask bind to reload the zone - $RNDC reload $domain -} diff --git a/src/functions_hosting.sh b/src/functions_hosting.sh deleted file mode 100644 index 61bd7207..00000000 --- a/src/functions_hosting.sh +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/bash - -. /usr/lib/alternc/functions.sh - -TEMPLATE_DIR="/etc/alternc/templates/apache2" -HOSTING_DIR="/etc/alternc/functions_hosting" - -HTML_HOME="$ALTERNC_HTML" -VHOST_DIR="/var/lib/alternc/apache-vhost" - -launch_hooks() { - local ACTION=$1 - - if [ ! $2 ] ; then - # If no VTYPE specified - return 0 - fi - - local VTYPE=$2 - - EXITCODE=0 - if [ -x "$HOSTING_DIR/hosting_$VTYPE.sh" ] ; then - # If a specific script exist for this VTYPE, - # we launch it, and return his return code - "$HOSTING_DIR/hosting_$VTYPE.sh" "$1" "$2" "$3" "$4" - EXITCODE=$? - fi - # also launch ssl update domains hook - /usr/lib/alternc/update_certs.sh "$1" "$2" "$3" "$4" - - # No specific script, return 0 - return "$EXITCODE" -} - -host_conffile() { - # Return the absolute path of a conf file for a FQDN - local FQDN="$1" - local U_ID=$(get_uid_by_domain "$FQDN") - local CONFFILE="$VHOST_DIR/${U_ID:(-1)}/$U_ID/$FQDN.conf" - echo $CONFFILE - return 0 -} - -host_create() { - # Function to create a vhost for a website - # First, it look if there is a special file for - # this type of vhost - # If there isn't, it use the default function - # and the template file provided - - local VTYPE="$1" - - launch_hooks "create" "$1" "$2" "$3" "$4" - if [ $? -gt 10 ] ; then - # If the hooks return a value > 10 - # it's mean we do not continue the - # "default" actions - return $? - fi - - # There is no special script, I use the standart template - # If I do not found template manualy define, I look - # If there is an existing template with the good name - - # First, usefull vars. Some may be empty or false, it's - # OK, it will be solve in the "case" below - local FQDN=$2 - local MAIL_ACCOUNT=$3 - local REDIRECT=$4 # Yes, TARGET_DIR and REDIRECT are the same - local TARGET_DIR=$4 # It's used by different template - local U_ID=$(get_uid_by_domain "$FQDN") - local G_ID="$U_ID" - local USER=$(get_account_by_domain $FQDN) - local user_letter=`print_user_letter "$USER"` - local DOCUMENT_ROOT="${HTML_HOME}/${user_letter}/${USER}$TARGET_DIR" - local ACCOUNT_ROOT="${HTML_HOME}/${user_letter}/${USER}/" - local FILE_TARGET=$(host_conffile "$FQDN") - - # In case VTYPE don't have the same name as the template file, - # here we can define it - local TEMPLATE='' - case $VTYPE in -# "example") -# TEMPLATE="$TEMPLATE_DIR/an-example.conf" -# ;; - *) - # No template found, look if there is some in the - # template dir - [ -r "$TEMPLATE_DIR/$VTYPE" ] && TEMPLATE="$TEMPLATE_DIR/$VTYPE" - [ ! "$TEMPLATE" ] && [ -r "$TEMPLATE_DIR/$VTYPE.conf" ] && TEMPLATE="$TEMPLATE_DIR/$VTYPE.conf" - ;; - esac - - # If TEMPLATE is empty, stop right here - [ ! "$TEMPLATE" ] && return 6 - - # Forbid generation for website with UID/GID == 0 - if [[ $U_ID == 0 || $G_ID == 0 ]] ; then - log_error "Fatal error: update_domains/function_dns/host_create : FQDN = $FQDN - TYPE = $VTYPE - UID = $U_ID - GID = $G_ID . Stopping generation" - return 7 - fi - - # Create a new conf file - local TMP_FILE=$(mktemp "/tmp/alternc_host.XXXXXX") - cp "$TEMPLATE" "$TMP_FILE" - - # Substitute special characters : - FQDN2="`echo $FQDN | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" - DOCUMENT_ROOT2="`echo $DOCUMENT_ROOT | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" - ACCOUNT_ROOT2="`echo $ACCOUNT_ROOT | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" - REDIRECT2="`echo $REDIRECT | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" - USER2="`echo $USER | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" - - # Put the good value in the conf file - sed -i \ - -e "s#%%LOGIN%%#$USER#g" \ - -e "s#%%fqdn%%#$FQDN2#g" \ - -e "s#%%document_root%%#$DOCUMENT_ROOT2#g" \ - -e "s#%%account_root%%#$ACCOUNT_ROOT2#g" \ - -e "s#%%redirect%%#$REDIRECT2#g" \ - -e "s#%%UID%%#$U_ID#g" \ - -e "s#%%GID%%#$G_ID#g" \ - -e "s#%%mail_account%%#$MAIL_ACCOUNT#g" \ - -e "s#%%user%%#$USER2#g" \ - $TMP_FILE - - ## Fix for wildcard - if [[ "$FQDN2" == "*."* ]]; then - sed -i "s/ServerName/ServerAlias/" $TMP_FILE - fi - - # Check if all is right in the conf file - # If not, put a debug message -# NO : redirect and document_root COULD contains legitimate %% expressions (...) -# local ISNOTGOOD=$(grep "%%" "$TMP_FILE") -# [ "$ISNOTGOOD" ] && (echo "# There was a probleme in the generation : $ISNOTGOOD" > "$TMP_FILE" ; return 44 ) - - # Put the conf file in prod - mkdir -p "$(dirname "$FILE_TARGET")" - mv -f "$TMP_FILE" "$FILE_TARGET" - - # Execute post-install hooks - launch_hooks "postinst" "$1" "$2" "$3" "$4" - if [ $? -gt 10 ] ; then - # If the hooks return a value > 10 - # it's mean we do not continue the - # "default" actions - return $? - fi - - # All is quit, we return 0 - return 0 -} - -host_disable() { - host_change_enable "disable" "$1" "$2" "$3" "$4" -} - -host_enable() { - host_change_enable "enable" "$1" "$2" "$3" "$4" -} - -host_change_enable() { - # Function to enable or disable a host - local STATE=$1 - - # Execute hooks - launch_hooks "$1" "$2" "$3" "$4" - if [ $? -gt 10 ] ; then - # If the hooks return a value > 10 - # it's mean we do not continue the - # "default" actions - return $? - fi - - local TYPE=$2 # no use here, but one day, maybe... So here he is - local FQDN=$3 - local FENABLED=$(host_conffile "$FQDN") - local FDISABLED="$FENABLED-disabled" - - case $STATE in - "enable") - local SOURCE="$FDISABLED" - local TARGET="$FENABLED" - ;; - "disable") - local TARGET="$FDISABLED" - local SOURCE="$FENABLED" - ;; - *) - return 1 - ;; - esac - - if [ ! -e "$TARGET" ] && [ -e "$SOURCE" ] ; then - # If the "target" file do not exist and the "source" file exist - mv -f "$SOURCE" "$TARGET" - else - return 2 - fi -} - -host_delete() { - local VTYPE=$1 - local FQDN=$2 - # Execute post-install hooks - launch_hooks "delete" "$1" "$2" "$3" "$4" - if [ $? -gt 10 ] ; then - # If the hooks return a value > 10 - # it's mean we do not continue the - # "default" actions - return $? - fi - - # Fix of a longstanding BUG: we only DELETE the vhost file if the type is a vhost one ! - if [ -f "${TEMPLATE_DIR}/${VTYPE}.conf" ] - then - local FENABLED=$(host_conffile "$FQDN") - local FDISABLED="$FENABLED-disabled" - - [ -w "$FENABLED" ] && rm -f "$FENABLED" - [ -w "$FDISABLED" ] && rm -f "$FDISABLED" - fi -} - diff --git a/src/update_domains.sh b/src/update_domains.sh index 3869ac72..403581e6 100755 --- a/src/update_domains.sh +++ b/src/update_domains.sh @@ -3,173 +3,3 @@ /usr/lib/alternc/update_domains.php -exit - -# legacy code here - -PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - -for CONFIG_FILE in \ - /etc/alternc/local.sh \ - /usr/lib/alternc/functions.sh \ - /usr/lib/alternc/functions_hosting.sh \ - /usr/lib/alternc/functions_dns.sh - do - if [ ! -r "$CONFIG_FILE" ]; then - echo "Can't access $CONFIG_FILE." - exit 1 - fi - . "$CONFIG_FILE" -done - -stop_if_jobs_locked - -# Some vars -umask 022 -LOCK_FILE="/usr/share/alternc/panel/cron.lock" # FIXME doesn't seem clean to be here -OLDIFS="$IFS" -NEWIFS=" " -RELOAD_WEB="$(mktemp /tmp/alternc_reload_web.XXXX)" -RELOAD_DNS="$(mktemp /tmp/alternc_reload_dns.XXXX)" -B="ยตยตยงยง" # Strange letters to make split in query - -# Somes check before start operations -if [ `id -u` -ne 0 ]; then - log_error "must be launched as root" -elif [ -z "$DEFAULT_MX" -o -z "$PUBLIC_IP" ]; then - log_error "Bad configuration. Please use: dpkg-reconfigure alternc" -elif [ -f "$LOCK_FILE" ]; then - process=$(ps f -p `cat "$LOCK_FILE"|tail -1`|tail -1|awk '{print $NF;}') - if [ "$(basename $process)" = "$(basename "$0")" ] ; then - log_error "last cron unfinished or stale lock file ($LOCK_FILE)." - else - rm "$LOCK_FILE" - fi -fi - -# backward compatibility: single-server setup -if [ -z "$ALTERNC_SLAVES" ] ; then - ALTERNC_SLAVES="localhost" -fi - -# We lock the application -echo $$ > "$LOCK_FILE" - -echo "" > "$RELOAD_WEB" -echo "" > "$RELOAD_DNS" - -# For domains we want to delete completely, make sure all the tags are all right -# set sub_domaines.web_action = delete where domaines.dns_action = DELETE -mysql_query "update sub_domaines sd, domaines d set sd.web_action = 'DELETE' where sd.domaine = d.domaine and sd.compte=d.compte and d.dns_action = 'DELETE';" - -# Sub_domaines we want to delete -# sub_domaines.web_action = delete -for sub in $( mysql_query "select concat_ws('$B',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine)) from sub_domaines sd where web_action ='DELETE';") ; do - host_delete ${sub/$B/ } - mysql_query "delete from sub_domaines where concat_ws('$B',lower(type), if(length(sub)>0,concat_ws('.',sub,domaine),domaine)) = '$sub' and web_action ='DELETE';" - echo 1 > "$RELOAD_WEB" -done - -# Sub domaines we want to update -# sub_domaines.web_action = update and sub_domains.only_dns = false -IFS="$NEWIFS" -mysql_query " -select concat_ws('$IFS',sd.id, lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), concat_ws('@',m.login,v.value), sd.valeur ) -from sub_domaines sd,membres m,variable v -where sd.compte=m.uid and sd.web_action ='UPDATE' and v.name='mailname_bounce' -;" | while read sdid type domain mail valeur ; do - host_create "$type" "$domain" "$mail" "$valeur" - mysql_query "update sub_domaines sd set web_action='OK',web_result='$?' where sd.id = '$sdid' ; " - echo 1 > "$RELOAD_WEB" -done - -# Domaine to enable -mysql_query "select concat_ws('$IFS',sd.id, lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.valeur) from sub_domaines sd where sd.enable ='ENABLE' ;"|while read sdid type domain valeur ; do - host_enable "$type" "$domain" "$valeur" - mysql_query "update sub_domaines sd set enable='ENABLED' where sd.id = '$sdid' ;" - echo 1 > "$RELOAD_WEB" -done - -# Domains to disable -mysql_query "select concat_ws('$IFS', sd.id, lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.valeur) from sub_domaines sd where sd.enable ='DISABLE' ;"|while read sdid type domain valeur ; do - host_disable "$type" "$domain" "$valeur" - mysql_query "update sub_domaines sd set enable='DISABLED' where sd.id = '$sdid' ;" - echo 1 > "$RELOAD_WEB" -done - -# Domains we do not want to be the DNS serveur anymore : -# domaines.dns_action = UPDATE and domaines.gesdns = 0 -for dom in `mysql_query "select domaine from domaines where dns_action = 'UPDATE' and gesdns = 0;"| tr '\n' ' '` -do - dns_delete $dom - mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'" - echo 1 >"$RELOAD_DNS" -done - -# Domains we have to update the dns : -# domaines.dns_action = UPDATE -for dom in `mysql_query "select domaine from domaines where dns_action = 'UPDATE';" | tr '\n' ' '` -do - echo "dns_regenerate : domain=/$dom/" - dns_regenerate $dom - mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'" - echo 1 >"$RELOAD_DNS" -done - -# Domains we want to delete completely, now we do it -# domaines.dns_action = DELETE -for dom in `mysql_query "select domaine from domaines where dns_action = 'DELETE';" | tr '\n' ' '` -do - dns_delete $dom - # Web configurations have already bean cleaned previously - mysql_query "delete from sub_domaines where domaine='$dom'; delete from domaines where domaine='$dom';" - echo 1 >"$RELOAD_DNS" -done - -if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then - - # Just to encourage user to use THIS directory and not another one - test -d "$VHOST_MANUALCONF" || mkdir -p "$VHOST_MANUALCONF" - - # Concat the apaches files - tempo=$(mktemp "$VHOST_FILE.XXXXX") - - ( - echo "###BEGIN OF ALTERNC AUTO-GENERATED FILE - DO NOT EDIT MANUALLY###" - find "$VHOST_DIR"/ -mindepth 2 -type f -iname "*.conf" -print0 | xargs -0 cat - echo "###END OF ALTERNC AUTO-GENERATED FILE - DO NOT EDIT MANUALLY###" - ) > "$tempo" - - if [ $? -ne 0 ] ; then - log_error " web file concatenation failed" - fi - touch "$VHOST_FILE" - if [ ! -w "$VHOST_FILE" ] ; then - log_error "cannot write on $VHOST_FILE" - fi - mv "$tempo" "$VHOST_FILE" - - # We must reload apache - # we assume we run apache on the master - /usr/lib/alternc/alternc_reload apache || true - # Launch hooks for apache reload - run-parts --arg=web_reload /usr/lib/alternc/reload.d -fi - -# If we added / edited / deleted at least one dns zone file, we go here in the end: -if [ ! -z "$(cat "$RELOAD_DNS")" ] ; then - service opendkim restart - run-parts --arg=dns_reload /usr/lib/alternc/reload.d -fi - -## FIXME : move the slave part into the /usr/lib/alternc/reload.d directory to be an hook -#for slave in $ALTERNC_SLAVES; do -# if [ "$slave" != "localhost" ]; then -# ssh alternc@$slave alternc_reload 'apache' || true -# fi -#done - -rm -f "$LOCK_FILE" "$RELOAD_ZONES" "$RELOAD_WEB" "$INOTIFY_UPDATE_DOMAIN" "$RELOAD_DNS" - -exit 0 -