slitaz-modular view initramfs/usr/bin/activate @ rev 177

mkiso.sh: more filenames support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 30 09:46:37 2016 +0200 (2016-03-30)
parents
children
line source
1 #!/bin/bash
2 # Activate a module, while running LiveCD.
3 # Include it into live directory structure on the fly
4 #
5 # Author: Tomas M. <http://www.linux-live.org>
9 MODULE=$(readlink -f "$1")
11 if [ "$MODULE" = "" -o ! -e "$MODULE" -o -d "$MODULE" ]; then
12 echo
13 echo "Activate a module on the fly while running Linux Live"
14 echo "Usage: $0 module.lzm"
15 exit 1
16 fi
18 if [ "$(echo $MODULE | fgrep -i .lzm || fgrep -i .xz)" = "" ]; then
19 echo
20 echo "$(basename $MODULE): Module must end with .lzm"
21 exit 2
22 fi
24 PATH=.:$(dirname $0):/usr/lib:$PATH
25 . liblinuxlive || exit 3
27 allow_only_root
28 IMAGES=/mnt/live/memory/images
29 MODULES=/mnt/live/memory/modules
31 # are we even using union?
32 if [ "$(grep '^aufs / ' /proc/mounts)" = "" ]; then
33 echo "not in the live mode, can't continue. Try lzm2dir $MODULE /"
34 exit 4
35 fi
37 mkdir -p "$MODULES"
39 # Test whether the module file is stored in union
40 # if yes, then we must move it somewhere else (to RAM) else it can't be added
41 if [ -e "/mnt/live/memory/changes/$(readlink -f "$MODULE")" ]; then
42 echo "module file is stored inside the union, moving to $MODULES first..."
43 TARGET="$MODULES/$(basename "$MODULE")"
44 mv "$MODULE" "$TARGET"
45 if [ $? -ne 0 ]; then
46 echo "error copying module to memory, not enough free RAM? try df" >&2
47 rm "$TARGET"
48 exit 6
49 fi
50 MODULE="$TARGET"
51 fi
53 MOD=$(union_insert_module / "$MODULE" $IMAGES)
54 if [ $? -ne 0 ]; then echo "error inserting module to live filesystem" >&2; exit 3; fi
56 # All executables (but symlinks) in /etc/rc.d/init.d/ from this module will be started
57 # with two arguments: "start" "activate".
58 # This is done only by the 'activate' script, not in the case when the module is loaded
59 # during OS startup (in that case, your distro is responsible for execution)
60 #
61 # For compatibility, /etc/init.d is also examined, but it's not recommended for you to put your startup scripts
62 # there in your module
64 MOD="$IMAGES/$(basename $MOD)"
66 find_n_run_scripts $MOD start activate
68 # update ld cache if new ld.so.conf/cache exists in the module
69 if [ -e "$MOD/etc/ld.so.conf" -o -e "$MOD/etc/ld.so.cache" ]; then
70 echo "Module contains ld.so.conf or ld.so.cache, updating libs cache..."
71 /sbin/ldconfig
72 fi