summaryrefslogtreecommitdiff
path: root/templates/system
diff options
context:
space:
mode:
Diffstat (limited to 'templates/system')
-rw-r--r--templates/system/host-name/node.def21
-rw-r--r--templates/system/static-host-mapping/host-name/node.def7
-rw-r--r--templates/system/static-host-mapping/host-name/node.tag/alias/node.def15
-rw-r--r--templates/system/static-host-mapping/host-name/node.tag/inet/node.def14
4 files changed, 16 insertions, 41 deletions
diff --git a/templates/system/host-name/node.def b/templates/system/host-name/node.def
index aeed3986..e1370b70 100644
--- a/templates/system/host-name/node.def
+++ b/templates/system/host-name/node.def
@@ -2,21 +2,18 @@ type: txt
help: "Configure system host name"
default: "vyatta"
syntax: pattern $(@) "^[-a-zA-Z0-9.]+$" ; "invalid host name $(@)"
-# do we need to add ntpd restart here?
update: "sudo sh -c \"hostname '$(@)' && \
+echo '$(@)' > /etc/hostname && \
touch /etc/hosts && \
-sed -i '/localhost/d' /etc/hosts && \
-echo \\\"127.0.0.1\t localhost $(@)\t #vyatta entry\\\" >> /etc/hosts && \
+sed -i '/^127.0.1.1/d' /etc/hosts && \
+echo \\\"127.0.1.1\t $(@)\t #vyatta entry\\\" >> /etc/hosts && \
if [ x$(../domain-name/@) != x ]; then \
-echo \\\"127.0.0.1\t localhost $(@).$(../domain-name/@)\t #vyatta entry\\\" \
+echo \\\"127.0.1.1\t $(@).$(../domain-name/@)\t #vyatta entry\\\" \
>> /etc/hosts; fi\" "
-# do we need to add ntpd restart here?
-delete: "sudo sh -c \"echo > /etc/hostname.conf && hostname 'vyatta' && \
+delete: "sudo sh -c \"echo 'vyatta' > /etc/hostname && hostname 'vyatta' && \
touch /etc/hosts && \
-sed -i '/localhost.*#vyatta entry/d' /etc/hosts && \
-echo \\\"127.0.0.1\t localhost vyatta\t #vyatta entry\\\" >> /etc/hosts && \
+sed -i '/^127.0.1.1/d' /etc/hosts && \
+echo \\\"127.0.1.1\t vyatta\t #vyatta entry\\\" >> /etc/hosts && \
if [ x$(../domain-name/@) != x ]; then \
-echo \\\"127.0.0.1\t localhost vyatta.$(../domain-name/@)\t #vyatta entry\\\" \
->> /etc/hosts; fi && \
-if [ -f /etc/ntp/ntp.conf ] && grep -q 'server' /etc/ntp/ntp.conf; then \
-/opt/vyatta/sbin/ntpd.init restart; fi\" "
+echo \\\"127.0.1.1\t vyatta.$(../domain-name/@)\t #vyatta entry\\\" \
+>> /etc/hosts; fi\" "
diff --git a/templates/system/static-host-mapping/host-name/node.def b/templates/system/static-host-mapping/host-name/node.def
index ea0000af..275aa867 100644
--- a/templates/system/static-host-mapping/host-name/node.def
+++ b/templates/system/static-host-mapping/host-name/node.def
@@ -2,3 +2,10 @@ tag:
type: txt
help: "Map DNS names to system interfaces"
syntax: pattern $(@) "^[-a-zA-Z0-9.]+$" ; "invalid host name $(@)"
+commit: $(./inet) != ""; "IP address for the static mapping must be set"
+end: "sudo sh -c \"\
+ touch /etc/hosts; \
+ sed -i '/ $(@) .*#vyatta entry/d' /etc/hosts; \
+ if [ -z \"$(./inet/@)\" ]; then exit 0; fi; \
+ declare -a aliases=( $(alias/@@) ); \
+ echo \\\"$(inet/@)\t $(@) \\\\\${aliases[*]} \t #vyatta entry\\\" \ >> /etc/hosts\" "
diff --git a/templates/system/static-host-mapping/host-name/node.tag/alias/node.def b/templates/system/static-host-mapping/host-name/node.tag/alias/node.def
index c8f5cdef..e9f1de7c 100644
--- a/templates/system/static-host-mapping/host-name/node.tag/alias/node.def
+++ b/templates/system/static-host-mapping/host-name/node.tag/alias/node.def
@@ -1,18 +1,3 @@
multi:
type: txt
help: "Alias for this address"
-update: "sudo sh -c \"touch /etc/hosts && \
-sed -i '/$(../@).*#vyatta entry/d;/127\\.0\\.0\\.1.*#vyatta entry/d' \
- /etc/hosts && \
-echo \\\"$(../inet/@)\t $(../@) $(@) \t #vyatta entry\\\" \
- >> /etc/hosts && \
-if [ x$(../../../domain-name/@) == x ]; then \
- echo \\\"127.0.0.1\t localhost $(../../../host-name/@)\t #vyatta entry\\\" \
- >> /etc/hosts; \
-else \
- echo \\\"127.0.0.1\t localhost \
-$(../../../host-name/@).$(../../../domain-name/@)\t #vyatta entry\\\" \
- >> /etc/hosts; \
-fi\" "
-delete: "sudo sh -c \"touch /etc/hosts && \
-sed -i '/ $(../@) .*#vyatta entry/{/localhost/!d}' /etc/hosts\" "
diff --git a/templates/system/static-host-mapping/host-name/node.tag/inet/node.def b/templates/system/static-host-mapping/host-name/node.tag/inet/node.def
index 47a84733..4a069d9e 100644
--- a/templates/system/static-host-mapping/host-name/node.tag/inet/node.def
+++ b/templates/system/static-host-mapping/host-name/node.tag/inet/node.def
@@ -1,16 +1,2 @@
type: ipv4
help: "Internet address"
-update: "sudo sh -c \"touch /etc/hosts && \
-sed -i '/$(../@).*#vyatta entry/d;/127\\.0\\.0\\.1.*#vyatta entry/d' \
- /etc/hosts && \
-echo \\\"$(@)\t $(../@) \t #vyatta entry\\\" >> /etc/hosts && \
-if [ x$(../../../domain-name/@) == x ]; then \
- echo \\\"127.0.0.1\t localhost $(../../../host-name/@)\t #vyatta entry\\\" \
- >> /etc/hosts; \
-else \
- echo \\\"127.0.0.1\t localhost \
-$(../../../host-name/@).$(../../../domain-name/@)\t #vyatta entry\\\" \
- >> /etc/hosts; \
-fi\" "
-delete: "sudo sh -c \"touch /etc/hosts && \
-sed -i '/ $(../@) .*#vyatta entry/{/localhost/!d}' /etc/hosts\" "