#!/bin/bash
#
# Author: Frank Brehm <frank.brehm@pixelpark.com>
-#
-
#
# Generating /etc/motd like:
#
-# +----------------------------------------------------------------+
-# | Nodename: cobbler Purpose: VMWare Template |
-# | Domain: pixelpark.com Location: L105 / VMWare |
-# | Network: 192.168.88.8 Owner: Digitas Pixelpark GmbH |
-# | Hardware: vmware (x86_64) Contact: 8x5@pixelpark.com |
-# | OS: CentOS 7.9.2009 Zone-Host: N/A |
-# | Puppet Env: test Customer: pixelpark |
-# | Puppet Role: default Project: <undefined> |
-# | Puppet Tier: production |
-# +----------------------------------------------------------------+
+# +------------------------------------------------------------------------------------+
+# | Nodename : template-rhel9 Purpose : VMWare Template |
+# | Domain : pixelpark.com Location : L105 / VMWare |
+# | Network : 192.168.145.50 Owner : Digitas Pixelpark GmbH |
+# | Hardware : vmware (x86_64 Intel) Contact : solution@pixelpark.com |
+# | OS : Red Hat Enterprise Linux 9.2 (Plow) Zone-Host: test/test-vmcc-l105-01 |
+# | Puppet-Env : development Customer : pixelpark |
+# | Puppet-Role: dpx_infra::cobbler_tst Project : <undefined> |
+# | Puppet-Tier: development |
+# | Puppet-Cert: template-rhel9.pixelpark.com |
+# +------------------------------------------------------------------------------------+
#
set -e
DEBUG="n"
QUIET='n'
-VERSION="0.10.0"
+VERSION="0.11.0"
BASENAME="$(basename ${0})"
BASE_DIR="$(dirname ${0})"
OWNER="Digitas Pixelpark GmbH"
CONTACT="solution@pixelpark.com"
COMMENTS=
-ZONE="N/A"
+ZONE="test/test-vmcc-l105-01"
OS_NAME=$( cat /etc/os-release | grep '^PRETTY_NAME' | awk -F= '{print $2}' | sed -e 's/^"//' -e 's/"$//' )
if [[ "${OS_NAME}" =~ Oracle ]] ; then
OS_NAME=$( echo "${OS_NAME}" | sed -e 's/ *Linux *Server/Linux/i' )
PUPPET_ENV="${system_status:-development}"
PUPPET_ROLE="default"
PUPPET_TIER="production"
+PUPPET_CERT="${NODENAME}.${DOMAIN}"
#------------------------------------------------------------------------------
description() {
set -x
fi
+ PUPPET_CERT="${NODENAME}.${DOMAIN}"
+
}
#########################################
text="OS: ${OS_NAME}"
left+=("${text}")
- text="Puppet Env: ${PUPPET_ENV}"
+ text="Puppet-Env: ${PUPPET_ENV}"
+ left+=("${text}")
+
+ text="Puppet-Role: ${PUPPET_ROLE}"
left+=("${text}")
- text="Puppet Role: ${PUPPET_ROLE}"
+ text="Puppet-Tier: ${PUPPET_TIER}"
left+=("${text}")
- text="Puppet Tier: ${PUPPET_TIER}"
+ text="Puppet-Cert: ${PUPPET_CERT}"
left+=("${text}")
# Texte rechte Spalte
echo "Using snippet $dist_upgrade_snippet"
$SNIPPET($dist_upgrade_snippet)
+#set $create_motd_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.300.create-motd.sh"
+echo
+echo "Using snippet $create_motd_snippet"
+$SNIPPET($create_motd_snippet)
+
#set $this_snippet= "per_status/" + $SYSTEM_STATUS + "/tpl.320.root-ssh-login.sh"
echo
echo "Using snippet $this_snippet"
$SNIPPET($this_snippet)
-# ###########################
-# Seems to be finished
+#set $chrony_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.400.chrony.sh"
+echo
+echo "Using snippet $chrony_snippet"
+$SNIPPET($chrony_snippet)
+
+#set $puppet_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.450.puppet.sh"
+echo
+echo "Using snippet $puppet_snippet"
+$SNIPPET($puppet_snippet)
+
+#set $logrotate_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.500.logrotate.sh"
+echo
+echo "Using snippet $logrotate_snippet"
+$SNIPPET($logrotate_snippet)
+
+## ###########################
+## Sees to be finished
+
+#set $finish_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.999.finish.sh"
+echo
+echo "Using snippet $finish_snippet"
+$SNIPPET($finish_snippet)
%end
#-----------------------------------------------------------
create_motd() {
+ local rhsm='/usr/sbin/subscription-manager'
+
echo -e "\e[0Ksection_start:$( date +%s ):ks_create_motd\r\e[0KCreating initial MOTD ..."
echo
echo "${HASH_LINE}"
fi
rm -fv "${mk_script}"
+ if [[ -d "/etc/motd.d" ]] ; then
+ echo "Cleaning up /etc/motd.d ..."
+ ls -l -A /etc/motd.d
+ local mfile=
+ for mfile in /etc/motd.d/* ; do
+ if [[ ! -f "${mfile}" && ! -L "${mfile}" ]] ; then
+ continue
+ fi
+ rm -fv "${mfile}"
+ done
+
+ if [[ -x "${rhsm}" ]] ; then
+ if [[ "${rhsm_registred}" ]] ; then
+ local rhsm_consumed=$( LC_TIME=de_DE.UTF-8 ${rhsm} list --consumed )
+ local sub_name=$( echo "${rhsm_consumed}" | \
+ grep -i '^Subscription Name:' | sed -e 's/^Subscription Name: *//' )
+ local till=$( echo "${rhsm_consumed}" | \
+ grep -i '^Ends:' | sed -e 's/^Ends: *//' )
+ echo "Subscription: ${sub_name}, ends: ${till}" | tee /etc/motd.d/sunscription
+ else
+ echo "The system has no subscription." | tee /etc/motd.d/sunscription
+ fi
+ fi
+ fi
+
echo -e "\e[0Ksection_end:$( date +%s ):ks_create_motd\r\e[0K"
}