Improve error handling; make scripts re-executable
authorMichael Prokop <devnull@localhost>
Wed, 19 Sep 2007 19:36:11 +0000 (21:36 +0200)
committerMichael Prokop <devnull@localhost>
Wed, 19 Sep 2007 19:36:11 +0000 (21:36 +0200)
etc/grml/fai/config/scripts/GRMLBASE/21-usersetup
etc/grml/fai/config/scripts/GRMLBASE/31-motd
etc/grml/fai/grml/grml_cleanup_chroot.no_online
grml-live

index fc71e2f..ce42a3c 100755 (executable)
@@ -4,7 +4,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # 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
index 2d20b0a..05d7b01 100755 (executable)
@@ -4,13 +4,15 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # 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
index 637c71b..7d277eb 100755 (executable)
@@ -4,7 +4,7 @@
 # Authors:       (c) Michael Prokop <mika@grml.org>
 # 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
index 8ff93f9..0b22840 100755 (executable)
--- 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'"