From: Chris Koeritz Date: Mon, 21 Jan 2013 15:59:48 +0000 (-0500) Subject: new script to take a domain name off of a fully qualified hostname. X-Git-Tag: 2.140.90~1138 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=a86fc3fc37f9617ef175aee52c3bbe6d0cff957a;p=feisty_meow.git new script to take a domain name off of a fully qualified hostname. --- diff --git a/scripts/networking/prune_domain.sh b/scripts/networking/prune_domain.sh new file mode 100644 index 00000000..3b06f74c --- /dev/null +++ b/scripts/networking/prune_domain.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# takes the domain name off of the hostname provided and outputs just the +# short name for the host. the host is the first parameter, and the domain +# name is the second, but both are optional. if missing, this script uses +# the local machine's information to print a hostname stripped of domain. + +source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" + +#ha, should look back and see what other cool stuff hecho used to do. +function hecho() +{ + echo $* 1>&2 +} + +export host="$1"; shift +if [ -z "$host" ]; then + host="$(hostname)" +fi +export DOMAIN_NAME="$1"; shift +if [ -z "$DOMAIN_NAME" ]; then + # set the domain name based on what's found in the resolv.conf file, where + # dns info is often found. + DOMAIN_NAME=$(grep -i search