Unify use of /etc/grml/fai/grml/grml_cleanup_chroot
authorMichael Prokop <devnull@localhost>
Wed, 19 Sep 2007 11:44:10 +0000 (13:44 +0200)
committerMichael Prokop <devnull@localhost>
Wed, 19 Sep 2007 11:44:10 +0000 (13:44 +0200)
docs/grml-live.txt
etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot
etc/grml/fai/grml/grml_cleanup_chroot
etc/grml/fai/grml/grml_cleanup_chroot.latex_cleanup [new file with mode: 0755]
etc/grml/fai/grml/grml_cleanup_chroot.no_online [new file with mode: 0755]
etc/grml/fai/grml/grml_cleanup_chroot.remove_docs [new file with mode: 0755]
etc/grml/fai/grml/grml_cleanup_chroot.small [deleted file]

index 932e7c6..7a68af8 100644 (file)
@@ -387,7 +387,8 @@ error processing" [software.log], "FAILED with exit code" [shell.log],...)
 * support something like a directory /etc/grml/fai/packages to install
 additional Debian packages without the need for a Debian repository
 
-* document the available classes in more detail
+* document the available classes in more detail (GRMLBASE, LATEX_CLEANUP,
+NO_ONLINE, REMOVE_DOCS, GRML_SMALL,...)
 
 * add a check to make sure $TARGET is mounted rw,suid,dev?
 
index e66fcf7..88fd997 100755 (executable)
@@ -4,36 +4,43 @@
 # 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 17:36:13 CEST 2007 [mika]
+# Latest change: Wed Sep 19 13:42:19 CEST 2007 [mika]
 ################################################################################
 
-set -u
 set -e
+set -u
 
-# TODO: use extra files and class names instead of environment variabes
-
-# supported environment variables for grml_cleanup_chroot:
-#   NOCOLORS: if set it disables colors in (debugging) output
-#   LATEX_CLEANUP: remove some big directories of texlive (/usr/share/doc/texlive-*)
-#   NOONLINE: disable functions that require working network setup
-#   FAST: skip some longer tasks
-#   REMOVE_DOCS: rm -rf /usr/share/doc + /usr/share/info
+# remove some big directories when using class LATEX_CLEANUP:
+if ifclass LATEX_CLEANUP ; then
+   cp /etc/grml/fai/grml/grml_cleanup_chroot.latex_cleanup $target/root/
+   $ROOTCMD /root/grml_cleanup_chroot.latex_cleanup
+   rm $target/root/grml_cleanup_chroot.latex_cleanup
+fi
 
-if ifclass GRML_SMALL ; then
-   cp /etc/grml/fai/grml/grml_cleanup_chroot.small $target/root/
-   $ROOTCMD sh -c "NOCOLORS=1 /root/grml_cleanup_chroot.small"
-   rm $target/root/grml_cleanup_chroot.small
+# skip tasks which require only when using class NO_ONLINE:
+if ! ifclass NO_ONLINE ; then
+   cp /etc/grml/fai/grml/grml_cleanup_chroot.no_online $target/root/
+   $ROOTCMD /root/grml_cleanup_chroot.no_online
+   rm $target/root/grml_cleanup_chroot.no_online
 fi
 
-if ifclass REMOVE_DOCS ; then
-   $ROOTCMD sh -c "NOCOLORS=1 REMOVE_DOCS=1 /root/grml_cleanup_chroot.small"
-   rm $target/root/grml_cleanup_chroot.small
+# remove /usr/share/doc, /usr/share/info,... only in class REMOVE_DOCS:
+if ifclass REMOVE_DOCS: ; then
+   cp /etc/grml/fai/grml/grml_cleanup_chroot.remove_docs $target/root/
+   $ROOTCMD /root/grml_cleanup_chroot.remove_docs
+   rm $target/root/grml_cleanup_chroot.remove_docs
 fi
 
-# final cleanup
+# misc cleanup:
 cp /etc/grml/fai/grml/grml_cleanup_chroot $target/root/
-$ROOTCMD sh -c "NOCOLORS=1 /root/grml_cleanup_chroot"
+$ROOTCMD /root/grml_cleanup_chroot
 rm $target/root/grml_cleanup_chroot
 
+# make sure GRML_SMALL uses the appropriate configuration:
+if ifclass GRML_SMALL ; then
+   cp $target/etc/inittab.small $target/etc/inittab
+   cp $target/etc/runlevel.conf.livecd.small $target/etc/runlevel.conf
+fi
+
 ## END OF FILE #################################################################
 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3
index 73b2ae6..e93f175 100755 (executable)
@@ -4,29 +4,17 @@
 # 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: Mon Sep 17 22:14:33 CEST 2007 [mika]
+# Latest change: Wed Sep 19 13:38:45 CEST 2007 [mika]
 ################################################################################
 
 # misc stuff
   umask 022
-  [ -n "$NOCOLORS" ] || . /etc/grml_colors
   . /etc/grml/lsb-functions || exit 6
   [ -x /lib64 ] && GRML64=yes || GRML64=''
 
 # detect kernel version, assume newest kernel version
   KERNEL=$(ls -1 /lib/modules/ | sort -r -u | head -1)
 
