zshsrc + zshenv: support hostnamectl iff hostname isn't present
[grml-etc-core.git] / etc / zsh / zshenv
index d696b56..9b70921 100644 (file)
 [[ -r /etc/environment ]] && source /etc/environment
 
 # set environment variables (important for autologin on tty)
-export HOSTNAME=${HOSTNAME:-$(hostname)}
+if [ -n "${HOSTNAME}" ] ; then
+  export HOSTNAME="${HOSTNAME}"
+elif [[ -x $(which hostname) ]] ; then
+  export HOSTNAME="$(hostname)"
+elif [[ -x $(which hostnamectl) ]] ; then
+  export HOSTNAME="$(hostnamectl --static)"
+fi
 
 # make sure /usr/bin/id is available
 if [[ -x /usr/bin/id ]] ; then
@@ -51,8 +57,8 @@ fi
 
 # support extra scripts/software in special directory outside of squashfs environment in live mode
 if [[ -f /etc/grml_cd ]] ; then
-    [[ -r /lib/live/mount/medium/scripts ]] && ADDONS='/lib/live/mount/medium/scripts'
-    [[ -r /etc/grml/my_path ]] && ADDONS="$(cat /etc/grml/my_path)"
+  [[ -r /run/live/medium/scripts ]] && ADDONS='/run/live/medium/scripts'
+  [[ -r /etc/grml/my_path ]] && ADDONS="$(cat /etc/grml/my_path)"
 fi
 
 # Solaris