Skip to content

Instantly share code, notes, and snippets.

@boardstretcher
Created April 11, 2019 13:24
Show Gist options
  • Save boardstretcher/906568cb395e13285bf802d18cf03acc to your computer and use it in GitHub Desktop.
Save boardstretcher/906568cb395e13285bf802d18cf03acc to your computer and use it in GitHub Desktop.
#!/bin/bash
function one () {
echo 'RUN: function 1'
}
function two () {
echo 'RUN: function 2'
}
function three () {
echo 'RUN: function 3'
}
DOMAIN=$(hostname -d)
if [ -z "$DOMAIN" ]
then
echo "ERROR: domain variable is null"
exit 1
fi
if [[ $HOSTNAME =~ .*01$ ]]; then HOSTCAT=1; fi
if [[ $HOSTNAME =~ .*02$ ]]; then HOSTCAT=2; fi
if [[ $HOSTNAME =~ .*03$ ]]; then HOSTCAT=3; fi
case $HOSTCAT in
1) one;;
2) two;;
3) three;;
*) echo "UNKNOWN CASE" && exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment