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

Huge change in boot... we start X as soon as possible by default, for this we have to config keymap, locale, user and home before, let do that in rcS. Also some fixes such as TZ
author Christophe Lincoln <pankso@slitaz.org>
date Fri Apr 29 16:06:08 2011 +0200 (2011-04-29)
parents 9f875fdcde50
children f1c0f8f8c116
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 # /home/$USER files from /etc/skel.
40 # make user be only read/write by user
41 chmod -R 700 /home/$USER
42 # Slim default user.
43 if [ -f /etc/slim.conf ]; then
44 sed -i s/"default_user .*"/"default_user $USER"/\
45 /etc/slim.conf
46 fi
47 fi
49 # Parse /proc/cmdline for boot options.
50 echo "Parsing kernel cmdline for SliTaz live options... "
52 for opt in `cat /proc/cmdline`
53 do
54 case $opt in
55 eject)
56 # Eject cdrom.
57 eject /dev/cdrom ;;
58 laptop)
59 # Laptop option to load related Kernel modules.
60 echo "Loading laptop modules: ac, battery, fan, yenta_socket..."
61 for mod in ac battery fan yenta_socket
62 do
63 modprobe $mod
64 done
65 grep -qs batt /etc/lxpanel/default/panels/panel ||
66 sed -i 's/= cpu/= batt\n}\n\nPlugin {\n type = cpu/' \
67 /etc/lxpanel/default/panels/panel 2> /dev/null
68 # Enable Kernel Laptop mode.
69 echo "5" > /proc/sys/vm/laptop_mode ;;
70 mount)
71 # Mount all ext3 partitions found (opt: mount).
72 # Get the list of partitions.
73 DEVICES_LIST=`fdisk -l | sed '/83 Linux/!d;s/ .*//'`
74 # Mount filesystems rw.
75 for device in $DEVICES_LIST
76 do
77 name=${device#/dev/}
78 # Device can be already used by home=usb.
79 if ! mount | grep ^$device >/dev/null; then
80 echo "Mounting partition: $name on /mnt/$name"
81 mkdir /mnt/$name
82 mount $device /mnt/$name
83 fi
84 done ;;
85 mount-packages)
86 # Mount and install packages-XXX.iso (useful without Internet
87 # connection).
88 PKGSIGN="LABEL=\"packages-$(cat /etc/slitaz-release)\" TYPE=\"iso9660\""
89 PKGDEV=$(blkid | grep "$PKGSIGN" | cut -d: -f1)
90 [ -z "$PKGDEV" -a -L /dev/cdrom ] && \
91 PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
92 if [ -n "$PKGDEV" ]; then
93 echo -n "Mounting packages archive from $PKGDEV..."
94 mkdir /packages && mount -t iso9660 -o ro $PKGDEV /packages
95 status
96 /packages/install.sh
97 fi ;;
98 *)
99 continue ;;
100 esac
101 done
103 # Activate an eventual swap file or partition.
104 if [ "`fdisk -l | grep swap`" ]; then
105 for SWAP_DEV in `fdisk -l | sed '/swap/!d;s/ .*//'`; do
106 echo "Swap memory detected on: $SWAP_DEV"
107 add_swap_in_fstab $SWAP_DEV
108 done
109 fi
110 if grep -q swap /etc/fstab; then
111 echo "Activating swap memory..."
112 swapon -a
113 fi