#!/bin/sh # Usage: modload [force] TMPFILE=/tmp/.load.tmp.$$ MODFILE=/var/flash/freetz trap "rm -f $TMPFILE" EXIT [ -d "/tmp/flash" -a "$1" != "force" ] && exit 0 echo -n "Loading $MODFILE ... " if cat $MODFILE > $TMPFILE 2> /dev/null; then if tar -xf $TMPFILE -C /tmp/ 2> /dev/null; then echo 'done.' else echo 'failed.' echo -n "Creating $MODFILE ... " mkdir -p /tmp/flash tar -cf $MODFILE -C /tmp flash echo 'done.' fi else echo 'does not exist.' echo -n "Creating $MODFILE ... " mkdir -p /tmp/flash tar -cf $MODFILE -C /tmp flash echo 'done.' fi [ -d /tmp/flash/mod ] || mkdir -p /tmp/flash/mod # # Symlink file (of specific type) into the /mod tree; an absolute path # must be passed # lnmod() { local test=$1 file=$2 if [ "$test" "$file" -a ! -e "/mod${file}" ]; then ln -s "$file" "/mod${file}" fi } echo -n 'Loading users, groups and passwords ... ' /usr/bin/modusers load echo 'done.' echo -n 'Loading hosts ... ' /usr/bin/modhosts load echo 'done.' echo -n 'Loading config ... ' if [ -e /etc/static.pkg ]; then for pkg in $(cat /etc/static.pkg) avm; do [ -e "/mod/pkg/$pkg" ] || ln -s / "/mod/pkg/$pkg" lnmod -d "/etc/default.$pkg" lnmod -d "/usr/lib/cgi-bin/$pkg" lnmod -x "/usr/lib/cgi-bin/$pkg.cgi" lnmod -x "/etc/init.d/rc.$pkg" [ -r "/etc/default.$pkg/$pkg.cfg" ] && /usr/bin/modconf load "$pkg" done fi /usr/bin/modconf load avm echo 'done.' echo -n 'Loading modules ... ' for MODULE in fat vfat mbcache ext2 jbd ext3 crc16 jbd2 ext4 reiserfs nls_utf8 hfsplus ipv6; do [ -e /lib/modules/*/kernel/*/*/${MODULE}.ko ] && modprobe $MODULE done if [ -r /tmp/flash/mod/modules ]; then grep -v "^ *#" /tmp/flash/mod/modules | while read -r module; do [ -n "$module" ] && modprobe ${module%.ko} done fi echo 'done.' exit 0