[issue650] live-module revision 1.6

Tong Sun bts at bts.grml.org
Fri Jan 15 21:13:02 CET 2010


Tong Sun <suntong at cpan.org> added the comment:

- add back all the relavent fleshes beside the bare-bone
---
 bin/live-module |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/bin/live-module b/bin/live-module
index 453800d..e38ab29 100755
--- a/bin/live-module
+++ b/bin/live-module
@@ -14,6 +14,49 @@
 
 # FIXME: move the functions from above line and the followings into a central lib file
 
+# log
+# store given text in /var/log/livedbg
+log()
+{
+   echo "$@" 2>/dev/null >>/var/log/livedbg
+}
+
+debug_log()
+{
+   if [ "$DEBUG_IS_ENABLED" ]; then
+      echo "- debug: $*" >&2
+      log "- debug: $*"
+   fi
+}
+
+# echogreen will echo $@ in green color
+# $1 = text
+#
+echogreen()
+{
+   echo -ne """$@"""
+}
+
+# echolog
+# $1 = text to show and to write to /var/log/messages
+#
+echolog()
+{
+   if [ "$1" != "" ]; then
+      echogreen "* "
+      log "LIVECD:" "$@" 
+      echo "$@"
+   fi
+}
+
+# test if the script is started by root user. If not, exit
+allow_only_root()
+{
+  if [ "0$UID" -ne 0 ]; then
+    echo "Only root can run $(basename $0)"; exit 1
+  fi
+}
+
 # Insert a directory tree $2 to an union specified by $1
 # Top-level read-write branch is specified by it's index 0
 # Using =rr enables aufs to optimize real readonly branches
@@ -22,9 +65,9 @@
 #
 union_insert_dir()
 {
-  log_begin_msg "Union_insert_dir $*"
+  debug_log "union_insert_dir $*"
   mount -n -o remount,add:1:$2=rr aufs $1
-  log_end_msg
+  if [ $? -ne 0 ]; then echo "can't insert module to union" >&2; return 2; fi
 }
 
 mount_image ()
@@ -51,11 +94,14 @@ mount_image ()
 
   union_insert_dir / "${croot}/${imagename}"
 
+  if [ $? -ne 0 ]; then 
+    echo "error inserting module to live filesystem" >&2; exit 3; 
+  fi
 }
 
 try_remount()
 {
-   mount -t aufs -o remount,verbose,del:"${croot}/${imagename}" aufs / 2>/dev/null
+   mount -t aufs -o remount,del:"${croot}/${imagename}" aufs / 2>/dev/null
 }
 
 # ############################################################## &cs ###
@@ -179,10 +225,22 @@ done
 # ############################################################## &cs ###
 # :::::::::::::::::::::::::::::::::::::::::::::::: Main script begin :::
 
+allow_only_root
+
+# are we even using aufs union?
+if [ "$(grep '^aufs / ' /proc/mounts)" = "" ]; then
+  echo "not in the live mode, can't continue."
+  exit 4
+fi
+
 image="${1}"
 imagename=$(basename "${image}")
 croot=""
 
+# FIXME: port the following after bug 506591 has been fixed
+# Test whether the module file is stored in union
+# if yes, then we must move it somewhere else (to RAM) else it can't be added
+
 # == Main dispatch
 
 # business-logic for command line parameter-processing
-- 
1.5.6.5

----------
assignedto: mika
messages: 2035, 2036, 2045, 2046, 2047, 2048, 2049, 2398, 2839, 2840, 2841, 2842, 2843, 2844
nosy: mika, suntong
priority: feature
status: need-eg
title: live-module revision 1.6

_____________________________________
GRML issue tracker <bts at bts.grml.org>
<http://bts.grml.org/grml/issue650>
_____________________________________


More information about the Bugs-changes mailing list