From: Frank Brehm Date: Mon, 4 Jul 2022 15:22:45 +0000 (+0200) Subject: Setting COBBLER_URL as a kickstart parameter. X-Git-Tag: 2.6.2~1^2~8^2~15 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=8f3272a179491c8290cfd15af370d9fadd15c330;p=pixelpark%2Fcreate-vmware-tpl.git Setting COBBLER_URL as a kickstart parameter. --- diff --git a/snippets/tpl.001.basics.sh b/snippets/tpl.001.basics.sh index 09e310c..861f6d4 100644 --- a/snippets/tpl.001.basics.sh +++ b/snippets/tpl.001.basics.sh @@ -2,7 +2,6 @@ #raw HASH_LINE="#######################################################################################" -COBBLER_URL="http://cobbler.pixelpark.com" echo "$(date --rfc-3339=seconds): Das ist das Post-Install-Script '$0'." echo @@ -16,11 +15,64 @@ DEVNAME_ETH0=$( ip -oneline link show | \ 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/\..*//' ) @@ -53,8 +105,11 @@ echo " \$management_interface: ${mgmt_interface}" 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() { diff --git a/snippets/tpl.010.authkeys.sh b/snippets/tpl.010.authkeys.sh index 387ce5f..cafb3ff 100644 --- a/snippets/tpl.010.authkeys.sh +++ b/snippets/tpl.010.authkeys.sh @@ -9,7 +9,7 @@ create_authkeys() { 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 diff --git a/snippets/tpl.040.network.sh b/snippets/tpl.040.network.sh index 12ea0fe..82c1d43 100644 --- a/snippets/tpl.040.network.sh +++ b/snippets/tpl.040.network.sh @@ -46,10 +46,32 @@ create_networkconfig() { 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 diff --git a/snippets/tpl.080.rsyslogd-el7.sh b/snippets/tpl.080.rsyslogd-el7.sh index 7e4bb6a..11e9a38 100644 --- a/snippets/tpl.080.rsyslogd-el7.sh +++ b/snippets/tpl.080.rsyslogd-el7.sh @@ -9,8 +9,8 @@ set_rsyslogd_el7() { 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." diff --git a/snippets/tpl.080.rsyslogd-el8.sh b/snippets/tpl.080.rsyslogd-el8.sh index 90dfb2c..5d2ca47 100644 --- a/snippets/tpl.080.rsyslogd-el8.sh +++ b/snippets/tpl.080.rsyslogd-el8.sh @@ -9,8 +9,8 @@ set_rsyslogd_el8() { 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." diff --git a/snippets/tpl.170.repos_centos7.sh b/snippets/tpl.170.repos_centos7.sh index 51baddf..d1368c9 100644 --- a/snippets/tpl.170.repos_centos7.sh +++ b/snippets/tpl.170.repos_centos7.sh @@ -9,7 +9,7 @@ get_repos_centos7() { 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') diff --git a/snippets/tpl.170.repos_oel7.sh b/snippets/tpl.170.repos_oel7.sh index 3b1dcad..838c7c5 100644 --- a/snippets/tpl.170.repos_oel7.sh +++ b/snippets/tpl.170.repos_oel7.sh @@ -9,7 +9,7 @@ get_repos_oel7() { 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') diff --git a/snippets/tpl.175.repos_el7.sh b/snippets/tpl.175.repos_el7.sh index 48ab4a1..beb62a9 100644 --- a/snippets/tpl.175.repos_el7.sh +++ b/snippets/tpl.175.repos_el7.sh @@ -9,7 +9,7 @@ get_repos_el7() { 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') diff --git a/snippets/tpl.180.repos_almalinux8.sh b/snippets/tpl.180.repos_almalinux8.sh index 5c8db96..8c7029d 100644 --- a/snippets/tpl.180.repos_almalinux8.sh +++ b/snippets/tpl.180.repos_almalinux8.sh @@ -8,7 +8,7 @@ get_repos_almalinux8() { 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') diff --git a/snippets/tpl.180.repos_centos8.sh b/snippets/tpl.180.repos_centos8.sh index 1b96d4c..984982a 100644 --- a/snippets/tpl.180.repos_centos8.sh +++ b/snippets/tpl.180.repos_centos8.sh @@ -8,7 +8,7 @@ get_repos_centos8() { 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') diff --git a/snippets/tpl.180.repos_rocky8.sh b/snippets/tpl.180.repos_rocky8.sh index 6a857d6..1bc17ce 100644 --- a/snippets/tpl.180.repos_rocky8.sh +++ b/snippets/tpl.180.repos_rocky8.sh @@ -8,7 +8,7 @@ get_repos_rocky8() { 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') diff --git a/snippets/tpl.185.repos_el8.sh b/snippets/tpl.185.repos_el8.sh index 0473cde..0373fce 100644 --- a/snippets/tpl.185.repos_el8.sh +++ b/snippets/tpl.185.repos_el8.sh @@ -8,7 +8,7 @@ get_repos_el8() { 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') diff --git a/snippets/tpl.190.repos_almalinux9.sh b/snippets/tpl.190.repos_almalinux9.sh index 71027b1..7917fa3 100644 --- a/snippets/tpl.190.repos_almalinux9.sh +++ b/snippets/tpl.190.repos_almalinux9.sh @@ -8,7 +8,7 @@ get_repos_almalinux9() { 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') diff --git a/snippets/tpl.190.repos_centos9.sh b/snippets/tpl.190.repos_centos9.sh index 0132d97..4e4ae6f 100644 --- a/snippets/tpl.190.repos_centos9.sh +++ b/snippets/tpl.190.repos_centos9.sh @@ -8,7 +8,7 @@ get_repos_centos9() { 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') diff --git a/snippets/tpl.195.repos_el9.sh b/snippets/tpl.195.repos_el9.sh index a106b54..9ff526f 100644 --- a/snippets/tpl.195.repos_el9.sh +++ b/snippets/tpl.195.repos_el9.sh @@ -8,7 +8,7 @@ get_repos_el9() { 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') diff --git a/snippets/tpl.205.bashrc-el7.sh b/snippets/tpl.205.bashrc-el7.sh index 37e7c2b..170904d 100644 --- a/snippets/tpl.205.bashrc-el7.sh +++ b/snippets/tpl.205.bashrc-el7.sh @@ -9,7 +9,7 @@ set_bashrc_el7() { 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 ..." diff --git a/snippets/tpl.210.bashrc-el8.sh b/snippets/tpl.210.bashrc-el8.sh index d2dd3a3..28f351d 100644 --- a/snippets/tpl.210.bashrc-el8.sh +++ b/snippets/tpl.210.bashrc-el8.sh @@ -9,7 +9,7 @@ set_bashrc_centos8() { 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 ..." diff --git a/snippets/tpl.211.bashrc-el9.sh b/snippets/tpl.211.bashrc-el9.sh index d2dd3a3..28f351d 100644 --- a/snippets/tpl.211.bashrc-el9.sh +++ b/snippets/tpl.211.bashrc-el9.sh @@ -9,7 +9,7 @@ set_bashrc_centos8() { 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 ..." diff --git a/snippets/tpl.225.vimrc-el7.sh b/snippets/tpl.225.vimrc-el7.sh index 34929b4..dbcdd03 100644 --- a/snippets/tpl.225.vimrc-el7.sh +++ b/snippets/tpl.225.vimrc-el7.sh @@ -9,7 +9,7 @@ set_vimrc_el7() { 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 ..." diff --git a/snippets/tpl.230.vimrc-el8.sh b/snippets/tpl.230.vimrc-el8.sh index d85c3f7..1d100fe 100644 --- a/snippets/tpl.230.vimrc-el8.sh +++ b/snippets/tpl.230.vimrc-el8.sh @@ -9,7 +9,7 @@ set_vimrc_centos8() { 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 ..." diff --git a/snippets/tpl.231.vimrc-el9.sh b/snippets/tpl.231.vimrc-el9.sh index d85c3f7..1d100fe 100644 --- a/snippets/tpl.231.vimrc-el9.sh +++ b/snippets/tpl.231.vimrc-el9.sh @@ -9,7 +9,7 @@ set_vimrc_centos8() { 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 ..." diff --git a/snippets/tpl.300.create-motd.sh b/snippets/tpl.300.create-motd.sh index e057970..1d1c48c 100644 --- a/snippets/tpl.300.create-motd.sh +++ b/snippets/tpl.300.create-motd.sh @@ -9,7 +9,7 @@ create_motd() { 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 ..." diff --git a/snippets/tpl.350.legato.sh b/snippets/tpl.350.legato.sh index 6ec5340..892abaf 100644 --- a/snippets/tpl.350.legato.sh +++ b/snippets/tpl.350.legato.sh @@ -13,8 +13,8 @@ install_legato() { 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 diff --git a/snippets/tpl.470.postfix.sh b/snippets/tpl.470.postfix.sh index 1f7e229..d10f0da 100644 --- a/snippets/tpl.470.postfix.sh +++ b/snippets/tpl.470.postfix.sh @@ -154,7 +154,7 @@ install_postfix() { 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 @@ -164,7 +164,7 @@ install_postfix() { 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 diff --git a/snippets/tpl.500.logrotate.sh b/snippets/tpl.500.logrotate.sh index 04c9822..1d6af68 100644 --- a/snippets/tpl.500.logrotate.sh +++ b/snippets/tpl.500.logrotate.sh @@ -9,7 +9,7 @@ config_logrotate() { 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 diff --git a/templates/el-standard.ks b/templates/el-standard.ks index 1b25d01..b460996 100644 --- a/templates/el-standard.ks +++ b/templates/el-standard.ks @@ -136,6 +136,7 @@ export ip_address_eth0="$ip_address_eth0" 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'" @@ -145,6 +146,7 @@ echo "Management interface: '${mgmt_interface}'" 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