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

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