#raw
HASH_LINE="#######################################################################################"
-COBBLER_URL="http://cobbler.pixelpark.com"
echo "$(date --rfc-3339=seconds): Das ist das Post-Install-Script '$0'."
echo
head -n 1 | \
awk '{print $2}' | \
sed -e 's/:$//' )
+
IP_ADDRESS_ETH0=$( ip -oneline addr show dev "${DEVNAME_ETH0}" | \
grep ' inet ' | \
head -n 1 | \
awk '{print $4}' | \
sed -e 's|/.*||' )
+
+NETMASK_INT_ETH0=$( ip -oneline addr show dev "${DEVNAME_ETH0}" | \
+ grep ' inet ' | \
+ head -n 1 | \
+ awk '{print $4}' | \
+ sed -e 's|.*/||' )
+
+case "${NETMASK_INT_ETH0}" in
+ 20)
+ NETMASK_ETH0='255.255.240.0'
+ ;;
+ 21)
+ NETMASK_ETH0='255.255.248.0'
+ ;;
+ 22)
+ NETMASK_ETH0='255.255.252.0'
+ ;;
+ 23)
+ NETMASK_ETH0='255.255.254.0'
+ ;;
+ 24)
+ NETMASK_ETH0='255.255.255.0'
+ ;;
+ 25)
+ NETMASK_ETH0='255.255.255.128'
+ ;;
+ 26)
+ NETMASK_ETH0='255.255.255.192'
+ ;;
+ 27)
+ NETMASK_ETH0='255.255.255.224'
+ ;;
+ 28)
+ NETMASK_ETH0='255.255.255.240'
+ ;;
+ 29)
+ NETMASK_ETH0='255.255.255.248'
+ ;;
+ 30)
+ NETMASK_ETH0='255.255.255.252'
+ ;;
+ 31)
+ NETMASK_ETH0='255.255.255.254'
+ ;;
+ 32)
+ NETMASK_ETH0='255.255.255.255'
+ ;;
+ *)
+ NETMASK_ETH0='255.255.255.255'
+ ;;
+esac
+
GATEWAY=$( ip -oneline route show | grep ^default | head -n 1 | awk '{print $3}' )
DOMAIN=$( echo "${hostname}" | sed -e 's/^[^\.]*\.//' )
SIMPLE_HOSTNAME=$( echo "${hostname}" | sed -e 's/\..*//' )
echo " \$mac_address_eth0: $mac_address_eth0"
echo " \$ip_address_eth0: $ip_address_eth0"
echo " \$IP_ADDRESS_ETH0: $IP_ADDRESS_ETH0"
+echo " \$NETMASK_INT_ETH0: $NETMASK_INT_ETH0"
+echo " \$NETMASK_ETH0: $NETMASK_ETH0"
echo " \$SIMPLE_HOSTNAME: $SIMPLE_HOSTNAME"
echo " \$DOMAIN: $DOMAIN"
+echo " \$cobbler_url: $cobbler_url"
#-----------------------------------------------------------
log() {
echo "${HASH_LINE}"
echo "Calling create_authkeys() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/keys/auth_keys_pp_betrieb"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/keys/auth_keys_pp_betrieb"
log "Creating /root/.ssh ..."
mkdir -pv /root/.ssh
NETBOOT=yes
UUID="${if_uuid}"
IPV6INIT=yes
- BOOTPROTO=dhcp
+ BOOTPROTO=none
TYPE=Ethernet
+ USERCTL=no
+ IPADDR=${IP_ADDRESS_ETH0}
+ NETMASK=${NETMASK_ETH0}
+ PREFIX=${NETMASK_INT_ETH0}
+ IPV4_FAILURE_FATAL=no
+ PEERDNS=no
EOF
+ local i=1
+ local ns=
+
+ for ns in $( cat /etc/resolv.conf | grep '^nameserver' | awk '{print $2}' ) ; do
+ echo "DNS${i}=${ns}" >>"${dev_file}"
+ i=$(( $i + 1 ))
+ done
+
+ if grep '^search' /etc/resolv.conf >/dev/null ; then
+ local search=$( grep '^search' /etc/resolv.conf | sed -e 's/^search[ ][ ]*//' )
+ echo "DOMAIN=\"${search}\"" >>"${dev_file}"
+ fi
+
+ echo "RES_OPTIONS=\"timeout:1 attempts:2 use-vc\"" >>"${dev_file}"
+ echo >>"${dev_file}"
+
for ifcfg_file in ${nw_script_dir}/ifcfg-* ; do
local bname=$(basename "${ifcfg_file}" )
if [[ "${bname}" == "ifcfg-lo" ]] ; then
echo "${HASH_LINE}"
echo "Calling set_rsyslogd_el7() ..."
echo
- local url_top="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/rsyslog.conf"
- local url_sub="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/50_rsyslog.conf.el7"
+ local url_top="${cobbler_url}/${ws_rel_filesdir}/${system_status}/rsyslog.conf"
+ local url_sub="${cobbler_url}/${ws_rel_filesdir}/${system_status}/50_rsyslog.conf.el7"
echo
log "Configuring Rsyslogd."
echo "${HASH_LINE}"
echo "Calling set_rsyslogd_el8() ..."
echo
- local url_top="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/rsyslog.conf"
- local url_sub="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/50_rsyslog.conf.el8"
+ local url_top="${cobbler_url}/${ws_rel_filesdir}/${system_status}/rsyslog.conf"
+ local url_sub="${cobbler_url}/${ws_rel_filesdir}/${system_status}/50_rsyslog.conf.el8"
echo
log "Configuring Rsyslogd."
echo "${HASH_LINE}"
echo "Calling get_repos_centos7() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/centos7"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/centos7"
local -a repos=('CentOS-Base' 'CentOS-CR' 'CentOS-fasttrack')
echo "${HASH_LINE}"
echo "Calling get_repos_oel7() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/oel7"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/oel7"
local -a repos=('ol7_addons' 'ol7_latest' 'ol7_optional_latest')
echo "${HASH_LINE}"
echo "Calling get_repos_el7() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/el7"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/el7"
local -a repos=('epel' 'icinga' 'pixelpark' 'prometheus' 'puppet' 'wazuh')
echo "${HASH_LINE}"
echo "Calling get_repos_repos_almalinux8() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/alma8"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/alma8"
local -a repos=('almalinux' 'almalinux-ha' 'almalinux-nft' 'almalinux-plus')
repos+=('almalinux-powertools' 'almalinux-resilientstorage' 'almalinux-rt')
echo "${HASH_LINE}"
echo "Calling get_repos_centos8() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/centos8"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/centos8"
local -a repos=('CentOS-Stream-AppStream' 'CentOS-Stream-BaseOS' 'CentOS-Stream-Extras-common' 'CentOS-Stream-Extras')
repos+=('CentOS-Stream-HighAvailability' 'CentOS-Stream-NFV' 'CentOS-Stream-PowerTools' 'CentOS-Stream-ResilientStorage')
echo "${HASH_LINE}"
echo "Calling get_repos_rocky8() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/rocky8"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/rocky8"
local -a repos=('Rocky-AppStream' 'Rocky-BaseOS' 'Rocky-Extras' 'Rocky-HighAvailability')
repos+=('Rocky-NFV' 'Rocky-Plus' 'Rocky-PowerTools' 'Rocky-ResilientStorage' 'Rocky-RT')
echo "${HASH_LINE}"
echo "Calling get_repos_el8() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/el8"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/el8"
local -a repos=('epel' 'icinga' 'pixelpark' 'prometheus' 'puppet')
echo "${HASH_LINE}"
echo "Calling get_repos_repos_almalinux9() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/alma9"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/alma9"
local -a repos=('almalinux-appstream' 'almalinux-baseos' 'almalinux-crb' 'almalinux-extras' )
repos+=('almalinux-highavailability' 'almalinux-nfv' 'almalinux-plus')
echo "${HASH_LINE}"
echo "Calling get_repos_centos9() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/centos9"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/centos9"
local -a repos=('centos' 'centos-addons')
echo "${HASH_LINE}"
echo "Calling get_repos_el9() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/repos/el9"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/el9"
local -a repos=('pixelpark' 'puppet')
echo "${HASH_LINE}"
echo "Calling set_bashrc_el7() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/bashrc-el7"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/bashrc-el7"
echo
log "Rewriting /etc/bashrc ..."
echo "${HASH_LINE}"
echo "Calling set_bashrc_centos8() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/bashrc-centos8"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/bashrc-centos8"
echo
log "Rewriting /etc/bashrc ..."
echo "${HASH_LINE}"
echo "Calling set_bashrc_centos8() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/bashrc-centos8"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/bashrc-centos8"
echo
log "Rewriting /etc/bashrc ..."
echo "${HASH_LINE}"
echo "Calling set_vimrc_el7() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/vimrc-el7"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/vimrc-el7"
echo
log "Rewriting /etc/vimrc ..."
echo "${HASH_LINE}"
echo "Calling set_vimrc_centos8() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/vimrc-centos8"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/vimrc-centos8"
echo
log "Rewriting /etc/vimrc ..."
echo "${HASH_LINE}"
echo "Calling set_vimrc_centos8() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/vimrc-centos8"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/vimrc-centos8"
echo
log "Rewriting /etc/vimrc ..."
echo "${HASH_LINE}"
echo "Calling create_motd() ..."
echo
- local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/create-motd.sh"
+ local url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/create-motd.sh"
echo
log "Creating initial /etc/motd ..."
log "Installing Legato networker client packages (backup) ..."
echo
- local url_client="${COBBLER_URL}/custom/legato/lgtoclnt-latest.x86_64.rpm"
- local url_man="${COBBLER_URL}/custom/legato/lgtoman-latest.x86_64.rpm"
+ local url_client="${cobbler_url}/custom/legato/lgtoclnt-latest.x86_64.rpm"
+ local url_man="${cobbler_url}/custom/legato/lgtoman-latest.x86_64.rpm"
echo "Installing lgtoclnt ..."
if yum install -y "lgtoclnt" ; then
echo
echo "Getting new master.cf ..."
- url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/postfix/master.cf"
+ url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/postfix/master.cf"
tmp_file=$( mktemp )
wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true
if [[ -s "${tmp_file}" ]] ; then
echo
echo "Getting new virtuals ..."
cp /dev/null "${tmp_file}"
- url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/postfix/virtual"
+ url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/postfix/virtual"
wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true
if [[ -s "${tmp_file}" ]] ; then
mv -v "${tmp_file}" /etc/postfix/virtual
echo "${HASH_LINE}"
echo "Calling config_logrotate() ..."
echo
- local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}"
+ local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}"
log "Configuring logrotation ..."
echo
export mac_address_eth0="$mac_address_eth0"
export system_status="${SYSTEM_STATUS}"
export ws_rel_filesdir="${WS_REL_FILESDIR}"
+export cobbler_url="${COBBLER_URL}"
echo
echo "hostname: '$hostname'"
echo "ip_address_eth0: '$ip_address_eth0'"
echo "mac_address_eth0: '$mac_address_eth0'"
echo "System status: '${system_status}'"
+echo "Cobbler URL: '${cobbler_url}'"
###############################################################################
# Performing snippets