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

Option: mount (Mount all ext3 local partitions automaticaly
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 27 12:59:57 2008 +0200 (2008-04-27)
parents f1529c400e81
children d7ba6f674f9c
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 # Check if swap file must be generated in /home: swap=size (Mb).
7 # This option is used with home=device.
8 gen_home_swap()
9 {
10 if grep -q "swap=[1-9]*" /proc/cmdline; then
11 SWAP_SIZE=`cat /proc/cmdline | sed 's/.*swap=\([^ ]*\).*/\1/'`
12 # DD to gen a virtual disk.
13 echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
14 dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
15 # Make the Linux swap filesystem.
16 mkswap /home/swap
17 fi
18 }
20 # Mount /home and check for user hacker home dir.
21 #
22 mount_home()
23 {
24 echo "Home has been specified to $DEVICE..."
25 echo "Sleeping 10 s to let the kernel detect the device... "
26 sleep 10
28 DEVID=$DEVICE
29 if [ -x /sbin/blkid ]; then
30 # Can be label, uuid or devname. DEVID give us first: /dev/name.
31 DEVID=`/sbin/blkid | grep $DEVICE | cut -d: -f1`
32 DEVID=${DEVID##*/}
33 fi
34 if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then
35 echo "Mounting /home on /dev/$DEVID... "
36 mv /home/hacker /tmp/hacker-home
37 mount /dev/$DEVID /home -o uid=500,gid=500 2>/dev/null \
38 || mount /dev/$DEVID /home
39 gen_home_swap
40 else
41 echo "Unable to find $DEVICE... "
42 fi
43 # Move all hacker dir if needed.
44 if [ ! -d "/home/hacker" ] ; then
45 mv /tmp/hacker-home /home/hacker
46 chown -R hacker.hacker /home/hacker
47 else
48 rm -rf /tmp/hacker-home
49 fi
50 }
52 # Mount all ext3 partitions found (opt: mount).
53 mount_partitions()
54 {
55 # Get the list partitions.
56 DEVICES_LIST=`fdisk -l | grep 83 | cut -d " " -f 1`
58 # Mount filesystems rw.
59 for device in $DEVICES_LIST
60 do
61 name=${device#/dev/}
62 # Device can be already used by home=usb.
63 if ! mount | grep ^$device >/dev/null; then
64 echo "Mounting partition: $name on /mnt/$name"
65 mkdir /mnt/$name
66 mount $device /mnt/$name
67 fi
68 done
69 }
71 # Parse /proc/cmdline with grep.
72 #
74 echo "Parsing kernel cmdline for SliTaz live options... "
76 # Check for a specified home directory on cmdline (home=*).
77 #
78 if grep -q "home=usb" /proc/cmdline; then
79 DEVICE=sda1
80 mount_home
81 elif grep -q "home=" /proc/cmdline; then
82 DEVICE=`cat /proc/cmdline | sed 's/.*home=\([^ ]*\).*/\1/'`
83 mount_home
84 fi
86 # Active an eventual swap file in /home and on local hd.
87 #
88 if [ -f "/home/swap" ]; then
89 echo "Activing swap (/home/swap) memory..."
90 swapon /home/swap
91 fi
92 if [ "`fdisk -l | grep swap`" ]; then
93 for SWAP_DEV in `fdisk -l | grep swap | awk '{ print $1 }'`; do
94 echo "Swap memory detected on: $SWAP_DEV"
95 swapon $SWAP_DEV
96 done
97 fi
99 # Check for a specified locale (lang=*).
100 #
101 if grep -q "lang=*" /proc/cmdline; then
102 LANG=`cat /proc/cmdline | sed 's/.*lang=\([^ ]*\).*/\1/'`
103 echo -n "Setting system locale to: $LANG... "
104 echo "LANG=$LANG" > /etc/locale.conf
105 echo "LC_ALL=$LANG" >> /etc/locale.conf
106 status
107 fi
109 # Check for a specified keymap (kmap=*).
110 #
111 if grep -q "kmap=*" /proc/cmdline; then
112 KMAP=`cat /proc/cmdline | sed 's/.*kmap=\([^ ]*\).*/\1/'`
113 echo -n "Setting system keymap to: $KMAP..."
114 echo "KMAP=$KMAP.kmap" > /etc/kmap.conf
115 status
116 fi
118 # Laptop option to load ac and battery Kernel modules.
119 if grep -q "laptop" /proc/cmdline; then
120 echo "Loading laptop modules: ac, battery, yenta_socket..."
121 modprobe ac
122 modprobe battery
123 modprobe yenta_socket
124 depmod -a
125 fi
127 # Check for a Window Manager (for a flavor, default WM can be changed
128 # with boot option or with an addfile in /etc/X11/wm.default.
129 if grep -q "wm=" /proc/cmdline; then
130 mkdir -p /etc/X11
131 WM=`cat /proc/cmdline | sed 's/.*wm=\([^ ]*\).*/\1/'`
132 case $WM in
133 jwm)
134 echo "jwm" > /etc/X11/wm.default ;;
135 ob|openbox|openbox-session)
136 echo "openbox" > /etc/X11/wm.default ;;
137 e17|enlightenment|enlightenment_start)
138 echo "enlightenment" > /etc/X11/wm.default ;;
139 esac
140 else
141 # If no default WM fallback to Openbox.
142 if [ ! -f /etc/X11/wm.default ]; then
143 echo "openbox" > /etc/X11/wm.default
144 fi
145 fi
147 # Check for option mount.
148 if grep -q "mount" /proc/cmdline; then
149 mount_partitions
150 fi