20 lines
429 B
Bash
20 lines
429 B
Bash
#!/bin/bash
|
|
|
|
HOSTNAME=$1
|
|
|
|
COUNT=`/bin/echo $HOSTNAME|/bin/grep -o '\.'|/usr/bin/wc -l`
|
|
|
|
if [ "$COUNT" -lt '2' ]; then
|
|
# second level domain, don't munge just return
|
|
/bin/echo -n $HOSTNAME
|
|
exit 0
|
|
elif [ "$COUNT" -ge '2' ]; then
|
|
# third or higher level domain, strip first level off
|
|
/bin/echo -n "$HOSTNAME" | /bin/sed 's/[^.]*./\*\./'
|
|
exit 0
|
|
else
|
|
# unexpected. hostname not set?
|
|
/bin/echo -n $HOSTNAME
|
|
exit 0
|
|
fi
|