From a86fc3fc37f9617ef175aee52c3bbe6d0cff957a Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 21 Jan 2013 10:59:48 -0500 Subject: [PATCH] new script to take a domain name off of a fully qualified hostname. --- scripts/networking/prune_domain.sh | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 scripts/networking/prune_domain.sh 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