From ada9ee0154c453dc6f1236527e1a7ed82890ba4b Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 19 Sep 2007 21:36:11 +0200 Subject: [PATCH] Improve error handling; make scripts re-executable --- etc/grml/fai/config/scripts/GRMLBASE/21-usersetup | 17 +++++++++++++---- etc/grml/fai/config/scripts/GRMLBASE/31-motd | 6 ++++-- etc/grml/fai/grml/grml_cleanup_chroot.no_online | 8 ++++---- grml-live | 17 ++++++++++++----- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup b/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup index fc71e2f..ce42a3c 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup +++ b/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup @@ -4,7 +4,7 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2 or any later version. -# Latest change: Mon Sep 17 15:12:21 CEST 2007 [mika] +# Latest change: Wed Sep 19 20:27:03 CEST 2007 [mika] ################################################################################ set -u @@ -14,10 +14,19 @@ USERNAME='' [ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf [ -n "$USERNAME" ] || USERNAME=grml -$ROOTCMD addgroup --gid 1000 $USERNAME -$ROOTCMD useradd -d /home/$USERNAME -m -s /bin/zsh -g 1000 $USERNAME +if grep -q "$USERNAME:x:1000" $target/etc/group ; then + echo "group $USERNAME exists already, skipping" +else + $ROOTCMD addgroup --gid 1000 $USERNAME +fi -sed -i 's/^root::/root:*:/' $target/etc/shadow +if grep -q "$USERNAME:x:1000" $target/etc/passwd ; then + echo "user $USERNAME exists already, skipping" +else + $ROOTCMD useradd -d /home/$USERNAME -m -s /bin/zsh -g 1000 $USERNAME +fi + +sed -i 's/^root::/root:*:/' $target/etc/shadow sed -i "s/^$USERNAME:!:/$USERNAME:*:/" $target/etc/shadow $ROOTCMD chsh -s /bin/zsh root diff --git a/etc/grml/fai/config/scripts/GRMLBASE/31-motd b/etc/grml/fai/config/scripts/GRMLBASE/31-motd index 2d20b0a..05d7b01 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/31-motd +++ b/etc/grml/fai/config/scripts/GRMLBASE/31-motd @@ -4,13 +4,15 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2 or any later version. -# Latest change: Sun Sep 16 23:00:35 CEST 2007 [mika] +# Latest change: Wed Sep 19 20:13:01 CEST 2007 [mika] ################################################################################ set -u set -e -$ROOTCMD mv /etc/motd.dpkg-new /var/run/motd +if [ -f $target/etc/motd.dpkg-new ] ; then + $ROOTCMD mv /etc/motd.dpkg-new /var/run/motd +fi ## END OF FILE ################################################################# # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3 diff --git a/etc/grml/fai/grml/grml_cleanup_chroot.no_online b/etc/grml/fai/grml/grml_cleanup_chroot.no_online index 637c71b..7d277eb 100755 --- a/etc/grml/fai/grml/grml_cleanup_chroot.no_online +++ b/etc/grml/fai/grml/grml_cleanup_chroot.no_online @@ -4,7 +4,7 @@ # Authors: (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Wed Sep 19 13:38:54 CEST 2007 [mika] +# Latest change: Wed Sep 19 20:07:43 CEST 2007 [mika] ################################################################################ # misc stuff @@ -20,8 +20,8 @@ fi if [ -x /usr/bin/update-pciids ] ; then einfo "Updating PCI- and USB-ids" - update-pciids - update-usbids + update-pciids || echo "Warning: update-pciids was not successfull">&2 + update-usbids || echo "Warning: update-usbids was not successfull">&2 eend $? else ewarn "update-pciids/update-usbids not installed" ; eend 0 @@ -29,7 +29,7 @@ fi if [ -x /usr/sbin/nessus-update-plugins ] ; then einfo "Updating nessus-plugins" - nessus-update-plugins + nessus-update-plugins || echo "Warning: nessus-update-plugins was not successfull">&2 eend $? else ewarn "nessus-update-plugins not installed" ; eend 0 diff --git a/grml-live b/grml-live index 8ff93f9..0b22840 100755 --- a/grml-live +++ b/grml-live @@ -164,7 +164,7 @@ fi [ -n "$CHROOT_TARGET" ] || CHROOT_TARGET="$TARGET/grml_chroot" if [ -d "$CHROOT_TARGET" ] ; then - echo " [x] $CHROOT_TARGET exists already, skipping the stage 'fai dirnstall'" + echo " [x] $CHROOT_TARGET exists already, skipping the stage 'fai dirinstall'" else mkdir -p "$CHROOT_TARGET" || bailout 5 "Problem with creating $CHROOT_TARGET for FAI" if [ -n "${MIRROR_DIRECTORY}" ] ; then @@ -175,11 +175,18 @@ else umount $CHROOT_TARGET/proc 2>/dev/null || /bin/true umount $CHROOT_TARGET/sys 2>/dev/null || /bin/true [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_TARGET}/${MIRROR_DIRECTORY}" - # notice: 'fai dirinstall' does not seem to exit appropriate -> - if grep -q 'dpkg: error processing' /var/log/fai/dirinstall/$HOSTNAME/software.log || \ - grep -q 'FAILED with exit code' /var/log/fai/dirinstall/$HOSTNAME/shell.log ; then + + # notice: 'fai dirinstall' does not seem to exit appropriate, so: + ERROR='' + [ -r "/var/log/fai/dirinstall/$HOSTNAME/software.log" ] && + grep -q 'dpkg: error processing' /var/log/fai/dirinstall/$HOSTNAME/software.log && ERROR=1 + + [ -r "/var/log/fai/dirinstall/$HOSTNAME/shell.log" ] && + grep -q 'FAILED with exit code' /var/log/fai/dirinstall/$HOSTNAME/shell.log && ERROR=2 + + if [ -n "$ERROR" ] ; then echo " [!] There was an error during execution of stage 'fai dirinstall'" - echo " Check out /var/log/fai/dirinstall/$HOSTNAME/... for details" + echo " Check out /var/log/fai/dirinstall/$HOSTNAME/... for details. [exit ${ERROR}]" exit 1 else echo " [*] Finished execution of stage 'fai dirinstall'" -- 2.1.4