diff --git a/.gitattributes b/.gitattributes index 8bbabb15..d8d558fe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -356,9 +356,9 @@ etc/alternc/phpmyadmin.inc.php -text etc/alternc/postfix-slave.cf -text etc/alternc/postfix.cf -text etc/alternc/templates/alternc/bureau.conf -text +etc/alternc/templates/apache2/local.conf -text etc/alternc/templates/apache2/panel.conf -text etc/alternc/templates/apache2/redirect.conf -text -etc/alternc/templates/apache2/vhost.conf -text etc/alternc/templates/apache2/webmail.conf -text etc/alternc/templates/bind/automatic.conf -text etc/alternc/templates/bind/named.conf.options -text diff --git a/etc/alternc/templates/apache2/vhost.conf b/etc/alternc/templates/apache2/local.conf similarity index 100% rename from etc/alternc/templates/apache2/vhost.conf rename to etc/alternc/templates/apache2/local.conf diff --git a/install/upgrades/1.0.sql b/install/upgrades/1.0.sql index 0b1d1bbb..28f05582 100644 --- a/install/upgrades/1.0.sql +++ b/install/upgrades/1.0.sql @@ -34,7 +34,7 @@ INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibil -- TODO modify mysql.sh to add this changes alter table domaines add column dns_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE'; alter table domaines add column dns_result varchar(255) not null default ''; -alter table sub_domaines add column web_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE'; +alter table sub_domaines add column web_action enum ('OK','UPDATE','ENABLE','DISABLE','DELETE') NOT NULL default 'UPDATE'; alter table sub add column dns_result varchar(255) not null default ''; drop table sub_domaines_standby; drop table domaines_standby; diff --git a/src/functions.sh b/src/functions.sh index aeef9a93..95dc6e30 100755 --- a/src/functions.sh +++ b/src/functions.sh @@ -7,6 +7,7 @@ # Init some other vars MYSQL_DO="/usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -Bs -e " DOMAIN_LOG_FILE="/var/log/alternc/update_domains.log" +VHOST_FILE="$VHOST_DIR/vhosts_all.conf" # Some usefull miscellaneous shell functions print_domain_letter() { diff --git a/src/hosting_functions_v2.sh b/src/hosting_functions_v2.sh index eb7d175e..51121a92 100644 --- a/src/hosting_functions_v2.sh +++ b/src/hosting_functions_v2.sh @@ -134,7 +134,7 @@ host_change_enable() { if [ ! -e "$TARGET" ] && [ -e "$SOURCE" ] ; then # If the "target" file do not exist and the "source" file exist - rename -f "$SOURCE" "$TARGET" + mv -f "$SOURCE" "$TARGET" else return 2 fi diff --git a/src/update_domains.sh b/src/update_domains.sh index b50816f1..e1275896 100644 --- a/src/update_domains.sh +++ b/src/update_domains.sh @@ -43,8 +43,7 @@ $MYSQL_DO "update sub_domaines sd, domaines d set sd.web_action = 'DELETE' where # Sub_domaines we want to delete # sub_domaines.web_action = delete for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where web_action ='DELETE';") ; do - echo $sub - # TODO Do the conf + host_delete $sub # TODO Update the entry in the DB with the result and the action done @@ -58,11 +57,21 @@ params=$( $MYSQL_DO " and dt.only_dns = false ;") for sub in $params;do - echo host_create $(echo $sub|tr '|µ' ' ') host_create $(echo $sub|tr '|µ' ' ') # TODO Update the entry in the DB with the result and the action done -unset IFS + +# Domaine to enable +for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='ENABLE' ;");do + host_enable $sub + # TODO Update the entry in the DB with the result and the action +done + +# Domains to disable +for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='DISABLE' ;");do + host_disable $sub + # TODO Update the entry in the DB with the result and the action +done # Domains we do not want to be the DNS serveur anymore : # domaines.dns_action = UPDATE and domaines.gesdns = 0 @@ -87,21 +96,23 @@ for dom in $( $MYSQL_DO "select domaine from domaines where dns_action = 'DELETE done -echo Exitbefore reload everything, we are testing, FUCK -rm "$LOCK_FILE" -exit 1 # Concat the apaches files -local tempo=$(mktemp /tmp/alternc-vhost.XXXXX) -find "$VHOST_DIR" -type f -iname "*.conf" -exec cat '{}' >> "$tempo" \; +tempo=$(mktemp /tmp/alternc-vhost.XXXXX) +find "$VHOST_DIR" -mindepth 2 -type f -iname "*.conf" -exec cat '{}' > "$tempo" \; if [ $? -ne 0 ] ; then log_error " web file concatenation failed" fi -if [ ! -w "$VHOST_FILE" ] ; then +touch "$VHOST_FILE" +if [ ! -w "$VHOST_FILE" ] ; then log_error "cannot write on $VHOST_FILE" fi mv "$tempo" "$VHOST_FILE" +echo Exitbefore reload everything, we are testing, FUCK +rm "$LOCK_FILE" +exit 1 + # Reload web and dns alternc_reload all