slitaz-boot-scripts view etc/init.d/bootopts.sh @ rev 33

Modify home=* again...
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 23 19:40:09 2008 +0100 (2008-02-23)
parents 8d77d0bba811
children 85421faee535
line source
1 #!/bin/sh
2 # /etc/init.d/bootopts.sh - SliTaz boot options from the cmdline.
3 #
4 . /etc/init.d/rc.functions
6 # Mount /home and check for user hacker home dir.
7 #
8 mount_home()
9 {
10 echo "Home has been specified to $DEVICE..."
11 echo "Sleeping 10 s to let the kernel detect the device... "
12 sleep 10
14 DEVID=$DEVICE
15 if [ -x /sbin/blkid ]; then
16 # Can be label, uuid or devname. DEVID give us /dev/name and
17 # DEVICE give us disk name without /dev/.
18 DEVID=`/sbin/blkid | grep $DEVICE | cut -d: -f1`
19 fi
20 if [ -n "$DEVID" ] && grep -q "$DEVICE" /proc/partitions ; then
21 echo "Mounting /home on /dev/$DEVICE... "
22 mv /home/hacker /tmp/hacker-home
23 mount -o uid=500,gid=500 /dev/$DEVICE /home
24 else
25 echo "Unable to find $DEVICE... "
26 fi
27 # Move all hacker dir if needed.
28 if [ ! -d "/home/hacker" ] ; then
29 mv /tmp/hacker-home /home/hacker
30 chown -R hacker.hacker /home/hacker
31 else
32 rm -rf /tmp/hacker-home
33 fi
34 }
36 # Check if swap file must be generated in /home: swap=size (Mb).
37 # This option is used with home=device.
38 gen_home_swap()
39 {
40 if grep -q "swap=[1-9]*" /proc/cmdline; then
41 SWAP_SIZE=`cat /proc/cmdline | sed 's/.*swap=\([^ ]*\).*/\1/'`
42 # DD to gen a virtual disk.
43 echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
44 dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
45 # Make the Linux swap filesystem.
46 mkswap /home/swap
47 fi
48 }
50 # Parse /proc/cmdline with grep.
51 #
53 echo "Parsing kernel cmdline for SliTaz live options... "
55 # Check for a specified home directory on cmdline (home=*).
56 #
57 if grep -q "home=usb" /proc/cmdline; then
58 DEVICE=sda1
59 mount_home
60 gen_home_swap
61 elif grep -q "home=" /proc/cmdline; then
62 DEVICE=`cat /proc/cmdline | sed 's/.*home=\([^ ]*\).*/\1/'`
63 mount_home
64 gen_home_swap
65 fi
67 # Active an eventual swap file in /home and on local hd.
68 #
69 if [ -f "/home/swap" ]; then
70 echo "Activing swap (/home/swap) memory..."
71 swapon /home/swap
72 fi
73 if [ "`fdisk -l | grep swap`" ]; then
74 for SWAP_DEV in `fdisk -l | grep swap | awk '{ print $1 }'`; do
75 echo "Swap memory detected on: $SWAP_DEV"
76 swapon $SWAP_DEV
77 done
78 fi
80 # Check for a specified locale (lang=*).
81 #
82 if grep -q "lang=*" /proc/cmdline; then
83 LANG=`cat /proc/cmdline | sed 's/.*lang=\([^ ]*\).*/\1/'`
84 echo -n "Setting system locale to: $LANG... "
85 echo "LANG=$LANG" > /etc/locale.conf
86 echo "LC_ALL=$LANG" >> /etc/locale.conf
87 status
88 fi
90 # Check for a specified keymap (kmap=*).
91 #
92 if grep -q "kmap=*" /proc/cmdline; then
93 KMAP=`cat /proc/cmdline | sed 's/.*kmap=\([^ ]*\).*/\1/'`
94 echo -n "Setting system keymap to: $KMAP..."
95 echo "KMAP=$KMAP.kmap" > /etc/kmap.conf
96 status
97 fi
99 # Check for a specified screen (screen=*).
100 #
101 if grep -q "screen=*" /proc/cmdline; then
102 SCREEN=`cat /proc/cmdline | sed 's/.*screen=\([^ ]*\).*/\1/'`
103 if [ "$SCREEN" = "text" ]; then
104 echo -n "Disabling X login manager: slim..."
105 sed -i s/'slim'/''/ /etc/rcS.conf
106 status
107 # Creat /etc/X11/screen.conf to avoid tazx execution by hwconf.sh
108 mkdir -p /etc/X11
109 echo 'SCREEN=1024x768x24' > /etc/X11/screen.conf
110 else
111 echo "Option not yet implemented: screen=$SCREEN"
112 sleep 2
113 fi
114 fi
116 # Laptop option to load ac and battery Kernel modules.
117 if grep -q "laptop" /proc/cmdline; then
118 echo "Loading laptop modules: ac battery..."
119 modprobe ac
120 modprobe battery
121 fi