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

Fix: starting Xorg (we dont need any config file)
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 01 22:14:02 2014 +0200 (2014-05-01)
parents e147902153c1
children b0b8423150c4
line source
1 #!/bin/sh
2 #
3 # /etc/init.d/bootopts.sh : SliTaz boot options from the cmdline
4 #
5 # Earlier boot options are in rcS, ex: config= and modprobe=
6 #
7 . /etc/init.d/rc.functions
9 # Get first usb disk
10 usb_device() {
11 cd /sys/block
12 for i in sd* sda ; do
13 grep -qs 1 $i/removable && break
14 done
15 echo $i
16 }
18 # Parse /proc/cmdline for boot options.
19 echo "Checking for SliTaz cmdline options..."
21 # Default user account without password (uid=1000). In live mode the option
22 # user=name can be used, but user must be added before home= to have home dir.
23 # This option is not handled by a loop and case like others and has no
24 # effect on an installed system.
25 if ! grep -q "100[0-9]:100" /etc/passwd; then
27 if fgrep -q "user=" /proc/cmdline; then
28 USER=$(cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/')
29 # Avoid usage of an existing system user or root.
30 if grep -q ^$USER /etc/passwd; then
31 USER=tux
32 fi
33 else
34 USER=tux
35 fi
37 # Make sure we have users applications.conf
38 if [ ! -f "/etc/skel/.config/slitaz/applications.conf" ]; then
39 mkdir -p /etc/skel/.config/slitaz
40 cp /etc/slitaz/applications.conf /etc/skel/.config/slitaz
41 fi
43 echo -n "Configuring user and group: $USER..."
44 adduser -D -s /bin/sh -g "SliTaz User" -G users -h /home/$USER $USER
45 passwd -d $USER >/dev/null
46 status
48 # Slim default user
49 if [ -f /etc/slim.conf ]; then
50 sed -i s/"default_user .*"/"default_user $USER"/ /etc/slim.conf
51 fi
52 fi
54 for opt in $(cat /proc/cmdline)
55 do
56 case $opt in
57 eject)
58 # Eject cdrom.
59 eject /dev/cdrom ;;
60 autologin)
61 # Autologin option to skip first graphic login prompt.
62 echo "auto_login yes" >> /etc/slim.conf ;;
63 lang=*)
64 # Check for a specified locale (lang=*).
65 LANG=${opt#lang=}
66 /sbin/tazlocale $LANG ;;
67 kmap=*)
68 # Check for a specified keymap (kmap=*).
69 KEYMAP=${opt#kmap=}
70 echo -n "Setting system keymap to: $KEYMAP..."
71 echo "$KEYMAP" > /etc/keymap.conf
72 status ;;
73 home=*)
74 # Check for a specified home partition (home=*) and check for
75 # user home dir. Note: home=usb is a shorter and easier way to
76 # have home=/dev/sda1.
77 DEVICE=${opt#home=}
78 [ "$DEVICE" = "usb" ] && DEVICE="$(usb_device)1"
79 echo "Home has been specified to $DEVICE..."
80 DEVID=`/sbin/blkid | sed 'p;s/"//g' | fgrep "$DEVICE" | sed 's/:.*//;q'`
81 if [ -z "$DEVID" ]; then
82 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
83 USBDELAY=$((2+$USBDELAY))
84 echo "Sleeping $USBDELAY s to let the kernel detect the device... "
85 sleep $USBDELAY
86 fi
87 USER=`cat /etc/passwd | sed '/:1000:/!d;s/:.*//;q'`
88 DEVID=$DEVICE
89 if [ -x /sbin/blkid ]; then
90 # Can be a label, uuid, type or devname. DEVID gives us first: /dev/name.
91 DEVID=`/sbin/blkid | sed 'p;s/"//g' | fgrep "$DEVICE" | sed 's/:.*//;q'`
92 fi
93 DEVID=${DEVID##*/}
94 if [ -n "$DEVID" ] && fgrep -q "$DEVID" /proc/partitions ; then
95 echo "Mounting /home on /dev/$DEVID... "
96 [ -d /home/$USER ] && mv /home/$USER /tmp/$USER-files
97 mount /dev/$DEVID /home &&
98 case "$(/sbin/blkid | grep /dev/$DEVID:)" in
99 *\"ntfs\"*|*\"vfat\"*) mount.posixovl -F /home -- -oallow_other -odefault_permissions -osuid ;;
100 esac
101 mount /home -o remount,uid=1000,gid=100 2>/dev/null
102 # Check if swap file must be generated in /home: swap=size (Mb).
103 # This option is only used within home=device.
104 if grep -q "swap=[1-9]*" /proc/cmdline; then
105 SWAP_SIZE=`sed 's/.*swap=\([^ ]*\).*/\1/' < /proc/cmdline`
106 # DD to gen a virtual disk.
107 echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
108 dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
109 # Make the Linux swap filesystem.
110 mkswap /home/swap
111 add_swap_in_fstab /home/swap
112 fi
113 else
114 echo "Unable to find $DEVICE... "
115 fi
116 # Move all user dir if needed.
117 if [ ! -d "/home/$USER" ] ; then
118 mv /tmp/$USER-files /home/$USER
119 chown -R $USER.users /home/$USER
120 else
121 rm -rf /tmp/$USER-files
122 fi
123 # Install all packages in /home/boot/packages. In live CD and
124 # USB mode the option home= mounts the device on /home, so we
125 # already have a boot directory with the Kernel and rootfs.
126 if [ -d "/home/boot/packages" ]; then
127 for pkg in /home/boot/packages/*.tazpkg
128 do
129 tazpkg install $pkg
130 done
131 fi
132 # We can have custom files in /home/boot/rootfs to overwrite
133 # the one packed into the Live system.
134 if [ -d "/home/boot/rootfs" ]; then
135 cp -a /home/boot/rootfs/* /
136 fi ;;
137 laptop)
138 # Enable Kernel Laptop mode.
139 echo "5" > /proc/sys/vm/laptop_mode ;;
140 mount)
141 # Mount all ext3 partitions found (opt: mount).
142 # Get the list of partitions.
143 DEVICES_LIST=`fdisk -l | sed '/83 Linux/!d;s/ .*//'`
144 # Mount filesystems rw.
145 for device in $DEVICES_LIST
146 do
147 name=${device#/dev/}
148 # Device can be already used by home=usb.
149 if ! mount | grep ^$device >/dev/null; then
150 echo "Mounting partition: $name on /mnt/$name"
151 mkdir /mnt/$name
152 mount $device /mnt/$name
153 fi
154 done ;;
155 mount-packages)
156 # Mount and install packages-XXX.iso (useful without Internet
157 # connection).
158 PKGSIGN="LABEL=\"packages-$(cat /etc/slitaz-release)\" TYPE=\"iso9660\""
159 PKGDEV=$(blkid | grep "$PKGSIGN" | cut -d: -f1)
160 [ -z "$PKGDEV" -a -L /dev/cdrom ] && \
161 PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
162 if [ -n "$PKGDEV" ]; then
163 echo -n "Mounting packages archive from $PKGDEV..."
164 mkdir /packages && mount -t iso9660 -o ro $PKGDEV /packages
165 status
166 /packages/install.sh
167 fi ;;
168 wm=*)
169 # Check for a Window Manager (for a flavor, default WM can be changed
170 # with boot options or via /etc/slitaz/applications.conf).
171 WM=${opt#wm=}
172 case $WM in
173 ob|openbox|openbox-session)
174 WM=openbox-session ;;
175 e17|enlightenment|enlightenment_start)
176 WM=enlightenment ;;
177 razorqt|razor-session)
178 WM=razor-session ;;
179 esac
180 sed -i s/"WINDOW_MANAGER=.*"/"WINDOW_MANAGER=\"$WM\""/ \
181 /etc/slitaz/applications.conf ;;
182 *)
183 continue ;;
184 esac
185 done