Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fw-initramfs.git;a=commitdiff;h=e76a411bbcbbfd3d2916134a25e2b3e697cb3a8a
commit e76a411bbcbbfd3d2916134a25e2b3e697cb3a8a Author: bouleetbil <bouleet...@frogdev.info> Date: Thu Nov 5 20:25:20 2009 +0100 init *init for initramfs diff --git a/init b/init new file mode 100755 index 0000000..dc053bc --- /dev/null +++ b/init @@ -0,0 +1,134 @@ +#!/bin/sh + +PATH="/usr/sbin:/usr/bin:/sbin:/bin" + +. /etc/init_functions.sh + +mount -t proc proc /proc >/dev/null 2>&1 +mount -o remount,rw / >/dev/null 2>&1 + +echo "/sbin/modprobe" > /proc/sys/kernel/modprobe + +#Disable kernel messages from popping onto the screen +echo 0 > /proc/sys/kernel/printk + +#Clear the screen +clear + +#Create all the symlinks to /bin/busybox +busybox --install -s + +#Create device nodes +mknod /dev/tty c 5 0 + +#lvm +if [ -e /bin/lvm ] +then + ln -s /bin/lvm /bin/vgscan + ln -s /bin/lvm /bin/vgchange +fi + + +#Defaults +init="/sbin/init" +root="/dev/hda1" + +#Process command line options +for i in $(cat /proc/cmdline); do + case $i in + root\=*) + root=$(get_opt $i) + ;; + init\=*) + init=$(get_opt $i) + ;; + # Scan delay options (usb for exemple) + scandelay\=*) + SDELAY=$(get_opt $i) + ;; + # Debug Options + debug) + DEBUG='yes' + ;; + #for delete save suspend + real_resume\=*|resume\=*) + REAL_RESUME=$(get_opt $i) + ;; + bootusb) +      BOOTUSB=1 +    ;; + esac +done + + +#Mount things needed by this script +mount_sysfs + +# Setup hotplugging for firmware loading +setup_hotplug + +#load modules +load_modules + +#resume +#swsusp_resume + +# Delay if needed for USB hardware +sdelay + +cd /sys +good_msg 'Activating mdev' +runmdev +cd / + +if [ "${BOOTUSB}" -eq '1' ] ; then +           #create mount dir +           mkdir /key +           for a in `find /dev/ -name [sh]???` +           do +               mount $a /key +               #wait the time to mount usb +               sleep 10 +               #search the file FrugalMove +               if [ -e /key/FrugalMove ] +               then +                    root="${a}" +                    #update fstab +                    rm /key/etc/fstab 2>/dev/null +                    cp /key/etc/fstab.new /key/etc/fstab +                    echo "${a}    /    ext3   defaults    1 1 " >> /key/etc/fstab +                    umount /key 2>/dev/null +                    break +               fi +               umount /key 2>/dev/null +           done  +         +           rm -R /key 2>/dev/null +fi + + + +# Run debug shell if requested +rundebugshell + +echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}" + +#Mount the root device +mount "${root}" /newroot + +#Check if $init exists and is executable +if [[ -x "/newroot/${init}" ]] ; then + #Unmount all other mounts so that the ram used by + #the initramfs can be cleared after switch_root + umount /sys /proc + + #Switch to the new root and execute init + exec switch_root /newroot "${init}" +fi + + + +#This will only be run if the exec above failed +bad_msg 'Failed to switch_root, dropping to a shell' +exec sh +
_______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git