From 98976e793d6a775665c92cb7c415963bfbb7e36e Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Sat, 10 Aug 2024 07:11:56 +0300 Subject: [PATCH] {bash,zsh}rc: check for existence of hostname{,ctl} as apparently Arch Linux doesn't ship it --- rc/bashrc | 11 ++++++----- rc/zshrc | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/rc/bashrc b/rc/bashrc index 93d55b3b..6abe8cfd 100755 --- a/rc/bashrc +++ b/rc/bashrc @@ -134,8 +134,12 @@ fi if hash lsb_release 2> /dev/null; then ( export LC_ALL="en_DK.UTF-8" - hostname --all-fqdns & - hostname --all-ip-addresses + if hash hostname 2> /dev/null; then + hostname --all-fqdns & + hostname --all-ip-addresses & + elif hash hostnamectl 2> /dev/null; then + hostnamectl hostname & + fi printf "\n" printf "$(uptime --pretty)\t$(uptime)\n" printf "\nPresent:\n" @@ -254,9 +258,6 @@ fi #export CLICOLOR=1 #export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx -# znc uses this variable for figuring out hostname -#export HOSTNAME=$(hostname --fqdn) - # Ensure not leaking queries to upstream nameservers (resolv.conf) export LOCALDOMAIN=. # Secureish resolv.conf options (except trust-ad, but systemd also sets it diff --git a/rc/zshrc b/rc/zshrc index 9a205496..54773abe 100755 --- a/rc/zshrc +++ b/rc/zshrc @@ -31,8 +31,12 @@ fi if hash lsb_release 2> /dev/null; then ( export LC_ALL="en_DK.UTF-8" - hostname --all-fqdns & - hostname --all-ip-addresses + if hash hostname 2> /dev/null; then + hostname --all-fqdns & + hostname --all-ip-addresses & + elif hash hostnamectl 2> /dev/null; then + hostnamectl hostname & + fi printf "\n" printf "$(uptime --pretty)\t$(uptime)\n" printf "\nPresent:\n" @@ -215,9 +219,6 @@ fi #export CLICOLOR=1 #export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx -# znc uses this variable for figuring out hostname -#export HOSTNAME=$(hostname --fqdn) - # Ensure not leaking queries to upstream nameservers (resolv.conf) export LOCALDOMAIN=. # Secureish resolv.conf options (except trust-ad, but systemd also sets it