]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Setting hostname and disabling IPv6 in bin/postinst
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 28 Mar 2018 09:31:50 +0000 (11:31 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 28 Mar 2018 09:31:50 +0000 (11:31 +0200)
bin/postinst

index 8ae38832943dc2f4ce2d37d09bf38e84081ae754..daff7ac34d3e7eea9a94287dbf89799f6068f7da 100644 (file)
@@ -101,12 +101,37 @@ create_etc_hosts() {
 
 }
 
+#-----------------------------------------------------------
+set_hostname() {
+    echo
+    log "Setting hostname ${hostname} ..."
+    hostnamectl set-hostname --static "${hostname}"
+    hostname > /etc/hostname
+    echo "Hostname normal:  $(hostname)"
+    echo "Hostname simple:  $(hostname -s)"
+    echo "Hostname FQDN:    $(hostname -f)"
+}
+
+#-----------------------------------------------------------
+disable_ipv6() {
+    local sysctl_file="/etc/sysctl.d/99-disable-ipv6.conf"
+    echo
+    log "Disabling IPv6 in '${sysctl_file}' ..."
+    mkdir -pv /etc/sysctl.d
+    echo "#disable ipv6" | tee -a "${sysctl_file}"
+    echo "net.ipv6.conf.all.disable_ipv6 = 1" | tee -a "${sysctl_file}"
+    echo "net.ipv6.conf.default.disable_ipv6 = 1" | tee -a "${sysctl_file}"
+    echo "net.ipv6.conf.lo.disable_ipv6 = 1" | tee -a "${sysctl_file}"
+}
+
 #-----------------------------------------------------------
 main() {
 
     create_authkeys
     import_ssh_hostkeys
     create_etc_hosts
+    set_hostname
+    disable_ipv6
 
 }