slitaz-dev-tools rev 259

tazu: add functions to check/clean users DB
author Christophe Lincoln <pankso@slitaz.org>
date Mon Dec 12 18:53:30 2016 +0100 (2016-12-12)
parents 0b0666832cb6
children db2f2190018f
files tazu/tazu
line diff
     1.1 --- a/tazu/tazu	Fri Sep 23 12:46:36 2016 +0300
     1.2 +++ b/tazu/tazu	Mon Dec 12 18:53:30 2016 +0100
     1.3 @@ -2,7 +2,10 @@
     1.4  #
     1.5  # TazU - SliTaz Users account utility
     1.6  #
     1.7 -# Copyright 2014 (C) SliTaz GNU/Linux - BSD License
     1.8 +# This tool is used to mange SliTaz users accounts on bugs.slitaz.org
     1.9 +# and scn.slitaz.org. It can also be used to admin TinyCM users DB.
    1.10 +#
    1.11 +# Copyright 2016 (C) SliTaz GNU/Linux - BSD License
    1.12  # Author: Christophe Lincoln <pankso@slitaz.org>
    1.13  #
    1.14  . /lib/libtaz.sh
    1.15 @@ -24,10 +27,12 @@
    1.16  Commands:
    1.17    count    Count all users
    1.18    list     List all users
    1.19 +  check    Check accounts integrity
    1.20  
    1.21  Options:
    1.22    --admin  Make user admin
    1.23    --del    Delete a user
    1.24 +  --clean  check: clean users accounts
    1.25  
    1.26  EOT
    1.27  }
    1.28 @@ -52,11 +57,34 @@
    1.29  		separator
    1.30  		for user in $(ls $people)
    1.31  		do
    1.32 +			if ! [ -f "$people/$user/account.conf" ]; then
    1.33 +				echo -n "$(colorize 31 "$user")"
    1.34 +				echo -e "\\033[16GCORRUPTED" && continue
    1.35 +			fi
    1.36  			. $people/$user/account.conf
    1.37  			echo -n "$(colorize 34 "$user")"
    1.38  			echo -e "\\033[16G${NAME}"
    1.39  		done 
    1.40  		separator && newline ;;
    1.41 +	check)
    1.42 +		# Check accounts and auth file
    1.43 +		newline
    1.44 +		boldify "SliTaz accounts integrity"
    1.45 +		separator
    1.46 +		echo "$(colorize 33 "Checking account.conf files...")"
    1.47 +		for user in $(ls $people)
    1.48 +		do
    1.49 +			if ! [ -f "$people/$user/account.conf" ]; then
    1.50 +				echo -n "$(colorize 30 "$user")"
    1.51 +				echo -e "\\033[16GMissing account.conf"
    1.52 +				if [ "$clean" ]; then # --clean
    1.53 +					rm -rf "${people}/${user}"
    1.54 +					sed -i "/^${user}:/"d $authfile
    1.55 +				fi
    1.56 +				#else -- check empty VALUES
    1.57 +			fi
    1.58 +		done 
    1.59 +		separator && newline ;;
    1.60  	*)
    1.61  		# Handle general: --options
    1.62  		case " $@ " in