From: Frank Brehm Date: Wed, 16 May 2018 14:15:28 +0000 (+0200) Subject: Extending bin/postinst by an error file X-Git-Tag: 0.1.1~3^2~2 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=3d090bf6b70a31b1e6049762a0af040ca1d6715f;p=pixelpark%2Fcreate-vmware-tpl.git Extending bin/postinst by an error file --- diff --git a/bin/postinst b/bin/postinst index aea12e6..4176dd2 100644 --- a/bin/postinst +++ b/bin/postinst @@ -25,6 +25,8 @@ GIT_NAMESPACE="ppadmin" POSTFIX_MYORIGIN='pixelpark.net' POSTFIX_RELAYHOST='[mx.pixelpark.net]' +ERROR_POINTER="/root/postinst-error.txt" + echo echo "Some information:" echo " \$hostname: $hostname" @@ -336,7 +338,11 @@ install_epel() { tgt="/etc/yum.repos.d/${bname}" echo echo "Retrieving '${url}' -> '${tgt}' ..." - wget -O "${tgt}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + if wget -O "${tgt}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + : + else + echo "[$(date)]: Could not get '${bname}' from '${url}'." | tee -a "${ERROR_POINTER}" + fi chmod -v 0644 "${tgt}" done @@ -349,7 +355,11 @@ install_epel() { tgt="/etc/pki/rpm-gpg/${bname}" echo echo "Retrieving '${url}' -> '${tgt}' ..." - wget -O "${tgt}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + if wget -O "${tgt}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + : + else + echo "[$(date)]: Could not get '${bname}' from '${url}'." | tee -a "${ERROR_POINTER}" + fi chmod -v 0644 "${tgt}" done @@ -359,11 +369,19 @@ install_epel() { echo log "Updating YUM cache ..." - yum makecache fast + if yum makecache fast ; then + : + else + echo "[$(date)]: Could not update YUM cache." | tee -a "${ERROR_POINTER}" + fi echo log "Installing perl-Config-IniFiles.noarch ..." - yum install -y perl-Config-IniFiles.noarch + if yum install -y perl-Config-IniFiles.noarch ; then + : + else + echo "[$(date)]: Could not install perl-Config-IniFiles.noarch." | tee -a "${ERROR_POINTER}" + fi sleep 3 } @@ -381,7 +399,11 @@ install_pp_tcsh_env() { local local_tar=$( mktemp -p /tmp "linux_tcsh.XXXXXXXX.tar" ) echo "Local tar file: '${local_tar}'." - wget -O "${local_tar}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + if wget -O "${local_tar}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + : + else + echo "[$(date)]: Could not get 'linux_tcsh.tar' from '${url}'." | tee -a "${ERROR_POINTER}" + fi if [[ -f "${local_tar}" && -s "${local_tar}" ]] ; then cd /etc echo "Unpacking '${local_tar}' ..." @@ -399,7 +421,11 @@ install_pp_tcsh_env() { url="${COBBLER_URL}/custom/create-vmware-tpl/files/fbr.sh" local tgt="/etc/profile.d/fbr.sh" echo "Retrieving '${url}' -> '${tgt}' ..." - wget -O "${tgt}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + if wget -O "${tgt}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}"; then + : + else + echo "[$(date)]: Could not get 'fbr.sh' from '${url}'." | tee -a "${ERROR_POINTER}" + fi chmod -v 0644 "${tgt}" } @@ -430,7 +456,11 @@ misc_packages() { echo "${HASH_LINE}" echo log "Installing NetworkManager ..." - yum install -y NetworkManager NetworkManager-config-server NetworkManager-tui + if yum install -y NetworkManager NetworkManager-config-server NetworkManager-tui ; then + : + else + echo "[$(date)]: Could not install NetworkManager." | tee -a "${ERROR_POINTER}" + fi echo "Enabling NetworkManager ..." systemctl enable NetworkManager @@ -443,11 +473,18 @@ misc_packages() { echo log "Installng VLAN vconfig ..." - yum install -y vconfig - + if yum install -y vconfig ; then + : + else + echo "[$(date)]: Could not install vconfig." | tee -a "${ERROR_POINTER}" + fi echo log "Installing packages: ${misc_pkgs}" - yum install -y ${misc_pkgs} + if yum install -y ${misc_pkgs} ; then + : + else + echo "[$(date)]: Could not install ${misc_pkgs}" | tee -a "${ERROR_POINTER}" + fi echo log "Removing packages mysql-community* ..." @@ -489,12 +526,15 @@ create_motd() { echo log "Creating initial /etc/motd ..." local mk_script=$( mktemp -p /tmp "mk_create_motd.XXXXXXXXXX.ksh" ) - wget -O "${mk_script}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" - chmod 0755 "${mk_script}" - "${mk_script}" -i 192.168.88.0/23 \ - -p "Template VM" \ - -l "L105 VMWare" \ - -o "Pixelpark GmbH" > /etc/motd + if wget -O "${mk_script}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + chmod 0755 "${mk_script}" + "${mk_script}" -i 192.168.88.0/23 \ + -p "Template VM" \ + -l "L105 VMWare" \ + -o "Pixelpark GmbH" > /etc/motd + else + echo "[$(date)]: Could not get 'mk_create_motd.ksh' from '${url}'." | tee -a "${ERROR_POINTER}" + fi rm -fv "${mk_script}" } @@ -511,9 +551,17 @@ install_legato_networker() { log "Installing Legato networker client ..." echo "Installing from URL '${url_client}' ..." - yum install -y "${url_client}" + if yum install -y "${url_client}" ; then + : + else + echo "[$(date)]: Could not install from ${url_client}" | tee -a "${ERROR_POINTER}" + fi echo "Installing from URL '${url_man}' ..." - yum install -y "${url_man}" + if yum install -y "${url_man}" ; then + : + else + echo "[$(date)]: Could not install from ${url_man}" | tee -a "${ERROR_POINTER}" + fi mkdir -pv /nsr/res echo "legato01.pixelpark.com" > /nsr/res/servers @@ -536,7 +584,11 @@ install_ntp() { echo log "Installing NTP ..." - yum install -y ntp + if yum install -y ntp ; then + : + else + echo "[$(date)]: Could not install ntp." | tee -a "${ERROR_POINTER}" + fi echo "Cofiguring ntpd ..." mkdir -pv /etc/ntp @@ -574,13 +626,17 @@ install_openvm_tools() { echo log "Installing open-vm-tools ..." - yum install -y open-vm-tools + if yum install -y open-vm-tools ; then - echo "Enabling vmware-tools and vmtoolsd ..." - systemctl enable vmware-tools - systemctl enable vmtoolsd + echo "Enabling vmware-tools and vmtoolsd ..." + systemctl enable vmware-tools + systemctl enable vmtoolsd - vmware-toolbox-cmd timesync disable + vmware-toolbox-cmd timesync disable + + else + echo "[$(date)]: Could not install open-vm-tools" | tee -a "${ERROR_POINTER}" + fi } @@ -614,7 +670,11 @@ dist_upgrade() { echo log "Upgrading all packages ..." echo - yum upgrade -y + if yum upgrade -y ; then + : + else + echo "[$(date)]: Upgrading system not successful." | tee -a "${ERROR_POINTER}" + fi } @@ -643,7 +703,11 @@ install_puppet() { echo echo "Installing puppet package ..." - yum install -y puppet-agent + if yum install -y puppet-agent ; then + : + else + echo "[$(date)]: Could not install puppet-agent." | tee -a "${ERROR_POINTER}" + fi echo echo "Creating config dirs ..." @@ -855,7 +919,11 @@ install_postfix() { ) - yum install -y postfix mailx + if yum install -y postfix mailx ; then + : + else + echo "[$(date)]: Could not install postfix and mailx." | tee -a "${ERROR_POINTER}" + fi cat <<-EOF >"/etc/postfix/generic" @@ -965,7 +1033,11 @@ config_logrotate() { local tgt="/etc/logrotate.conf" echo "Getting ${url} => ${tgt} ..." - wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + if wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + : + else + echo "[$(date)]: Could not get 'logrotate.conf' from '${url}'." | tee -a "${ERROR_POINTER}" + fi if [[ -s "${tmp_file}" ]] ; then cp -v "${tmp_file}" "${tgt}" fi @@ -976,7 +1048,11 @@ config_logrotate() { tgt="/etc/logrotate.d/${base}" cp -v /dev/null "${tmp_file}" echo "Getting ${url} => ${tgt} ..." - wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + if wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + : + else + echo "[$(date)]: Could not get '${base}' from '${url}'." | tee -a "${ERROR_POINTER}" + fi if [[ -s "${tmp_file}" ]] ; then cp -v "${tmp_file}" "${tgt}" fi @@ -1020,6 +1096,8 @@ main() { tweak_grub + echo "[$(date)]: Test error." | tee -a "${ERROR_POINTER}" + }