#!/bin/sh
#
# linbo_hostname [-f|--full] | [-h|help|--help]
# prints hostname
# thomas@linuxmuster.net
# 20250421
#

usage(){
  echo
  echo "Prints hostname."
  echo
  echo "Usage: linbo_hostname [-f|--full] | [-h|help|--help]"
  echo
  exit 0
}

# print help
[ "$1" = "help" ] && usage

# get environment
source /usr/share/linbo/shell_functions

if localmode; then
  linbo_mountcache &> /dev/null
  [ -s /cache/hostname ] || exit 1
  FQDN="$(cat /cache/hostname)"
  HOSTNAME="${FQDN%%.*}"
fi

case "$1" in
  -f|--full) echo "$FQDN" ;;
  *) echo "$HOSTNAME" ;;
esac

exit 0
