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

Mount /home uid=500 if fs is FAT32
author Christophe Lincoln <pankso@slitaz.org>
date Fri Mar 14 14:59:50 2008 +0100 (2008-03-14)
parents 439cb0a8e2d0
children eb339fcb3200
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 # Parse /proc/cmdline with grep.
53 #
55 echo "Parsing kernel cmdline for SliTaz live options... "
57 # Check for a specified home directory on cmdline (home=*).
58 #
59 if grep -q "home=usb" /proc/cmdline; then
60 DEVICE=sda1
61 mount_home
62 elif grep -q "home=" /proc/cmdline; then
63 DEVICE=`cat /proc/cmdline | sed 's/.*home=\([^ ]*\).*/\1/'`
64 mount_home
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 # Laptop option to load ac and battery Kernel modules.
100 if grep -q "laptop" /proc/cmdline; then
101 echo "Loading laptop modules: ac battery..."
102 modprobe ac
103 modprobe battery
104 fi