-if [ -n "$LATEX_CLEANUP" ] ; then
-   rm -rf /usr/share/doc/texlive-latex-recommended/latex/ \
-          /usr/share/doc/texlive-latex-base/latex/ \
-          /usr/share/doc/texlive-base-bin/pdftex/thanh/ \
-          /usr/share/doc/texlive-latex-base/latex/base/ \
-          /usr/share/doc/texlive-latex-base/latex/hyperref/ \
-          /usr/share/doc/texlive-latex-base/generic/babel/  \
-          /usr/share/doc/texlive-latex-recommended/latex/koma-script/ \
-          /usr/share/doc/texmf/pgf/pgfmanual.pdf.gz
-fi
-
 if [ -f /usr/share/fonts/X11/misc/artwiz-cursor.pcf.gz ] ; then
   if dpkg-divert --list artwiz-cursor | grep -q /usr/share/fonts/X11/misc/cursor.pcf.gz ; then
      eerror "Broken diversion of artwiz-cursor, see #341397, trying to fix it"
@@ -221,36 +209,6 @@ else
   ewarn "depmod not installed" ; eend 0
 fi
 
-if [ -n "$NOONLINE" ] ; then
-   einfo "\$NOONLINE is set, skipping online tasks" ; eend 0
-else
-
-if [ -x /usr/bin/freshclam ] ; then
-  einfo "Updating clamav database via running freshclam"
-  /usr/bin/freshclam ; eend $?
-else
-  ewarn "freshclam not installed" ; eend 0
-fi
-
-if [ -x /usr/bin/update-pciids ] ; then
-  einfo "Updating PCI- and USB-ids"
-  update-pciids
-  update-usbids
-  eend $?
-else
-  ewarn "update-pciids/update-usbids not installed" ; eend 0
-fi
-
-if [ -x /usr/sbin/nessus-update-plugins ] ; then
-   einfo "Updating nessus-plugins"
-   nessus-update-plugins
-   eend $?
-else
-  ewarn "nessus-update-plugins not installed" ; eend 0
-fi
-
-fi # end of $NOONLINE-check
-
 einfo "Cleaning and removing some misc files and directories"
   rm -f  /etc/sysconfig/* /etc/motd.dpkg-new /etc/auto.master.distrib.dpkg-new    \
          /etc/samba/*.SID /etc/samba/*.tdb /dev/mouse* /dev/cdrom* /dev/cdwriter* \
@@ -281,11 +239,6 @@ else
   ewarn "update-ca-certificates not installed" ; eend 0
 fi
 
-# some stuff does not have to run every single time...
-if [ -n "$FAST" ] ; then
-   einfo "\$FAST is set, skipping some tasks" ; eend 0
-else
-
 # regenerate module dependencies and ls.so.cache
 if [ -x /sbin/ldconfig ] ; then
   einfo "Updating ld.so.cache"
@@ -320,30 +273,6 @@ else
   ewarn "mandb not installed" ; eend 0
 fi
 
-if [ -n "$REMOVE_DOCS" ] ; then
-  einfo "Cleaning documentation directories..."
-  if [ -d /usr/share/doc/grml-docs ] ; then
-     mv /usr/share/doc/grml-docs /tmp/
-  fi
-
-  rm -rf /usr/share/doc
-  mkdir /usr/share/doc
-
-  if [ -d /tmp/grml-docs ] ; then
-     mv /tmp/grml-docs /usr/share/doc/grml-docs
-  fi
-
-  rm -rf /usr/share/gtk-doc/
-  rm -rf /usr/share/man/
-  rm -rf /usr/man
-  rm -rf /usr/share/info
-  eend $?
-
-  einfo "Creating /usr/share/info/..."
-  mkdir -p /usr/share/info/
-  eend $?
-fi
-
 if [ -d /var/lib/clamav/ ] ; then
   einfo "Cleaning /var/lib/clamav/"
   rm -f /var/lib/clamav/clamav-* ; eend $?
@@ -386,8 +315,6 @@ else
   ewarn "updatedb not installed" ; eend 0
 fi
 
-fi # end of $FAST-check
-
 einfo "Unmounting all filesystems"
   umount -a
 eend $?
diff --git a/etc/grml/fai/grml/grml_cleanup_chroot.latex_cleanup b/etc/grml/fai/grml/grml_cleanup_chroot.latex_cleanup
new file mode 100755 (executable)
index 0000000..abea847
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Filename:      /etc/grml/fai/grml/grml_cleanup_chroot_latex_cleanup
+# Purpose:       remove some large LaTeX directories
+# 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:49 CEST 2007 [mika]
+################################################################################
+
+# misc stuff
+  . /etc/grml/lsb-functions || exit 6
+
+rm -rf /usr/share/doc/texlive-latex-recommended/latex/ \
+       /usr/share/doc/texlive-latex-base/latex/ \
+       /usr/share/doc/texlive-base-bin/pdftex/thanh/ \
+       /usr/share/doc/texlive-latex-base/latex/base/ \
+       /usr/share/doc/texlive-latex-base/latex/hyperref/ \
+       /usr/share/doc/texlive-latex-base/generic/babel/  \
+       /usr/share/doc/texlive-latex-recommended/latex/koma-script/ \
+       /usr/share/doc/texmf/pgf/pgfmanual.pdf.gz
+
+## END OF FILE #################################################################
diff --git a/etc/grml/fai/grml/grml_cleanup_chroot.no_online b/etc/grml/fai/grml/grml_cleanup_chroot.no_online
new file mode 100755 (executable)
index 0000000..637c71b
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+# Filename:      /etc/grml/fai/grml/grml_cleanup_chroot_no_online
+# Purpose:       execute tasks that require network access
+# 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]
+################################################################################
+
+# misc stuff
+  umask 022
+  . /etc/grml/lsb-functions || exit 6
+
+if [ -x /usr/bin/freshclam ] ; then
+  einfo "Updating clamav database via running freshclam"
+  /usr/bin/freshclam ; eend $?
+else
+  ewarn "freshclam not installed" ; eend 0
+fi
+
+if [ -x /usr/bin/update-pciids ] ; then
+  einfo "Updating PCI- and USB-ids"
+  update-pciids
+  update-usbids
+  eend $?
+else
+  ewarn "update-pciids/update-usbids not installed" ; eend 0
+fi
+
+if [ -x /usr/sbin/nessus-update-plugins ] ; then
+   einfo "Updating nessus-plugins"
+   nessus-update-plugins
+   eend $?
+else
+  ewarn "nessus-update-plugins not installed" ; eend 0
+fi
+
+## END OF FILE #################################################################
diff --git a/etc/grml/fai/grml/grml_cleanup_chroot.remove_docs b/etc/grml/fai/grml/grml_cleanup_chroot.remove_docs
new file mode 100755 (executable)
index 0000000..a4531ea
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+# Filename:      /etc/grml/fai/grml/grml_cleanup_chroot_remove_docs
+# Purpose:       remove docs in grml chroot
+# Authors:       (c) Michael Prokop <mika@grml.org>
+# License:       This file is licensed under the GPL v2.
+# Latest change: Wed Sep 19 13:38:58 CEST 2007 [mika]
+################################################################################
+
+. /etc/grml/lsb-functions || exit 6
+
+einfo "Cleaning documentation directories..."
+if [ -d /usr/share/doc/grml-docs ] ; then
+   mv /usr/share/doc/grml-docs /tmp/
+fi
+
+rm -rf /usr/share/doc
+mkdir /usr/share/doc
+
+if [ -d /tmp/grml-docs ] ; then
+   mv /tmp/grml-docs /usr/share/doc/grml-docs
+fi
+
+rm -rf /usr/share/gtk-doc/
+rm -rf /usr/share/man/
+rm -rf /usr/man
+rm -rf /usr/share/info
+eend $?
+
+einfo "Creating /usr/share/info/..."
+mkdir -p /usr/share/info/
+eend $?
+
+## END OF FILE #################################################################
diff --git a/etc/grml/fai/grml/grml_cleanup_chroot.small b/etc/grml/fai/grml/grml_cleanup_chroot.small
deleted file mode 100755 (executable)
index a96a581..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-# Filename:      /etc/grml/fai/grml/grml_cleanup_chroot.small
-# Purpose:       clean up grml chroot (adjusted for grml-small)
-# Authors:       (c) Michael Prokop <mika@grml.org>
-# License:       This file is licensed under the GPL v2.
-# Latest change: Mon Sep 17 17:34:47 CEST 2007 [mika]
-################################################################################
-
-# misc stuff
-  umask 022
-  [ -n "$NOCOLORS" ] || . /etc/grml_colors
-  . /etc/grml/lsb-functions || exit 6
-
-einfo "Setting up /etc/inittab"
-cp /etc/inittab.small /etc/inittab
-eend $?
-
-einfo "Copying original runlevel.conf to /etc/runlevel.conf"
-cp /etc/runlevel.conf.livecd.small /etc/runlevel.conf
-eend $?
-
-if [ -n "$REMOVE_DOCS" ] ; then
-#  einfo "Cleaning up /etc/skel..."
-#  rm -rf /etc/skel/.fluxbox 
-#  rm -rf /etc/skel/.gkrellm2 
-#  rm -rf /etc/skel/.idesktop 
-#  rm -rf /etc/skel/.pekwm
-#  eend $?
-
-  einfo "Cleaning documentation directories..."
-  if [ -d /usr/share/doc/grml-docs ] ; then
-     mv /usr/share/doc/grml-docs /tmp/
-  fi
-
-  rm -rf /usr/share/doc
-  mkdir /usr/share/doc
-
-  if [ -d /tmp/grml-docs ] ; then
-     mv /tmp/grml-docs /usr/share/doc/grml-docs
-  fi
-
-  rm -rf /usr/share/gtk-doc/
-  rm -rf /usr/share/man/
-  rm -rf /usr/man
-  rm -rf /usr/share/info
-  eend $?
-
-  einfo "Creating /usr/share/info/..."
-  mkdir -p /usr/share/info/
-  eend $?
-fi
-
-## END OF FILE #################################################################