slitaz-forge rev 45

taztank: add command adduser to create new users on tank
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 31 00:05:06 2011 +0200 (2011-03-31)
parents f9644aebc4a8
children 444d36a84ce8
files tank/taztank
line diff
     1.1 --- a/tank/taztank	Wed Mar 30 23:12:37 2011 +0200
     1.2 +++ b/tank/taztank	Thu Mar 31 00:05:06 2011 +0200
     1.3 @@ -126,6 +126,59 @@
     1.4  			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org 
     1.5  		done
     1.6  		echo "" ;;
     1.7 +	adduser|-au)
     1.8 +		# On Tank /etc/skel is empty to let taktank handle default user
     1.9 +		# files.
    1.10 +		echo ""
    1.11 +		if [ -n "$2" ]; then
    1.12 +			user=$2
    1.13 +		else
    1.14 +			echo -n "User name: " && read user
    1.15 +		fi
    1.16 +		if [ -d /home/$user ]; then
    1.17 +			echo -e "User $user already exist...\n" && exit 1
    1.18 +		fi
    1.19 +		echo "Adding user: $user"
    1.20 +		adduser $user
    1.21 +		# HG access
    1.22 +		echo -n "Hg password: " && read passwd
    1.23 +		echo "$user:$passwd" >> /etc/lighttpd/plain.passwd
    1.24 +		# README
    1.25 +		echo -n "Creating default user files... "
    1.26 +		cat > /home/$user/README << EOF
    1.27 +Welcome to Tank!
    1.28 +================================================================================
    1.29 +
    1.30 +Your Public directory URL is: http://people.slitaz.org/~$USER/
    1.31 +
    1.32 +Please complet your public profile in ~/Public/profile.php and feel free
    1.33 +to use the service for your needs, if any thing goes wrong or is missing
    1.34 +please express your self :-)
    1.35 +
    1.36 +EOF
    1.37 +		# Public profile
    1.38 +		mkdir -p /home/$user/Public
    1.39 +		cat > /home/$user/Public/profile.php << EOF
    1.40 +<?php
    1.41 +
    1.42 +// Your custom SliTaz profile at http://people.slitaz.org/. This file must
    1.43 +// be located at ~/Public/profile.php. You must at least provide your real
    1.44 +// name and you can use the $wall variable for a personnal message.
    1.45 +
    1.46 +$name = "Real Name";
    1.47 +$location = "";
    1.48 +$scn_user = "";
    1.49 +$skills = "";
    1.50 +$wall = "";
    1.51 +
    1.52 +?>
    1.53 +EOF
    1.54 +		# Shell profile
    1.55 +		cat > /home/$user/.profile << EOF
    1.56 +# ~/.profile: Executed by Bourne-compatible login SHells.
    1.57 +#
    1.58 +EOF
    1.59 +		echo -e "Done\n" ;;
    1.60  	*)
    1.61  		usage ;;
    1.62  esac