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

Add USER tux to video group in bootopts.sh file.
author Christopher Rogers <slaxemulator@gmail.com>
date Mon Dec 27 10:00:01 2010 +0000 (2010-12-27)
parents 7125405f8998
children cb7412f02a9d
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 echo "$USER:x:1000:1000:SliTaz User,,,:/home/$USER:/bin/sh" >> /etc/passwd
32 echo "$USER::14035:0:99999:7:::" >> /etc/shadow
33 echo "$USER:x:1000:" >> /etc/group
34 echo "$USER:!::" >> /etc/gshadow
35 status
36 # Audio and cdrom group.
37 addgroup $USER audio
38 addgroup $USER cdrom
39 addgroup $USER video
40 # /home/$USER files from /etc/skel.
41 if [ -d /etc/skel ]; then
42 cp -a /etc/skel /home/$USER
43 # Path for user desktop files.
44 for i in /home/$USER/.local/share/applications/*.desktop
45 do
46 sed -i s/"user_name"/"$USER"/g $i
47 done
48 else
49 mkdir -p /home/$USER
50 fi
51 # Set permissions.
52 chown -R $USER.$USER /home/$USER
53 # Slim default user.
54 if [ -f /etc/slim.conf ]; then
55 sed -i s/"default_user .*"/"default_user $USER"/\
56 /etc/slim.conf
57 fi
58 fi
60 # Parse /proc/cmdline for boot options.
61 echo "Parsing kernel cmdline for SliTaz live options... "
63 for opt in `cat /proc/cmdline`
64 do
65 case $opt in
66 eject)
67 # Eject cdrom.
68 eject /dev/cdrom ;;
69 autologin)
70 # Autologin option to skip first graphic login prompt.
71 echo "auto_login yes" >> /etc/slim.conf ;;
72 lang=*)
73 # Check for a specified locale (lang=*).
74 LANG=${opt#lang=}
75 echo -n "Setting system locale to: $LANG... "
76 echo "LANG=$LANG" > /etc/locale.conf
77 echo "LC_ALL=$LANG" >> /etc/locale.conf
78 [ ! -d /usr/lib/locale/$LANG ] && localedef \
79 -i $LANG -c -f UTF-8 /usr/lib/locale/$LANG &
80 tazlocale link-files
81 status ;;
82 kmap=*)
83 # Check for a specified keymap (kmap=*).
84 KEYMAP=${opt#kmap=}
85 echo -n "Setting system keymap to: $KEYMAP..."
86 echo "$KEYMAP" > /etc/keymap.conf
87 status ;;
88 home=*)
89 # Check for a specified home partition (home=*) and check for
90 # user home dir. Note: home=usb is a shorter and easier way to
91 # have home=/dev/sda1.
92 DEVICE=${opt#home=}
93 [ "$DEVICE" = "usb" ] && DEVICE=sda1
94 echo "Home has been specified to $DEVICE..."
95 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
96 USBDELAY=$((1+$USBDELAY))
97 echo "Sleeping $USBDELAY s to let the kernel detect the device... "
98 sleep $USBDELAY
99 USER=`cat /etc/passwd | grep 1000 | cut -d ":" -f 1`
100 DEVID=$DEVICE
101 if [ -x /sbin/blkid ]; then
102 # Can be a label, uuid or devname. DEVID gives us first: /dev/name.
103 DEVID=`/sbin/blkid | grep $DEVICE | cut -d: -f1`
104 DEVID=${DEVID##*/}
105 fi
106 if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then
107 echo "Mounting /home on /dev/$DEVID... "
108 [ -d /home/$USER ] && mv /home/$USER /tmp/$USER-files
109 mount /dev/$DEVID /home -o uid=1000,gid=1000 2>/dev/null \
110 || mount /dev/$DEVID /home
111 # Check if swap file must be generated in /home: swap=size (Mb).
112 # This option is only used within home=device.
113 if grep -q "swap=[1-9]*" /proc/cmdline; then
114 SWAP_SIZE=`cat /proc/cmdline | sed 's/.*swap=\([^ ]*\).*/\1/'`
115 # DD to gen a virtual disk.
116 echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
117 dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
118 # Make the Linux swap filesystem.
119 mkswap /home/swap
120 add_swap_in_fstab /home/swap
121 fi
122 else
123 echo "Unable to find $DEVICE... "
124 fi
125 # Move all user dir if needed.
126 if [ ! -d "/home/$USER" ] ; then
127 mv /tmp/$USER-files /home/$USER
128 chown -R $USER.$USER /home/$USER
129 else
130 rm -rf /tmp/$USER-files
131 fi
132 # Install all packages in /home/boot/packages. In live CD and
133 # USB mode the option home= mounts the device on /home, so we
134 # already have a boot directory with the Kernel and rootfs.
135 if [ -d "/home/boot/packages" ]; then
136 for pkg in /home/boot/packages/*.tazpkg
137 do
138 tazpkg install $pkg
139 done
140 fi
141 # We can have custom files in /home/boot/rootfs to overwrite
142 # the one packed into the Live system.
143 if [ -d "/home/boot/rootfs" ]; then
144 cp -a /home/boot/rootfs/* /
145 fi ;;
146 laptop)
147 # Laptop option to load related Kernel modules.
148 echo "Loading laptop modules: ac, battery, fan, yenta_socket..."
149 for mod in ac battery fan yenta_socket
150 do
151 modprobe $mod
152 done
153 grep -qs batt /etc/lxpanel/default/panels/panel ||
154 sed -i 's/= cpu/= batt\n}\n\nPlugin {\n type = cpu/' \
155 /etc/lxpanel/default/panels/panel 2> /dev/null
156 # Enable Kernel Laptop mode.
157 echo "5" > /proc/sys/vm/laptop_mode ;;
158 mount)
159 # Mount all ext3 partitions found (opt: mount).
160 # Get the list of partitions.
161 DEVICES_LIST=`fdisk -l | grep 83 | cut -d " " -f 1`
162 # Mount filesystems rw.
163 for device in $DEVICES_LIST
164 do
165 name=${device#/dev/}
166 # Device can be already used by home=usb.
167 if ! mount | grep ^$device >/dev/null; then
168 echo "Mounting partition: $name on /mnt/$name"
169 mkdir /mnt/$name
170 mount $device /mnt/$name
171 fi
172 done ;;
173 mount-packages)
174 # Mount and install packages-XXX.iso (useful without Internet
175 # connection).
176 PKGSIGN="LABEL=\"packages-$(cat /etc/slitaz-release)\" TYPE=\"iso9660\""
177 PKGDEV=$(blkid | grep "$PKGSIGN" | cut -d: -f1)
178 [ -z "$PKGDEV" -a -L /dev/cdrom ] && \
179 PKGDEV=$(blkid /dev/cdrom | grep "$PKGSIGN" | cut -d: -f1)
180 if [ -n "$PKGDEV" ]; then
181 echo -n "Mounting packages archive from $PKGDEV..."
182 mkdir /packages && mount -t iso9660 -o ro $PKGDEV /packages
183 status
184 /packages/install.sh
185 fi ;;
186 wm=*)
187 # Check for a Window Manager (for a flavor, default WM can be changed
188 # with boot options or with an addfile in /etc/X11/wm.default.
189 WM=${opt#wm=}
190 mkdir -p /etc/X11
191 case $WM in
192 jwm)
193 echo "jwm" > /etc/X11/wm.default ;;
194 ob|openbox|openbox-session)
195 echo "openbox" > /etc/X11/wm.default ;;
196 e17|enlightenment|enlightenment_start)
197 echo "enlightenment" > /etc/X11/wm.default ;;
198 esac ;;
199 *)
200 continue ;;
201 esac
202 done
204 # If no default WM fallback to Openbox (we never know).
205 if [ ! -f /etc/X11/wm.default ]; then
206 echo "openbox" > /etc/X11/wm.default
207 fi
209 # Activate an eventual swap file or partition.
210 if [ "`fdisk -l | grep swap`" ]; then
211 for SWAP_DEV in `fdisk -l | grep swap | awk '{ print $1 }'`; do
212 echo "Swap memory detected on: $SWAP_DEV"
213 add_swap_in_fstab $SWAP_DEV
214 done
215 fi
216 if grep -q swap /etc/fstab; then
217 echo "Activating swap memory..."
218 swapon -a
219 fi