HAS_TTY='y'
HAS_COLORS="n"
-VERSION="0.5"
+VERSION="0.6"
BASENAME="$(basename ${0})"
BASE_DIR="$(dirname ${0})"
NODENAME=$(hostname -s)
-PURPOSE="Projekt Kunde"
+PURPOSE="Customer project"
DOMAIN=$(hostname --fqdn | cut -d. -f 2- )
-LOCATION="L105"
+LOCATION="L105 / VMWare"
get_ip
HARDWARE=$( uname -p )
OWNER="Publicis Pixelpark GmbH"
COMMENTS=
ZONE="N/A"
OS_NAME=$( cat /etc/os-release | grep '^PRETTY_NAME' | awk -F= '{print $2}' | sed -e 's/^"//' -e 's/"$//' )
-KERNEL=$( uname -r | cut -d. -f1,2,3 )
-CUSTOMER="pixelpark"
+if [[ "${OS_NAME}" =~ Oracle ]] ; then
+ OS_NAME=$( echo "${OS_NAME}" | sed -e 's/ *Linux *Server/Linux/i' )
+elif echo "${OS_NAME}" | grep -q ' 7 ' ; then
+ OS_NAME=$( cat /etc/redhat-release | sed -e 's/ *Linux *release//i' -e 's/ *(Core)//i' )
+fi
+
+PUPPET_CUSTOMER="pixelpark"
+PUPPET_PROJECT="<undefined>"
+PUPPET_ENV="development"
+PUPPET_ROLE="default"
+PUPPET_TIER="production"
+
#------------------------------------------------------------------------------
description() {
Some additional comments to this machine.
-z|--zone ZONE_HOST
The containing zone host of this zone, VM or container, Default: '${ZONE}'.
- -C|--customer HIERA_CUSTOMER
- The hiera customer used for Puppet, Default: '${CUSTOMER}'.
+ -C|--customer PUPPET_CUSTOMER
+ The hiera customer used for Puppet, Default: '${PUPPET_CUSTOMER}'.
+ -P|--project PUPPET_PROJECT
+ The hiera project below the customer used for Puppet, Default: '${PUPPET_PROJECT}'.
+ -E|--env|--environment ENVIRONMENT
+ The Puppet Environment, Default: '${PUPPET_ENV}'.
+ -R|--role ROLE The Puppet Role, Default: '${PUPPET_ROLE}'.
+ -T|--tier TIER The Puppet Tier, Default: '${PUPPET_TIER}'.
-d|--debug Debug output (bash -x).
-v|--verbose Set verbosity on.
--nocolor Don't use colors on display.
local tmp=
local base_dir=
- local short_options="n:p:D:l:i:H:o:e:c:z:C:dvhV"
+ local short_options="n:p:D:l:i:H:o:e:c:z:C:P:E:R:T:dvhV"
local long_options="node:,purpose:,domain:,location:,ip:,hardware:,owner:,"
- long_options+="email:,comments:,zone:,customer:,debug,verbose,nocolor,help,version"
+ long_options+="email:,comments:,zone:,customer:,project:,env:,environment:,role:,"
+ long_options+="tier:,debug,verbose,nocolor,help,version"
set +e
tmp=$( getopt -o "${short_options}" --long "${long_options}" -n "${BASENAME}" -- "$@" )
shift
;;
-C|--customer)
- CUSTOMER="$2"
+ PUPPET_CUSTOMER="$2"
+ shift
+ shift
+ ;;
+ -P|--project)
+ PUPPET_PROJECT="$2"
+ shift
+ shift
+ ;;
+ -E|--env|--environment)
+ PUPPET_ENV="$2"
+ shift
+ shift
+ ;;
+ -R|--role)
+ PUPPET_ROLE="$2"
+ shift
+ shift
+ ;;
+ -T|--tier)
+ PUPPET_TIER="$2"
shift
shift
;;
info "Generating a new ${GREEN}/etc/motd${NORMAL} (Message of the day) ..." >&2
# Texte linke Spalte
- text="Nodename: ${NODENAME}"
+ text="Nodename: ${NODENAME}"
+ left+=("${text}")
+
+ text="Domain: ${DOMAIN}"
left+=("${text}")
- text="Domain: ${DOMAIN}"
+ text="Network: ${IP}"
left+=("${text}")
- text="Network: ${IP}"
+ text="Hardware: ${HARDWARE}"
left+=("${text}")
- text="Hardware: ${HARDWARE}"
+ text="OS: ${OS_NAME}"
left+=("${text}")
- text="OS: ${OS_NAME} (${KERNEL})"
+ text="Puppet Env: ${PUPPET_ENV}"
left+=("${text}")
- text=""
+ text="Puppet Role: ${PUPPET_ROLE}"
+ left+=("${text}")
+
+ text="Puppet Tier: ${PUPPET_TIER}"
left+=("${text}")
# Texte rechte Spalte
text="Zone-Host: ${ZONE}"
right+=("${text}")
- text="Customer: ${CUSTOMER}"
+ text="Customer: ${PUPPET_CUSTOMER}"
+ right+=("${text}")
+
+ text="Project: ${PUPPET_PROJECT}"
right+=("${text}")
local length=
local max_right="1"
local max="1"
+ local no_lines_left="${#left[*]}"
+ local no_lines_right="${#right[*]}"
+ local no_lines="${no_lines_left}"
+ if [[ "${no_lines_right}" -gt "${no_lines_left}" ]] ; then
+ no_lines="${no_lines_right}"
+ fi
+ local text_left=
+ local text_right=
+
for text in "${left[@]}" ; do
length=$( printf "${text}" | wc -c )
if [[ "${length}" -gt "${max_left}" ]] ; then
echo "Max. length right: ${max_right}" >&2
fi
- local i=
- for i in 0 1 2 3 4 5 ; do
- text=$( printf "%-*s %-*s" "${max_left}" "${left[${i}]}" \
- "${max_right}" "${right[${i}]}" )
+ local i=0
+ while [[ "$i" -lt "${no_lines}" ]] ; do
+
+ if [[ "$i" -lt "${no_lines_left}" ]] ; then
+ text_left="${left[${i}]}"
+ else
+ text_left=""
+ fi
+
+ if [[ "$i" -lt "${no_lines_right}" ]] ; then
+ text_right="${right[${i}]}"
+ else
+ text_right=""
+ fi
+
+ i=$(( $i + 1 ))
+
+ text=$( printf "%-*s %-*s" "${max_left}" "${text_left}" \
+ "${max_right}" "${text_right}" )
lines+=("${text}")
length=$( printf "${text}" | wc -c )
if [[ "${length}" -gt "${max}" ]] ; then
max="${length}"
fi
+
done
+
if [[ -n "${COMMENTS}" ]] ; then
text="Comments: ${COMMENTS}"
lines+=("${text}")
max="${length}"
fi
fi
+
if [[ "${VERBOSE}" == "y" ]] ; then
echo "Max. line length: ${max}" >&2
fi