Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fw-initramfs.git;a=commitdiff;h=575bb64913bcab908f48e1474dcea6937a79bdb9

commit 575bb64913bcab908f48e1474dcea6937a79bdb9
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Thu Nov 5 20:25:59 2009 +0100

init_functions
*some functions for initramfs

diff --git a/init_functions.sh b/init_functions.sh
new file mode 100644
index 0000000..68ce182
--- /dev/null
+++ b/init_functions.sh
@@ -0,0 +1,139 @@
+#!/bin/ash
+
+. /etc/modules.sh
+
+NORMAL="\033[0m"
+WARN="\033[33;1m"
+BAD="\033[31;1m"
+BOLD="\033[1m"
+GOOD="\033[32;1m"
+
+
+KV=`uname -r`
+KMAJOR=`echo $KV | cut -f1 -d.`
+KMINOR=`echo $KV | cut -f2 -d.`
+KVER="${KMAJOR}.${KMINOR}"
+
+
+#Function for parsing command line options with "=" in them
+# get_opt("init=/sbin/init") will return "/sbin/init"
+get_opt() {
+       echo "$@" | cut -d "=" -f 2
+}
+
+backup() {
+       echo -ne "\033[0G\033[0K"
+}
+
+# msg functions arguments
+# $1 string
+# $2 hide flag
+
+good_msg() {
+       msg_string=$1
+       msg_string="${msg_string:-...}"
+       [ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} 
${NORMAL}"
+}
+
+bad_msg() {
+       msg_string=$1
+       msg_string="${msg_string:-...}"
+       if [ "$2" != 1 ]
+       then
+               echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
+       fi
+}
+
+warn_msg() {
+       msg_string=$1
+       msg_string="${msg_string:-...}"
+       [ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} 
${NORMAL}"
+}
+
+mount_sysfs() {
+       mount -t sysfs /sys /sys >/dev/null 2>&1
+       ret=$?
+       [ "$ret" -eq '0' ] || bad_msg "Failed to mount /sys!"
+}
+
+setup_hotplug() {
+       echo /sbin/mdev > /proc/sys/kernel/hotplug
+}
+
+
+sdelay() {
+       # Sleep a specific number of seconds if SDELAY is set otherwise only 
sleep
+       # 1 second
+       if [ -n "${SDELAY}" ]
+       then
+               sleep ${SDELAY}
+       else
+               sleep 1
+       fi
+}
+
+rundebugshell() {
+       if [ -n "$DEBUG" ]
+       then
+               good_msg 'Starting debug shell as requested by "debug" option.'
+               good_msg 'Type "exit" to continue with normal bootup.'
+               [ -x /bin/sh ] && /bin/sh || /bin/ash
+       fi
+}
+
+
+load_modules() {
+       # Load modules listed in MY_HWOPTS if /lib/modules exists for the 
running
+       # kernel version
+       if [ -d "/lib/modules/${KV}" ]
+       then
+               good_msg 'Loading modules'
+               # Load appropriate kernel modules
+               MOD_EXT=".ko"
+
+               for module in $ALL_MODULES
+               do
+                       #FIXME Test if module is allready loaded
+                       [ -n "${DEBUG}" ] && echo -ne "${BOLD}   ::${NORMAL} 
Checking for ${x}..."
+                       # find -name does not work since the return status is 
always zero
+                       ModuleFile=`find "/lib/modules/${KV}" | grep 
${module}${MOD_EXT}`
+                       if [ -e $ModuleFile ]
+                       then
+                               echo -ne "${BOLD}   ::${NORMAL} Scanning for 
${module}..."
+                               #modprobe ${module} >> /log.txt
+                               modprobe ${module} 2>/dev/null 1> /dev/null
+                               if [ $? == 0 ]; then
+                                 echo "${module} module loaded"
+                               fi
+#if [ $? == 0 ]; then
+#  echo "$dev module loaded"
+#fi
+#do modprobe $dev 2>/dev/null 1> /dev/null
+#if [ $? == 0 ]; then
+#  echo "$dev module loaded"
+#fi
+                               backup
+                               echo -ne "${NORMAL}"
+                       fi
+               done
+       else
+               good_msg 'Skipping module load; no modules in the ramdisk for !'
+       fi
+}
+
+uppercase(){
+       # needs tr on busybox
+       echo $1 | tr 'a-z' 'A-Z'
+}
+
+runmdev() {
+       # busybox udev replacement
+       touch /etc/mdev.conf
+       mdev -s
+}
+
+swsusp_resume() {
+       # determine swap resume partition
+       local device=$(ls -lL "${REAL_RESUME}" | sed 's/\  */ /g' | cut -d \  
-f 5-6 | sed 's/,\ */:/')
+       [ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume
+}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to