slitaz-boot-scripts diff etc/init.d/bootopts.sh @ rev 263
Clean up network.sh and use fgrep when possible in rcS
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon May 16 00:51:01 2011 +0200 (2011-05-16) |
parents | f1c0f8f8c116 |
children | 9c574bdd563f |
line diff
1.1 --- a/etc/init.d/bootopts.sh Fri Apr 29 21:06:53 2011 +0200 1.2 +++ b/etc/init.d/bootopts.sh Mon May 16 00:51:01 2011 +0200 1.3 @@ -13,6 +13,38 @@ 1.4 EOT 1.5 } 1.6 1.7 +# Default user account without password (uid=1000). In live mode the option 1.8 +# user=name can be used, but user must be added before home= to have home dir. 1.9 +# This option is not handled by a loop and case like others and has no 1.10 +# effect on an installed system. 1.11 +if ! grep -q "100[0-9]:100[0-9]" /etc/passwd; then 1.12 + if grep -q "user=" /proc/cmdline; then 1.13 + USER=`cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/'` 1.14 + # Avoid usage of an existing system user or root. 1.15 + if grep -q ^$USER /etc/passwd; then 1.16 + USER=tux 1.17 + fi 1.18 + else 1.19 + USER=tux 1.20 + fi 1.21 + echo -n "Configuring user and group: $USER..." 1.22 + adduser -D -s /bin/sh -g "SliTaz User" -G users -h /home/$USER $USER 1.23 + passwd -d $USER >/dev/null 1.24 + status 1.25 + # Audio and cdrom group. 1.26 + addgroup $USER audio 1.27 + addgroup $USER cdrom 1.28 + addgroup $USER video 1.29 + addgroup $USER tty 1.30 + # make user be only read/write by user 1.31 + chmod -R 700 /home/$USER 1.32 + # Slim default user. 1.33 + if [ -f /etc/slim.conf ]; then 1.34 + sed -i s/"default_user .*"/"default_user $USER"/\ 1.35 + /etc/slim.conf 1.36 + fi 1.37 +fi 1.38 + 1.39 # Parse /proc/cmdline for boot options. 1.40 echo "Parsing kernel cmdline for SliTaz live options... " 1.41 1.42 @@ -22,6 +54,86 @@ 1.43 eject) 1.44 # Eject cdrom. 1.45 eject /dev/cdrom ;; 1.46 + autologin) 1.47 + # Autologin option to skip first graphic login prompt. 1.48 + echo "auto_login yes" >> /etc/slim.conf ;; 1.49 + lang=*) 1.50 + # Check for a specified locale (lang=*). 1.51 + LANG=${opt#lang=} 1.52 + echo -n "Setting system locale to: $LANG... " 1.53 + echo "LANG=$LANG" > /etc/locale.conf 1.54 + echo "LC_ALL=$LANG" >> /etc/locale.conf 1.55 + [ ! -d /usr/lib/locale/$LANG ] && localedef \ 1.56 + -i $LANG -c -f UTF-8 /usr/lib/locale/$LANG & 1.57 + tazlocale link-files 1.58 + status ;; 1.59 + kmap=*) 1.60 + # Check for a specified keymap (kmap=*). 1.61 + KEYMAP=${opt#kmap=} 1.62 + echo -n "Setting system keymap to: $KEYMAP..." 1.63 + echo "$KEYMAP" > /etc/keymap.conf 1.64 + status ;; 1.65 + home=*) 1.66 + # Check for a specified home partition (home=*) and check for 1.67 + # user home dir. Note: home=usb is a shorter and easier way to 1.68 + # have home=/dev/sda1. 1.69 + DEVICE=${opt#home=} 1.70 + [ "$DEVICE" = "usb" ] && DEVICE=sda1 1.71 + echo "Home has been specified to $DEVICE..." 1.72 + DEVID=`/sbin/blkid | sed 'p;s/"//g' | grep "$DEVICE" | sed 's/:.*//;q'` 1.73 + if [ -z "$DEVID" ]; then 1.74 + USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use` 1.75 + USBDELAY=$((2+$USBDELAY)) 1.76 + echo "Sleeping $USBDELAY s to let the kernel detect the device... " 1.77 + sleep $USBDELAY 1.78 + fi 1.79 + USER=`cat /etc/passwd | sed '/:1000:/!d;s/:.*//;q'` 1.80 + DEVID=$DEVICE 1.81 + if [ -x /sbin/blkid ]; then 1.82 + # Can be a label, uuid, type or devname. DEVID gives us first: /dev/name. 1.83 + DEVID=`/sbin/blkid | sed 'p;s/"//g' | grep "$DEVICE" | sed 's/:.*//;q'` 1.84 + fi 1.85 + DEVID=${DEVID##*/} 1.86 + if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then 1.87 + echo "Mounting /home on /dev/$DEVID... " 1.88 + [ -d /home/$USER ] && mv /home/$USER /tmp/$USER-files 1.89 + mount /dev/$DEVID /home -o uid=1000,gid=1000 2>/dev/null \ 1.90 + || mount /dev/$DEVID /home 1.91 + # Check if swap file must be generated in /home: swap=size (Mb). 1.92 + # This option is only used within home=device. 1.93 + if grep -q "swap=[1-9]*" /proc/cmdline; then 1.94 + SWAP_SIZE=`sed 's/.*swap=\([^ ]*\).*/\1/' < /proc/cmdline` 1.95 + # DD to gen a virtual disk. 1.96 + echo "Generating swap file: /home/swap ($SWAP_SIZE)..." 1.97 + dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE 1.98 + # Make the Linux swap filesystem. 1.99 + mkswap /home/swap 1.100 + add_swap_in_fstab /home/swap 1.101 + fi 1.102 + else 1.103 + echo "Unable to find $DEVICE... " 1.104 + fi 1.105 + # Move all user dir if needed. 1.106 + if [ ! -d "/home/$USER" ] ; then 1.107 + mv /tmp/$USER-files /home/$USER 1.108 + chown -R $USER.users /home/$USER 1.109 + else 1.110 + rm -rf /tmp/$USER-files 1.111 + fi 1.112 + # Install all packages in /home/boot/packages. In live CD and 1.113 + # USB mode the option home= mounts the device on /home, so we 1.114 + # already have a boot directory with the Kernel and rootfs. 1.115 + if [ -d "/home/boot/packages" ]; then 1.116 + for pkg in /home/boot/packages/*.tazpkg 1.117 + do 1.118 + tazpkg install $pkg 1.119 + done 1.120 + fi 1.121 + # We can have custom files in /home/boot/rootfs to overwrite 1.122 + # the one packed into the Live system. 1.123 + if [ -d "/home/boot/rootfs" ]; then 1.124 + cp -a /home/boot/rootfs/* / 1.125 + fi ;; 1.126 laptop) 1.127 # Laptop option to load related Kernel modules. 1.128 echo "Loading laptop modules: ac, battery, fan, yenta_socket..." 1.129 @@ -62,11 +174,29 @@ 1.130 status 1.131 /packages/install.sh 1.132 fi ;; 1.133 + wm=*) 1.134 + # Check for a Window Manager (for a flavor, default WM can be changed 1.135 + # with boot options or with an addfile in /etc/X11/wm.default. 1.136 + WM=${opt#wm=} 1.137 + mkdir -p /etc/X11 1.138 + case $WM in 1.139 + jwm) 1.140 + echo "jwm" > /etc/X11/wm.default ;; 1.141 + ob|openbox|openbox-session) 1.142 + echo "openbox" > /etc/X11/wm.default ;; 1.143 + e17|enlightenment|enlightenment_start) 1.144 + echo "enlightenment" > /etc/X11/wm.default ;; 1.145 + esac ;; 1.146 *) 1.147 continue ;; 1.148 esac 1.149 done 1.150 1.151 +# If no default WM fallback to Openbox (we never know). 1.152 +if [ ! -f /etc/X11/wm.default ]; then 1.153 + echo "openbox" > /etc/X11/wm.default 1.154 +fi 1.155 + 1.156 # Activate an eventual swap file or partition. 1.157 if [ "`fdisk -l | grep swap`" ]; then 1.158 for SWAP_DEV in `fdisk -l | sed '/swap/!d;s/ .*//'`; do