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

bootopts.sh: remove this chown -R on user home it make all files executable (this was a realy bad idea, noe repos is only accessible for a few old dev, it a part too imporant of the os to let anybody do what it want...)
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jun 05 12:35:23 2011 +0200 (2011-06-05)
parents 2bce54934129
children 28fda57244ee
line source
1 #!/bin/sh
2 # /etc/init.d/bootopts.sh - SliTaz boot options from the cmdline.
3 #
4 # Earlier boot options are in rcS, ex: config= and modprobe=
5 #
6 . /etc/init.d/rc.functions
8 # Update fstab for swapon/swapoff
9 add_swap_in_fstab()
10 {
11 grep -q "$1 " /etc/fstab || cat >> /etc/fstab <<EOT
12 $1 swap swap default 0 0
13 EOT
14 }
16 # Default user account without password (uid=1000). In live mode the option
17 # user=name can be used, but user must be added before home= to have home dir.
18 # This option is not handled by a loop and case like others and has no
19 # effect on an installed system.
20 if ! grep -q "100[0-9]:100[0-9]" /etc/passwd; then
21 if grep -q "user=" /proc/cmdline; then
22 USER=`cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/'`
23 # Avoid usage of an existing system user or root.
24 if grep -q ^$USER /etc/passwd; then
25 USER=tux
26 fi
27 else
28 USER=tux
29 fi
30 echo -n "Configuring user and group: $USER..."
31 adduser -D -s /bin/sh -g "SliTaz User" -G users -h /home/$USER $USER
32 passwd -d $USER >/dev/null
33 status
34 # Audio and cdrom group.
35 addgroup $USER audio
36 addgroup $USER cdrom
37 addgroup $USER video
38 addgroup $USER tty
39 # Slim default user.
40 if [ -f /etc/slim.conf ]; then
41 sed -i s/"default_user .*"/"default_user $USER"/\
42 /etc/slim.conf
43 fi
44 fi
46 # Parse /proc/cmdline for boot options.
47 echo "Parsing kernel cmdline for SliTaz live options... "
49 for opt in `cat /proc/cmdline`
50 do
51 case $opt in
52 eject)
53 # Eject cdrom.
54 eject /dev/cdrom ;;
55 autologin)
56 # Autologin option to skip first graphic login prompt.
57 echo "auto_login yes" >> /etc/slim.conf ;;
58 lang=*)
59 # Check for a specified locale (lang=*).
60 LANG=${opt#lang=}
61 echo -n "Setting system locale to: $LANG... "
62 tazlocale init $LANG
63 status ;;
64 kmap=*)
65 # Check for a specified keymap (kmap=*).
66 KEYMAP=${opt#kmap=}
67 echo -n "Setting system keymap to: $KEYMAP..."
68 echo "$KEYMAP" > /etc/keymap.conf
69 status ;;
70 home=*)
71 # Check for a specified home partition (home=*) and check for
72 # user home dir. Note: home=usb is a shorter and easier way to
73 # have home=/dev/sda1.
74 DEVICE=${opt#home=}
75 [ "$DEVICE" = "usb" ] && DEVICE=sda1
76 echo "Home has been specified to $DEVICE..."
77 DEVID=`/sbin/blkid | sed 'p;s/"//g' | grep "$DEVICE" | sed 's/:.*//;q'`
78 if [ -z "$DEVID" ]; then
79 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
80 USBDELAY=$((2+$USBDELAY))
81 echo "Sleeping $USBDELAY s to let the kernel detect the device... "
82 sleep $USBDELAY
83 fi
84 USER=`cat /etc/passwd | sed '/:1000:/!d;s/:.*//;q'`
85 DEVID=$DEVICE
86 if [ -x /sbin/blkid ]; then
87 # Can be a label, uuid, type or devname. DEVID gives us first: /dev/name.
88 DEVID=`/sbin/blkid | sed 'p;s/"//g' | grep "$DEVICE" | sed 's/:.*//;q'`
89 fi
90 DEVID=${DEVID##*/}
91 if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then
92 echo "Mounting /home on /dev/$DEVID... "
93 [ -d /home/$USER ] && mv /home/$USER /tmp/$USER-files
94 mount /dev/$DEVID /home -o uid=1000,gid=100 2>/dev/null \
95 || mount /dev/$DEVID /home
96 # Check if swap file must be generated in /home: swap=size (Mb).
97 # This option is only used within home=device.
98 if grep -q "swap=[1-9]*" /proc/cmdline; then
99 SWAP_SIZE=`sed 's/.*swap=\([^ ]*\).*/\1/' < /proc/cmdline`
100 # DD to gen a virtual disk.
101 echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
102 dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
103 # Make the Linux swap filesystem.
104 mkswap /home/swap
105 add_swap_in_fstab /home/swap
106 fi
107 else
108 echo "Unable to find $DEVICE... "
109 fi
110 # Move all user dir if needed.
111 if [ ! -d "/home/$USER" ] ; then
112 mv /tmp/$USER-files /home/$USER
113 chown -R $USER.users /home/$USER
114 else
115 rm -rf /tmp/$USER-files
116 fi
117 # Install all packages in /home/boot/packages. In live CD and
118 # USB mode the option home= mounts the device on /home, so we
119 # already have a boot directory with the Kernel and rootfs.
120 if [ -d "/home/boot/packages" ]; then
121 for pkg in /home/boot/packages/*.tazpkg
122 do
123 tazpkg install $pkg
124 done
125 fi
126 # We can have custom files in /home/boot/rootfs to overwrite
127 # the one packed into the Live system.
128 if [ -d "/home/boot/rootfs" ]; then
129 cp -a /home/boot/rootfs/* /
130 fi ;;
131 laptop)
132 # Laptop option to load related Kernel modules.
133 echo "Loading laptop modules: ac, battery, fan, yenta_socket..."
134 for mod in ac battery fan yenta_socket
135 do
136 modprobe $mod
137 done
138 grep -qs batt /etc/lxpanel/default/panels/panel ||
139 sed -i 's/= cpu/= batt\n}\n\nPlugin {\n type = cpu/' \
140 /etc/lxpanel/default/panels/panel 2> /dev/null
141 # Enable Kernel Laptop mode.
142 echo "5" > /proc/sys/vm/laptop_mode ;;
143 mount)
144 # Mount all ext3 partitions found (opt: mount).
145 # Get the list of partitions.
146 DEVICES_LIST=`fdisk -l | sed '/83 Linux/!d;s/ .*//'`
147 # Mount filesystems rw.
148 for device in $DEVICES_LIST
149 do
150 name=${device#/dev/}
151 # Device can be already used by home=usb.
152 if ! mount | grep ^$device >/dev/null; then
153 echo "Mounting partition: $name on /mnt/$name"
154 mkdir /mnt/$name
155 mount $device /mnt/$name
156 fi
157 done ;;
158 mount-packages)
159 # Mount and install packages-XXX.iso (useful without Internet
160 # connection).
161 PKGSIGN="LABEL=\"packages-$(cat /etc/slitaz-release)\" TYPE=\"iso9660\""
162 PKGDEV=$(blkid | grep "$PKGSIGN" | cut -d: -f1)
163 [ -z "$PKGDEV" -a -L /dev/cdrom ] && \
164 PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
165 if [ -n "$PKGDEV" ]; then
166 echo -n "Mounting packages archive from $PKGDEV..."
167 mkdir /packages && mount -t iso9660 -o ro $PKGDEV /packages
168 status
169 /packages/install.sh
170 fi ;;
171 wm=*)
172 # Check for a Window Manager (for a flavor, default WM can be changed
173 # with boot options or with an addfile in /etc/X11/wm.default.
174 WM=${opt#wm=}
175 mkdir -p /etc/X11
176 case $WM in
177 jwm)
178 echo "jwm" > /etc/X11/wm.default ;;
179 ob|openbox|openbox-session)
180 echo "openbox" > /etc/X11/wm.default ;;
181 e17|enlightenment|enlightenment_start)
182 echo "enlightenment" > /etc/X11/wm.default ;;
183 esac ;;
184 *)
185 continue ;;
186 esac
187 done
189 # If no default WM fallback to Openbox (we never know).
190 if [ ! -f /etc/X11/wm.default ]; then
191 echo "openbox" > /etc/X11/wm.default
192 fi
194 # Activate an eventual swap file or partition.
195 if [ "`fdisk -l | grep swap`" ]; then
196 for SWAP_DEV in `fdisk -l | sed '/swap/!d;s/ .*//'`; do
197 echo "Swap memory detected on: $SWAP_DEV"
198 add_swap_in_fstab $SWAP_DEV
199 done
200 fi
201 if grep -q swap /etc/fstab; then
202 echo "Activating swap memory..."
203 swapon -a
204 fi