slitaz-boot-scripts rev 160

bootopts.sh: Improve, clean and speed up boot options
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 26 16:11:54 2009 +0200 (2009-04-26)
parents 9bde17542c66
children 2f1bca639842
files etc/init.d/bootopts.sh
line diff
     1.1 --- a/etc/init.d/bootopts.sh	Sun Apr 26 15:19:34 2009 +0200
     1.2 +++ b/etc/init.d/bootopts.sh	Sun Apr 26 16:11:54 2009 +0200
     1.3 @@ -1,7 +1,7 @@
     1.4  #!/bin/sh
     1.5  # /etc/init.d/bootopts.sh - SliTaz boot options from the cmdline.
     1.6  #
     1.7 -# Earlier boot options are in rcS: config= and modprobe=
     1.8 +# Earlier boot options are in rcS, ex: config= and modprobe=
     1.9  #
    1.10  . /etc/init.d/rc.functions
    1.11  
    1.12 @@ -62,36 +62,8 @@
    1.13  	fi
    1.14  }
    1.15  
    1.16 -# Mount all ext3 partitions found (opt: mount).
    1.17 -mount_partitions()
    1.18 -{
    1.19 -	# Get the list of partitions.
    1.20 -	DEVICES_LIST=`fdisk -l | grep 83 | cut -d " " -f 1`
    1.21 -	# Mount filesystems rw.
    1.22 -	for device in $DEVICES_LIST
    1.23 -	do
    1.24 -		name=${device#/dev/}
    1.25 -		# Device can be already used by home=usb.
    1.26 -		if ! mount | grep ^$device >/dev/null; then
    1.27 -			echo "Mounting partition: $name on /mnt/$name"
    1.28 -			mkdir /mnt/$name
    1.29 -			mount $device /mnt/$name
    1.30 -		fi
    1.31 -	done
    1.32 -}
    1.33 -
    1.34 -# Parse /proc/cmdline with grep.
    1.35 -#
    1.36 -
    1.37 -echo "Parsing kernel cmdline for SliTaz live options... "
    1.38 -
    1.39 -# eject: Eject cdrom
    1.40 -if grep -q -w "eject" /proc/cmdline; then
    1.41 -	eject /dev/cdrom
    1.42 -fi
    1.43 -
    1.44 -# user=name: Default user account without password (uid=1000).
    1.45 -#
    1.46 +# Default user account without password (uid=1000). In live mode the option
    1.47 +# user=name can be used, but user must be add before home= to have home dir.
    1.48  if ! grep -q "1000:1000" /etc/passwd; then
    1.49  	if grep -q "user=" /proc/cmdline; then
    1.50  		USER=`cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/'`
    1.51 @@ -130,23 +102,96 @@
    1.52  	fi
    1.53  fi
    1.54  
    1.55 -# Autologin option to skip first graphic login prompt.
    1.56 -if grep -q "autologin" /proc/cmdline; then
    1.57 -        echo "auto_login        yes" >> /etc/slim.conf
    1.58 +# Parse /proc/cmdline for boot options.
    1.59 +echo "Parsing kernel cmdline for SliTaz live options... "
    1.60 +for opt in `cat /proc/cmdline`
    1.61 +do
    1.62 +	case $opt in
    1.63 +		eject)
    1.64 +			# Eject cdrom.
    1.65 +			eject /dev/cdrom ;;
    1.66 +		autologin)
    1.67 +			# Autologin option to skip first graphic login prompt.
    1.68 +			echo "auto_login        yes" >> /etc/slim.conf ;;
    1.69 +		home=usb)
    1.70 +			# home=usb is a shoter and easy way to have home=/dev/sda1.
    1.71 +			DEVICE=sda1
    1.72 +			mount_home ;;
    1.73 +		home=*)
    1.74 +			# Check for a specified home directory (home=*).
    1.75 +			DEVICE=${opt#home=}
    1.76 +			mount_home ;;
    1.77 +		lang=*)
    1.78 +			# Check for a specified locale (lang=*).
    1.79 +			LANG=${opt#lang=}
    1.80 +			echo -n "Setting system locale to: $LANG... "
    1.81 +			echo "LANG=$LANG" > /etc/locale.conf
    1.82 +			echo "LC_ALL=$LANG" >> /etc/locale.conf
    1.83 +			status ;;
    1.84 +		kmap=*)
    1.85 +			# Check for a specified keymap (kmap=*).
    1.86 +			KEYMAP=${opt#kmap=}
    1.87 +			echo -n "Setting system keymap to: $KEYMAP..."
    1.88 +			echo "$KEYMAP" > /etc/keymap.conf
    1.89 +			status ;;
    1.90 +		laptop)
    1.91 +			# Laptop option to load ac and battery Kernel modules.
    1.92 +			echo "Loading laptop modules: ac, battery, yenta_socket..."
    1.93 +			modprobe ac
    1.94 +			modprobe battery
    1.95 +			modprobe yenta_socket ;;
    1.96 +		mount)
    1.97 +			# Mount all ext3 partitions found (opt: mount).
    1.98 +			# Get the list of partitions.
    1.99 +			DEVICES_LIST=`fdisk -l | grep 83 | cut -d " " -f 1`
   1.100 +			# Mount filesystems rw.
   1.101 +			for device in $DEVICES_LIST
   1.102 +			do
   1.103 +				name=${device#/dev/}
   1.104 +				# Device can be already used by home=usb.
   1.105 +				if ! mount | grep ^$device >/dev/null; then
   1.106 +					echo "Mounting partition: $name on /mnt/$name"
   1.107 +					mkdir /mnt/$name
   1.108 +					mount $device /mnt/$name
   1.109 +				fi
   1.110 +			done ;;
   1.111 +		mount-packages)
   1.112 +			# Mount and install packages-XXX.iso (usefull without Internet 
   1.113 +			# connection).
   1.114 +			PKGSIGN="LABEL=\"packages-$(cat /etc/slitaz-release)\" TYPE=\"iso9660\""
   1.115 +			PKGDEV=$(blkid | grep "$PKGSIGN" | cut -d: -f1)
   1.116 +			[ -z "$PKGDEV" -a -L /dev/cdrom ] && \
   1.117 +				PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
   1.118 +			if [ -n "$PKGDEV" ]; then
   1.119 +				echo -n "Mounting packages archive from $PKGDEV..."
   1.120 +				mkdir /packages && mount -t iso9660 -o ro $PKGDEV /packages
   1.121 +				status
   1.122 +				/packages/install.sh
   1.123 +			fi ;;
   1.124 +		wm=*)
   1.125 +			# Check for a Window Manager (for a flavor, default WM can be changed
   1.126 +			# with boot option or with an addfile in /etc/X11/wm.default.
   1.127 +			WM=${opt#wm=}
   1.128 +			mkdir -p /etc/X11
   1.129 +			case $WM in
   1.130 +				jwm)
   1.131 +					echo "jwm" > /etc/X11/wm.default ;;
   1.132 +				ob|openbox|openbox-session)
   1.133 +					echo "openbox" > /etc/X11/wm.default ;;
   1.134 +				e17|enlightenment|enlightenment_start)
   1.135 +					echo "enlightenment" > /etc/X11/wm.default ;;
   1.136 +			esac
   1.137 +		*)
   1.138 +			continue ;;
   1.139 +	esac
   1.140 +done
   1.141 +
   1.142 +# If no default WM fallback to Openbox (we never know).
   1.143 +if [ ! -f /etc/X11/wm.default ]; then
   1.144 +	echo "openbox" > /etc/X11/wm.default
   1.145  fi
   1.146  
   1.147 -# Check for a specified home directory on cmdline (home=*).
   1.148 -#
   1.149 -if grep -q "home=usb" /proc/cmdline; then
   1.150 -	DEVICE=sda1
   1.151 -	mount_home
   1.152 -elif grep -q "home=" /proc/cmdline; then
   1.153 -	DEVICE=`cat /proc/cmdline | sed 's/.*home=\([^ ]*\).*/\1/'`
   1.154 -	mount_home
   1.155 -fi
   1.156 -
   1.157 -# Activate an eventual swap file in /home and on local HD.
   1.158 -#
   1.159 +# Activate an eventual swap file or partition.
   1.160  if [ "`fdisk -l | grep swap`" ]; then
   1.161  	for SWAP_DEV in `fdisk -l | grep swap | awk '{ print $1 }'`; do
   1.162  		echo "Swap memory detected on: $SWAP_DEV"
   1.163 @@ -157,69 +202,3 @@
   1.164  	echo "Activating swap memory..."
   1.165  	swapon -a
   1.166  fi
   1.167 -
   1.168 -# Check for a specified locale (lang=*).
   1.169 -#
   1.170 -if grep -q "lang=*" /proc/cmdline; then
   1.171 -	LANG=`cat /proc/cmdline | sed 's/.*lang=\([^ ]*\).*/\1/'`
   1.172 -	echo -n "Setting system locale to: $LANG... "
   1.173 -	echo "LANG=$LANG" > /etc/locale.conf
   1.174 -	echo "LC_ALL=$LANG" >> /etc/locale.conf
   1.175 -	status
   1.176 -fi
   1.177 -
   1.178 -# Check for a specified keymap (kmap=*).
   1.179 -#
   1.180 -if grep -q "kmap=*" /proc/cmdline; then
   1.181 -	KEYMAP=`cat /proc/cmdline | sed 's/.*kmap=\([^ ]*\).*/\1/'`
   1.182 -	echo -n "Setting system keymap to: $KEYMAP..."
   1.183 -	echo "$KEYMAP" > /etc/keymap.conf
   1.184 -	status
   1.185 -fi
   1.186 -
   1.187 -# Laptop option to load ac and battery Kernel modules.
   1.188 -if grep -q "laptop" /proc/cmdline; then
   1.189 -	echo "Loading laptop modules: ac, battery, yenta_socket..."
   1.190 -	modprobe ac
   1.191 -	modprobe battery
   1.192 -	modprobe yenta_socket
   1.193 -fi
   1.194 -
   1.195 -# Check for a Window Manager (for a flavor, default WM can be changed
   1.196 -# with boot option or with an addfile in /etc/X11/wm.default.
   1.197 -if grep -q "wm=" /proc/cmdline; then
   1.198 -	mkdir -p /etc/X11
   1.199 -	WM=`cat /proc/cmdline | sed 's/.*wm=\([^ ]*\).*/\1/'`
   1.200 -	case $WM in
   1.201 -		jwm)
   1.202 -			echo "jwm" > /etc/X11/wm.default ;;
   1.203 -		ob|openbox|openbox-session)
   1.204 -			echo "openbox" > /etc/X11/wm.default ;;
   1.205 -		e17|enlightenment|enlightenment_start)
   1.206 -			echo "enlightenment" > /etc/X11/wm.default ;;
   1.207 -	esac
   1.208 -else
   1.209 -	# If no default WM fallback to Openbox.
   1.210 -	if [ ! -f /etc/X11/wm.default ]; then
   1.211 -		echo "openbox" > /etc/X11/wm.default
   1.212 -	fi
   1.213 -fi
   1.214 -
   1.215 -# Check for option mount.
   1.216 -if grep -q "mount" /proc/cmdline; then
   1.217 -	mount_partitions
   1.218 -fi
   1.219 -
   1.220 -# Mount and install packages-XXX.iso (usefull without Internet connection)
   1.221 -if grep -q " mount-packages" /proc/cmdline; then
   1.222 -	PKGSIGN="LABEL=\"packages-$(cat /etc/slitaz-release)\" TYPE=\"iso9660\""
   1.223 -	PKGDEV=$(blkid | grep "$PKGSIGN" | cut -d: -f1)
   1.224 -	[ -z "$PKGDEV" -a -L /dev/cdrom ] && PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
   1.225 -	if [ -n "$PKGDEV" ]; then
   1.226 -		echo -n "Mounting packages archive from $PKGDEV..."
   1.227 -		mkdir /packages && mount -t iso9660 -o ro $PKGDEV /packages
   1.228 -		status
   1.229 -		/packages/install.sh
   1.230 -	fi
   1.231 -fi
   1.232 -