slitaz-boot-scripts rev 95

Add option: user=name
author Christophe Lincoln <pankso@slitaz.org>
date Mon Jun 09 23:39:44 2008 +0200 (2008-06-09)
parents 314ff70acfdf
children f54edda7c5fb
files applications/boot-log.desktop etc/init.d/bootopts.sh
line diff
     1.1 --- a/applications/boot-log.desktop	Fri Jun 06 23:26:27 2008 +0200
     1.2 +++ b/applications/boot-log.desktop	Mon Jun 09 23:39:44 2008 +0200
     1.3 @@ -2,6 +2,6 @@
     1.4  Encoding=UTF-8
     1.5  Name=Show Boot Log
     1.6  Exec=xterm -hold -e 'si=`cat /var/log/boot.log | wc -l`; sh=$(($si-1)); head -$sh /var/log/boot.log'
     1.7 -Icon=/usr/share/icons/Tango/jwm/applications-other.png
     1.8 +Icon=other.png
     1.9  Type=Application
    1.10  Categories=System;
     2.1 --- a/etc/init.d/bootopts.sh	Fri Jun 06 23:26:27 2008 +0200
     2.2 +++ b/etc/init.d/bootopts.sh	Mon Jun 09 23:39:44 2008 +0200
     2.3 @@ -24,7 +24,7 @@
     2.4  	echo "Home has been specified to $DEVICE..."
     2.5  	echo "Sleeping 10 s to let the kernel detect the device... "
     2.6  	sleep 10
     2.7 -
     2.8 +	USER=`cat /etc/passwd | grep 1000 | cut -d ":" -f 1`
     2.9  	DEVID=$DEVICE
    2.10  	if [ -x /sbin/blkid ]; then
    2.11  		# Can be label, uuid or devname. DEVID give us first: /dev/name.
    2.12 @@ -33,19 +33,19 @@
    2.13  	fi
    2.14  	if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then
    2.15  		echo "Mounting /home on /dev/$DEVID... "
    2.16 -		mv /home/hacker /tmp/hacker-home
    2.17 -		mount /dev/$DEVID /home -o uid=500,gid=500 2>/dev/null \
    2.18 +		mv /home/$USER /tmp/$USER-files
    2.19 +		mount /dev/$DEVID /home -o uid=1000,gid=1000 2>/dev/null \
    2.20  			|| mount /dev/$DEVID /home
    2.21  		gen_home_swap
    2.22  	else
    2.23  		echo "Unable to find $DEVICE... "
    2.24  	fi
    2.25  	# Move all hacker dir if needed.
    2.26 -	if [ ! -d "/home/hacker" ] ; then
    2.27 -		mv /tmp/hacker-home /home/hacker
    2.28 -		chown -R hacker.hacker /home/hacker
    2.29 +	if [ ! -d "/home/$USER" ] ; then
    2.30 +		mv /tmp/$USER-files /home/$USER
    2.31 +		chown -R $USER.$USER /home/$USER
    2.32  	else
    2.33 -		rm -rf /tmp/hacker-home
    2.34 +		rm -rf /tmp/$USER-files
    2.35  	fi
    2.36  }
    2.37  
    2.38 @@ -54,7 +54,6 @@
    2.39  {
    2.40  	# Get the list partitions.
    2.41  	DEVICES_LIST=`fdisk -l | grep 83 | cut -d " " -f 1`
    2.42 -	
    2.43  	# Mount filesystems rw.
    2.44  	for device in $DEVICES_LIST
    2.45  	do
    2.46 @@ -73,6 +72,37 @@
    2.47  
    2.48  echo "Parsing kernel cmdline for SliTaz live options... "
    2.49  
    2.50 +# user=name: Default user account witout password (uid=1000).
    2.51 +#
    2.52 +if ! grep -q "1000:1000" /etc/passwd; then
    2.53 +	if grep -q "user=" /proc/cmdline; then
    2.54 +		USER=`cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/'`
    2.55 +	else
    2.56 +		USER=linux
    2.57 +	fi
    2.58 +	echo -n "Configuring user and group: $USER..."
    2.59 +	echo "$USER:x:1000:1000:SliTaz User,,,:/home/$USER:/bin/sh" >> /etc/passwd
    2.60 +	echo "$USER::14035:0:99999:7:::" >> /etc/shadow
    2.61 +	echo "$USER:x:1000:" >> /etc/group
    2.62 +	echo "$USER:!::" >> /etc/gshadow
    2.63 +	status
    2.64 +	# Audio group.
    2.65 +	sed -i s/"audio:x:20:"/"audio:x:20:$USER"/ /etc/group
    2.66 +	# /home/$USER files from /etc/skel.
    2.67 +	if [ -d /etc/skel ]; then
    2.68 +		cp -a /etc/skel /home/$USER
    2.69 +	else
    2.70 +		mkdir -p /home/$USER
    2.71 +	fi
    2.72 +	# set permissions.
    2.73 +	chown -R $USER.$USER /home/$USER
    2.74 +	# Slim default user.
    2.75 +	if [ -f /etc/slim.conf ]; then
    2.76 +		sed -i s/"default_user        hacker"/"default_user        $USER"/\
    2.77 +			/etc/slim.conf
    2.78 +	fi
    2.79 +fi
    2.80 +
    2.81  # Check for a specified home directory on cmdline (home=*).
    2.82  #
    2.83  if grep -q "home=usb" /proc/cmdline; then