Ajout : vm_hosted : rule_nsd3_configure .
[lhc/ateliers.git] / vm_hosted
index 11dd8bb..91ec25a 100755 (executable)
--- a/vm_hosted
+++ b/vm_hosted
@@ -780,34 +780,6 @@ rule_network_configure () {
                    pre-down  ip address delete $vm_ipv4/32 dev \$IFACE
                EOF
  }
-rule_www_configure () {
-       rule adduser www \
-        --disabled-login \
-        --disabled-password \
-        --group \
-        --home /home/www \
-        --shell /bin/false \
-        --system
-       rule adduser log-www \
-        --disabled-login \
-        --disabled-password \
-        --group \
-        --home /home/www/log \
-        --shell /bin/false \
-        --system
-       #sudo adduser www www-data
-       sudo adduser www log-www
-       #sudo adduser log log-www
-       usermod --home /home/www/pub www-data
-       sudo install -d -m 751 -o www -g www \
-        /home/www
-       sudo install -d -m 750 -o www -g www \
-        /home/www/etc
-       sudo install -d -m 1771 -o www-data -g www-data \
-        /home/www/pub
-       sudo install -d -m 1771 -o log-www -g log-www \
-        /home/www/log
- }
 rule_nginx_configure () {
        local -; set +f
        rule apt_get_install nginx
@@ -889,6 +861,48 @@ rule_nginx_configure () {
                #       de leurs groupes supplĂ©mentaires.
        sudo service nginx restart
  }
+rule_nsd3_configure () { # NOTE: DNS autoritaire uniquement
+       local -; set +f
+       rule apt_get_install nsd m4
+       sudo rm -rf \
+        /etc/nsd3/zone.d
+       sudo install -d -m 750 -o root -g nsd \
+        /etc/nsd3/zone.d
+       {
+               cat <<-EOF
+                       server:
+                               ip-address: $vm_ipv4
+                               ip4-only: yes
+                       EOF
+               cat "$tool"/etc/nsd3/nsd.conf
+               local conf
+               for conf in "$tool"/etc/nsd3/zone.d/*.conf
+                do conf=${conf#"$tool"/etc/nsd3/zone.d/}
+                       local domain=${conf%.conf}
+                       if test -e "$tool"/etc/nsd3/zone.d/"$domain".zone.m4
+                        then m4 \
+                                --define=ZONE_DOMAIN=$domain \
+                                --define=ZONE_SERIAL=$(cd "$tool" && git log -1 --format="%ct" -- etc/nsd3/zone.d/"$domain".zone.m4) \
+                                --define=VM_IP4=$vm_ipv4 \
+                                       "$tool"/etc/nsd3/zone.d/"$domain".zone.m4
+                        else cat "$tool"/etc/nsd3/zone.d/"$domain".zone
+                        fi |
+                       sudo install -m 440 -o root -g nsd /dev/stdin \
+                        /etc/nsd3/zone.d/"$domain".zone
+                       sudo install -m 440 -o root -g nsd \
+                        "$tool"/etc/nsd3/zone.d/"$conf" \
+                               /etc/nsd3/zone.d/"$conf"
+                       cat <<-EOF
+                               zone:
+                                       name: $domain
+                                       zonefile: /etc/nsd3/zone.d/$domain.zone
+                               EOF
+                done
+       } |
+       sudo install -m 640 -o root -g nsd /dev/stdin \
+        /etc/nsd3/nsd.conf
+       sudo service nsd3 restart
+ }
 rule_php5_fpm_configure () {
        local -; set +f
        rule apt_get_install \
@@ -1395,6 +1409,34 @@ rule_user_root_configure () {
         do sudo gpg --import "$key"
         done
  }
+rule_www_configure () {
+       rule adduser www \
+        --disabled-login \
+        --disabled-password \
+        --group \
+        --home /home/www \
+        --shell /bin/false \
+        --system
+       rule adduser log-www \
+        --disabled-login \
+        --disabled-password \
+        --group \
+        --home /home/www/log \
+        --shell /bin/false \
+        --system
+       #sudo adduser www www-data
+       sudo adduser www log-www
+       #sudo adduser log log-www
+       usermod --home /home/www/pub www-data
+       sudo install -d -m 751 -o www -g www \
+        /home/www
+       sudo install -d -m 750 -o www -g www \
+        /home/www/etc
+       sudo install -d -m 1771 -o www-data -g www-data \
+        /home/www/pub
+       sudo install -d -m 1771 -o log-www -g log-www \
+        /home/www/log
+ }
 rule_configure () {
        rule apt_configure
        rule git_configure
@@ -1415,6 +1457,7 @@ rule_configure () {
        rule php5_fpm_configure
        rule nginx_configure
        #rule apache2_configure
+       rule nsd3_configure
        rule runit_configure
  }