slitaz-boot-scripts rev 165

move function mount_home (used only once) to home= case
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 26 17:12:27 2009 +0200 (2009-04-26)
parents cdbc958f594e
children 6d0cd1b906c6
files etc/init.d/bootopts.sh
line diff
     1.1 --- a/etc/init.d/bootopts.sh	Sun Apr 26 17:03:19 2009 +0200
     1.2 +++ b/etc/init.d/bootopts.sh	Sun Apr 26 17:12:27 2009 +0200
     1.3 @@ -13,54 +13,6 @@
     1.4  EOT
     1.5  }
     1.6  
     1.7 -# Check if swap file must be generated in /home: swap=size (Mb).
     1.8 -# This option is used with home=device.
     1.9 -gen_home_swap()
    1.10 -{
    1.11 -	if grep -q "swap=[1-9]*" /proc/cmdline; then
    1.12 -		SWAP_SIZE=`cat /proc/cmdline | sed 's/.*swap=\([^ ]*\).*/\1/'`
    1.13 -		# DD to gen a virtual disk.
    1.14 -		echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
    1.15 -		dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
    1.16 -		# Make the Linux swap filesystem.
    1.17 -		mkswap /home/swap
    1.18 -		add_swap_in_fstab /home/swap
    1.19 -	fi
    1.20 -}
    1.21 -
    1.22 -# Mount /home and check for user home dir.
    1.23 -mount_home()
    1.24 -{
    1.25 -	echo "Home has been specified to $DEVICE..."
    1.26 -	USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
    1.27 -	USBDELAY=$((1+$USBDELAY))
    1.28 -	echo "Sleeping $USBDELAY s to let the kernel detect the device... "
    1.29 -	sleep $USBDELAY
    1.30 -	USER=`cat /etc/passwd | grep 1000 | cut -d ":" -f 1`
    1.31 -	DEVID=$DEVICE
    1.32 -	if [ -x /sbin/blkid ]; then
    1.33 -		# Can be label, uuid or devname. DEVID give us first: /dev/name.
    1.34 -		DEVID=`/sbin/blkid | grep $DEVICE | cut -d: -f1`
    1.35 -		DEVID=${DEVID##*/}
    1.36 -	fi
    1.37 -	if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then
    1.38 -		echo "Mounting /home on /dev/$DEVID... "
    1.39 -		mv /home/$USER /tmp/$USER-files
    1.40 -		mount /dev/$DEVID /home -o uid=1000,gid=1000 2>/dev/null \
    1.41 -			|| mount /dev/$DEVID /home
    1.42 -		gen_home_swap
    1.43 -	else
    1.44 -		echo "Unable to find $DEVICE... "
    1.45 -	fi
    1.46 -	# Move all user dir if needed.
    1.47 -	if [ ! -d "/home/$USER" ] ; then
    1.48 -		mv /tmp/$USER-files /home/$USER
    1.49 -		chown -R $USER.$USER /home/$USER
    1.50 -	else
    1.51 -		rm -rf /tmp/$USER-files
    1.52 -	fi
    1.53 -}
    1.54 -
    1.55  # Default user account without password (uid=1000). In live mode the option
    1.56  # user=name can be used, but user must be add before home= to have home dir.
    1.57  # This option is not handled by a loop and case like other and without
    1.58 @@ -115,12 +67,6 @@
    1.59  		autologin)
    1.60  			# Autologin option to skip first graphic login prompt.
    1.61  			echo "auto_login        yes" >> /etc/slim.conf ;;
    1.62 -		home=*)
    1.63 -			# Check for a specified home directory (home=*). Note:
    1.64 -			# home=usb is a shoter and easy way to have home=/dev/sda1.
    1.65 -			DEVICE=${opt#home=}
    1.66 -			[ "$DEVICE" = "usb" ] && DEVICE=sda1
    1.67 -			mount_home ;;
    1.68  		lang=*)
    1.69  			# Check for a specified locale (lang=*).
    1.70  			LANG=${opt#lang=}
    1.71 @@ -134,6 +80,50 @@
    1.72  			echo -n "Setting system keymap to: $KEYMAP..."
    1.73  			echo "$KEYMAP" > /etc/keymap.conf
    1.74  			status ;;
    1.75 +		home=*)
    1.76 +			# Check for a specified home partition (home=*) and check for 
    1.77 +			# user home dir. Note: home=usb is a shoter and easier way to
    1.78 +			# have home=/dev/sda1.
    1.79 +			DEVICE=${opt#home=}
    1.80 +			[ "$DEVICE" = "usb" ] && DEVICE=sda1
    1.81 +			echo "Home has been specified to $DEVICE..."
    1.82 +			USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
    1.83 +			USBDELAY=$((1+$USBDELAY))
    1.84 +			echo "Sleeping $USBDELAY s to let the kernel detect the device... "
    1.85 +			sleep $USBDELAY
    1.86 +			USER=`cat /etc/passwd | grep 1000 | cut -d ":" -f 1`
    1.87 +			DEVID=$DEVICE
    1.88 +			if [ -x /sbin/blkid ]; then
    1.89 +				# Can be label, uuid or devname. DEVID give us first: /dev/name.
    1.90 +				DEVID=`/sbin/blkid | grep $DEVICE | cut -d: -f1`
    1.91 +				DEVID=${DEVID##*/}
    1.92 +			fi
    1.93 +			if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then
    1.94 +				echo "Mounting /home on /dev/$DEVID... "
    1.95 +				mv /home/$USER /tmp/$USER-files
    1.96 +				mount /dev/$DEVID /home -o uid=1000,gid=1000 2>/dev/null \
    1.97 +					|| mount /dev/$DEVID /home
    1.98 +				# Check if swap file must be generated in /home: swap=size (Mb).
    1.99 +				# This option is only used within home=device.
   1.100 +				if grep -q "swap=[1-9]*" /proc/cmdline; then
   1.101 +					SWAP_SIZE=`cat /proc/cmdline | sed 's/.*swap=\([^ ]*\).*/\1/'`
   1.102 +					# DD to gen a virtual disk.
   1.103 +					echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
   1.104 +					dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
   1.105 +					# Make the Linux swap filesystem.
   1.106 +					mkswap /home/swap
   1.107 +					add_swap_in_fstab /home/swap
   1.108 +				fi
   1.109 +			else
   1.110 +				echo "Unable to find $DEVICE... "
   1.111 +			fi
   1.112 +			# Move all user dir if needed.
   1.113 +			if [ ! -d "/home/$USER" ] ; then
   1.114 +				mv /tmp/$USER-files /home/$USER
   1.115 +				chown -R $USER.$USER /home/$USER
   1.116 +			else
   1.117 +				rm -rf /tmp/$USER-files
   1.118 +			fi ;;
   1.119  		laptop)
   1.120  			# Laptop option to load ac and battery Kernel modules.
   1.121  			echo "Loading laptop modules: ac, battery, fan, yenta_socket..."