home *** CD-ROM | disk | FTP | other *** search
/ host-198-236-40-254.wlwv.k12.or.us / host-198-236-40-254.wlwv.k12.or.us.tar / host-198-236-40-254.wlwv.k12.or.us / tsu / BareMetalInstall.iso / tools / uselivemod < prev   
Text File  |  2012-12-18  |  2KB  |  68 lines

  1. #!/bin/bash
  2. # Use module while running LiveCD
  3. # include it into live directory structure on the fly
  4. # Or install it if no union is found at /
  5. #
  6. # Author: Tomas M. <http://www.linux-live.org>
  7.  
  8. MODULE="$1"
  9.  
  10. if [ "$MODULE" = "" ]; then
  11.    echo
  12.    echo "Use module on the fly while running Live CD"
  13.    echo "Usage: $0 module.mo"
  14.    exit
  15. fi
  16.  
  17. PATH=.:$(dirname $0):/usr/lib:$PATH
  18. . liblinuxlive || exit 1
  19.  
  20. allow_only_root
  21. IMAGES=/mnt/live/memory/images
  22. MODULES=/mnt/live/memory/modules
  23.  
  24. # are we even using union?
  25. unionctl --query / >/dev/null 2>&1
  26. if [ $? -ne 0 ]; then
  27.    echo "Installing (unpacking) module $MODULE"
  28.    mo2dir $MODULE /
  29.    /sbin/ldconfig
  30.    exit 0
  31. fi
  32.  
  33. mkdir -p "$MODULES"
  34.  
  35. # test whether the module file is stored in union
  36. # if yes, then we must move it somewhere else (to RAM)
  37. unionctl --query "$MODULE" >/dev/null 2>&1
  38. if [ $? -eq 0 ]; then
  39.    echo "module file is stored inside the union, moving to $MODULES first..."
  40.    TARGET="$MODULES/`basename \"$MODULE\"`"
  41.    mv "$MODULE" "$TARGET"
  42.    if [ $? -ne 0 ]; then
  43.       echo "error copying module to memory, not enough free RAM? try df" >&2
  44.       rm "$TARGET"
  45.       return 2
  46.    fi
  47.    MODULE="$TARGET"
  48. fi
  49.  
  50. MOD="`union_insert_module / \"$MODULE\" $IMAGES`"
  51. if [ $? -ne 0 ]; then echo "error inserting module to live filesystem" >&2; exit 3; fi
  52.  
  53. # all executables in /etc/rc.d/ from this module will be started
  54. # with two arguments: "start" "mo". This happens only by this script (uselivemod),
  55. # not in the case when module is loaded during OS startup.
  56. find $IMAGES/$MOD/etc/rc.d -type f 2>/dev/null | while read SCRIPT; do
  57.    if [ "$SCRIPT" != "" -a -x "$SCRIPT" -a ! -d "$SCRIPT" ]; then
  58.       ${SCRIPT##$IMAGES/$MOD} start mo
  59.    fi
  60. done
  61.  
  62. # update ld cache if new ld.so.conf/cache exists in the module
  63.  
  64. if [ -e "$IMAGES/$MOD/etc/ld.so.conf" -o -e "$IMAGES/$MOD/etc/ld.so.cache" ]; then
  65.    echo "Module contains ld.so.conf or ld.so.cache, updating lib cache..."
  66.    /sbin/ldconfig
  67. fi
  68.