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

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