Warning!

Notice: the grml team is migrating from Mercurial to Git.
Please visit git.grml.org instead!

Improve error handling; make scripts re-executable
authorMichael Prokop
Wed Sep 19 21:36:11 2007 +0200 (14 months ago)
changeset 9463701b9f39a4
manifest63701b9f39a4
parent 93edfa68d7c488
child 95748ff5a59ed2
Improve error handling; make scripts re-executable
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
--- a/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup Wed Sep 19 17:18:18 2007 +0200
+++ b/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup Wed Sep 19 21:36:11 2007 +0200
@@ -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
--- a/etc/grml/fai/config/scripts/GRMLBASE/31-motd Wed Sep 19 17:18:18 2007 +0200
+++ b/etc/grml/fai/config/scripts/GRMLBASE/31-motd Wed Sep 19 21:36:11 2007 +0200
@@ -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
--- a/etc/grml/fai/grml/grml_cleanup_chroot.no_online Wed Sep 19 17:18:18 2007 +0200
+++ b/etc/grml/fai/grml/grml_cleanup_chroot.no_online Wed Sep 19 21:36:11 2007 +0200
@@ -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
--- a/grml-live Wed Sep 19 17:18:18 2007 +0200
+++ b/grml-live Wed Sep 19 21:36:11 2007 +0200
@@ -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'"