Add systemd-friendly hostname settings to drone and generic host setup.
authorChris Sharp <csharp@georgialibraries.org>
Thu, 29 Jun 2017 16:01:32 +0000 (12:01 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 29 Jun 2017 16:01:32 +0000 (12:01 -0400)
templates/setup-drone.sh
templates/setup.sh

index d02d8a7..eced7c8 100755 (executable)
@@ -67,7 +67,16 @@ echo
 echo $(date) >> "$INSTALL_LOG"
 echo "Setting Hostname"
 sleep 2
-echo "drone_file" > /etc/hostname
+# supported Debian releases and Ubuntu 16.04 are on systemd
+# so check to see if we're running 14.04, otherwise, we're 
+# on a systemd-based system
+#Get_OS_Distro
+if [ "$OSDISTRO" == "Ubuntu" ] && [ "$OSRELEASE" == "14.04" ]; then
+    echo "drone_file" > /etc/hostname
+    start hostname
+else
+    hostnamectl set-hostname "drone_file"
+fi
 tar zxvf drone_file_etc-hosts.tar.gz -C /
 sed -i 's/^domain.*/domain CLUSTER_DOMAINNAME/g' /etc/resolv.conf
 sed -i 's/^search.*/search CLUSTER_DOMAINNAME/g' /etc/resolv.conf
index 15ef8e1..97691c2 100755 (executable)
@@ -62,17 +62,16 @@ echo
 ### Set hostname.
 echo "Setting Hostname"
 sleep 2
-echo "tar_file" > /etc/hostname
-# Get_OS_Distro
-if [ "$OSDISTRO" == "Ubuntu" ] 
-       then
-       start hostname
-               else
-               /etc/init.d/hostname.sh 
+# supported Debian releases and Ubuntu 16.04 are on systemd
+# so check to see if we're running 14.04, otherwise, we're 
+# on a systemd-based system
+#Get_OS_Distro
+if [ "$OSDISTRO" == "Ubuntu" ] && [ "$OSRELEASE" == "14.04" ]; then
+    echo "tar_file" > /etc/hostname
+    start hostname
+else
+    hostnamectl set-hostname "tar_file"
 fi
-               
-               
-
 
 ### xtract /etc/hosts files.
 echo "Files Installed"