From: Ian Kelling Date: Mon, 18 Apr 2016 01:39:33 +0000 (-0700) Subject: better error output X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=a8ec695d6a39792133a21e9eca70e69f9fab107b;p=automated-distro-installer better error output --- diff --git a/arch-init b/arch-init index b34c428..d1c5542 100755 --- a/arch-init +++ b/arch-init @@ -3,7 +3,7 @@ # see t.org for how to call set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd $(dirname $(readlink -f "$BASH_SOURCE")) diff --git a/arch-init-chroot b/arch-init-chroot index 5e2f8aa..6c9d66b 100755 --- a/arch-init-chroot +++ b/arch-init-chroot @@ -1,6 +1,6 @@ #!/bin/bash -x set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR for x in /etc/*.pacorig; do # This started breaking immediately when I stoped doing genfstab. diff --git a/arch-init-remote b/arch-init-remote index c82cd70..3cf222c 100755 --- a/arch-init-remote +++ b/arch-init-remote @@ -3,7 +3,7 @@ set -x set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR if [[ ! $1 ]]; then echo "error: expect a hostname in \$1 " diff --git a/arch-pxe b/arch-pxe index 03ec659..56e4790 100755 --- a/arch-pxe +++ b/arch-pxe @@ -4,7 +4,7 @@ # Requires manually downloading image to /a/opt, and set it's name below. set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd /a/opt #iso="archlinux-2015.11.01-dual" diff --git a/chboot b/chboot index 0e3b506..64e499f 100755 --- a/chboot +++ b/chboot @@ -7,7 +7,7 @@ # DISTRO_NAME is based on the partition names in /boot. eg boot_debianjessie set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR [[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@" diff --git a/debian-preseed b/debian-preseed index 86b4ffd..98ee46c 100755 --- a/debian-preseed +++ b/debian-preseed @@ -1,7 +1,7 @@ #!/bin/bash set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR usage() { cat <&2' ERR [[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@" diff --git a/fai-redep b/fai-redep index 6a47faf..cd08887 100755 --- a/fai-redep +++ b/fai-redep @@ -5,7 +5,7 @@ set -x # then start a virtual machine to test the config. set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd $(dirname $(readlink -f "$BASH_SOURCE")) diff --git a/fai-revm b/fai-revm index 87cf1cf..f7bf872 100755 --- a/fai-revm +++ b/fai-revm @@ -6,7 +6,7 @@ set -x # then start a virtual machine to test the config. set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR redeploy=false if [[ $1 == -r ]]; then diff --git a/fai/config/class/50-host-classes b/fai/config/class/50-host-classes index 2660246..9afbe91 100755 --- a/fai/config/class/50-host-classes +++ b/fai/config/class/50-host-classes @@ -10,9 +10,9 @@ case $HOSTNAME in demohost) echo "FAIBASE DEBIAN DESKTOP STABLE" ;; x2) - echo "FAIBASE DEBIAN DESKTOP STABLE PARTITION_PROMPT" ;; + echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;; tp) - echo "FAIBASE DEBIAN DESKTOP STABLE PARTITION_PROMPT" ;; + echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;; frodo) echo "FAIBASE DEBIAN DESKTOP STABLE PARTITION_PROMPT" ;; # faiserver) diff --git a/fai/config/distro-install-common/end b/fai/config/distro-install-common/end index e6e182b..7d83b20 100755 --- a/fai/config/distro-install-common/end +++ b/fai/config/distro-install-common/end @@ -1,7 +1,7 @@ #!/bin/bash -x set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index 317eb6d..c2b73cb 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -1,7 +1,7 @@ #!/bin/bash -x set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR # # fai's setup-storage won't do btrfs on luks, # # so we do it ourself :) diff --git a/fai/config/scripts/GRUB_PC/11-ian b/fai/config/scripts/GRUB_PC/11-ian index 9764d8e..bdfa275 100755 --- a/fai/config/scripts/GRUB_PC/11-ian +++ b/fai/config/scripts/GRUB_PC/11-ian @@ -1,7 +1,7 @@ #!/bin/bash -x set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR $ROOTCMD adduser --disabled-password --gecos ian ian diff --git a/fai/config/scripts/LAST/50-misc b/fai/config/scripts/LAST/50-misc index 25b6ce7..11bafd5 100755 --- a/fai/config/scripts/LAST/50-misc +++ b/fai/config/scripts/LAST/50-misc @@ -15,13 +15,14 @@ else fi fi - usedm=$(dmsetup ls | egrep -v '^live-rw|^live-base|^No devices found' | wc -l) - if [ $usedm -ne 0 ]; then - if [ ! -d $target/etc/lvm ]; then - echo ERROR: Found lvm devices, but the lvm2 package was not installed - error=1 - fi - fi + # # commented because it does false possitive + # usedm=$(dmsetup ls | egrep -v '^live-rw|^live-base|^No devices found' | wc -l) + # if [ $usedm -ne 0 ]; then + # if [ ! -d $target/etc/lvm ]; then + # echo ERROR: Found lvm devices, but the lvm2 package was not installed + # error=1 + # fi + # fi fi # remove backup files from cfengine, but only if cfengine is installed diff --git a/faiserver-revm b/faiserver-revm index c7f82b8..f546acc 100755 --- a/faiserver-revm +++ b/faiserver-revm @@ -2,7 +2,7 @@ set -x set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd $(dirname $(readlink -f "$BASH_SOURCE")) diff --git a/faiserver-setup b/faiserver-setup index d507f0b..1bfbacb 100755 --- a/faiserver-setup +++ b/faiserver-setup @@ -3,7 +3,7 @@ # initial setup of a fai server on debian set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@" diff --git a/faiserver-uninstall b/faiserver-uninstall index 4a9976d..fbf3bd8 100755 --- a/faiserver-uninstall +++ b/faiserver-uninstall @@ -1,7 +1,7 @@ #!/bin/bash set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@" diff --git a/fresize b/fresize index 7a6688f..68c12bd 100755 --- a/fresize +++ b/fresize @@ -195,7 +195,7 @@ while read devid dev; do cat >/root/finish-resize <<'EOF' #!/bin/bash -x set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR EOF chmod +x /root/finish-resize fi diff --git a/pxe-server b/pxe-server index 6d2411e..1664253 100755 --- a/pxe-server +++ b/pxe-server @@ -7,7 +7,7 @@ # default distro is the base debian/fedora type. others are fai & arch set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR if [[ ! $1 ]]; then echo "$0: error: exptected 1 argument of type" diff --git a/wrt-setup b/wrt-setup index 0c9fb29..2362a33 100755 --- a/wrt-setup +++ b/wrt-setup @@ -1,7 +1,7 @@ #!/bin/bash set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR # ssh diff --git a/wrt-setup-remote b/wrt-setup-remote index ccd96c4..12f6567 100755 --- a/wrt-setup-remote +++ b/wrt-setup-remote @@ -1,7 +1,7 @@ #!/bin/bash set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR h=root@192.168.1.1 scp /a/bin/fai/wrt-setup /a/bin/bash-programs-by-ian/repos/cedit/cedit $h:/usr/bin