slitaz-boot-scripts rev 426

/etc/init.d/bootopts.sh: make sure selected user has a home (thanks Alanyih)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Feb 24 22:57:18 2016 +0200 (2016-02-24)
parents 09aba02ed71a
children 6373374e4683
files etc/init.d/bootopts.sh
line diff
     1.1 --- a/etc/init.d/bootopts.sh	Mon Feb 15 12:33:39 2016 +0100
     1.2 +++ b/etc/init.d/bootopts.sh	Wed Feb 24 22:57:18 2016 +0200
     1.3 @@ -22,18 +22,17 @@
     1.4  # user=name can be used, but user must be added before home= to have home dir.
     1.5  # This option is not handled by a loop and case like others and has no
     1.6  # effect on an installed system.
     1.7 -if ! grep -q '100[0-9]:100' /etc/passwd; then
     1.8 -
     1.9 -	if fgrep -q 'user=' /proc/cmdline; then
    1.10 -		USER=$(cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/')
    1.11 -		# Avoid usage of an existing system user or root.
    1.12 -		if grep -q ^$USER /etc/passwd; then
    1.13 -			USER=tux
    1.14 -		fi
    1.15 -	else
    1.16 +if fgrep -q 'user=' /proc/cmdline; then
    1.17 +	USER=$(cat /proc/cmdline | sed 's/.*user=\([^ ]*\).*/\1/')
    1.18 +	# Avoid usage of an existing system user or root.
    1.19 +	if grep -q ^$USER /etc/passwd; then
    1.20  		USER=tux
    1.21  	fi
    1.22 +else
    1.23 +	USER=tux
    1.24 +fi
    1.25  
    1.26 +if ! grep -q '100[0-9]:100' /etc/passwd; then
    1.27  	# Make sure we have users applications.conf
    1.28  	if [ ! -f '/etc/skel/.config/slitaz/applications.conf' -a \
    1.29  		-f '/etc/slitaz/applications.conf' ]; then
    1.30 @@ -55,6 +54,12 @@
    1.31  	fi
    1.32  fi
    1.33  
    1.34 +# Make sure selected user has home
    1.35 +if [ ! -d /home/$USER ]; then
    1.36 +	cp -a /etc/skel /home/$USER
    1.37 +	chown -R $USER:users /home/$USER
    1.38 +fi
    1.39 +
    1.40  for opt in $(cat /proc/cmdline); do
    1.41  	case $opt in
    1.42  		eject)