tinycm rev 75

Small fix to cmdline tool and backport users plugins from tazbug
author Christophe Lincoln <pankso@slitaz.org>
date Fri Feb 10 20:32:34 2017 +0100 (2017-02-10)
parents 7b72f7f8da35
children e3cba575c564
files plugins/users/users.cgi plugins/users/users.conf tinycm
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/users/users.cgi	Fri Feb 10 20:32:34 2017 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# TinyCM/TazBug Plugin - Users profile and admin
     1.7 +#
     1.8 +
     1.9 +case " $(GET) " in
    1.10 +	*\ users\ *)
    1.11 +		d="Users"
    1.12 +		header
    1.13 +		html_header
    1.14 +		user_box
    1.15 +		if check_auth && ! admin_user; then
    1.16 +			gettext "You must be admin to manage users"
    1.17 +			exit 0
    1.18 +		fi
    1.19 +		users=$(ls -1 $PEOPLE | wc -l)
    1.20 +		cat << EOT
    1.21 +<h2>Users: $users</h2>
    1.22 +<div id="tools">
    1.23 +	<a href="$script?dashboard">Dashboard</a>
    1.24 +	<a href='?logged'>Logged users</a>
    1.25 +</div>
    1.26 +<pre>
    1.27 +EOT
    1.28 +		for u in $(ls $PEOPLE)
    1.29 +		do
    1.30 +			# Skip corrupted accounts
    1.31 +			if ! [ -f "${PEOPLE}/${u}/account.conf" ]; then
    1.32 +				echo "${u} : Missing account.conf"
    1.33 +				continue
    1.34 +			fi
    1.35 +			. "${PEOPLE}/${u}/account.conf"
    1.36 +			cat << EOT
    1.37 +$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME | $MAIL
    1.38 +EOT
    1.39 +# deluser link
    1.40 +#: <a href="?users&amp;deluser=$USER">$(gettext "delete")</a>
    1.41 +			unset NAME USER 
    1.42 +		done
    1.43 +		echo "</pre>" 
    1.44 +		html_footer && exit 0 ;;
    1.45 +	
    1.46 +	*\ logged\ *)
    1.47 +		# Show online users based on sessions files.
    1.48 +		d="Logged users"
    1.49 +		header
    1.50 +		html_header
    1.51 +		user_box
    1.52 +		if ! check_auth; then
    1.53 +			gettext "You must be logged in to view online users"
    1.54 +			exit 0
    1.55 +		fi
    1.56 +		cat << EOT
    1.57 +<h2>Logged users</h2>
    1.58 +<div id="tools">
    1.59 +	<a href="$script?dashboard">Dashboard</a>
    1.60 +</div>
    1.61 +<pre>
    1.62 +EOT
    1.63 +		for u in $(ls $sessions)
    1.64 +		do
    1.65 +			. "${PEOPLE}/${u}/account.conf"
    1.66 +			cat << EOT
    1.67 +$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME
    1.68 +EOT
    1.69 +		done
    1.70 +		echo "</pre>"
    1.71 +		html_footer && exit 0 ;;
    1.72 +esac
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/plugins/users/users.conf	Fri Feb 10 20:32:34 2017 +0100
     2.3 @@ -0,0 +1,14 @@
     2.4 +# TinyCM/TazBug Plugin configuration
     2.5 +
     2.6 +PLUGIN="Users Admin"
     2.7 +SHORT_DESC="Handle TinyCM/TazBug users"
     2.8 +MAINTAINER="devel@slitaz.org"
     2.9 +
    2.10 +# Authenticated users
    2.11 +PLUGINS_TOOLS="${PLUGINS_TOOLS}"
    2.12 +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?logged'>Logged users</a>"
    2.13 +
    2.14 +# Admin only in Dashboard
    2.15 +ADMIN_TOOLS="${ADMIN_TOOLS} <a href='?users'>List users</a>"
    2.16 +
    2.17 +# Configurable variables used in plugin.cgi
     3.1 --- a/tinycm	Thu Apr 21 10:13:55 2016 +0200
     3.2 +++ b/tinycm	Fri Feb 10 20:32:34 2017 +0100
     3.3 @@ -86,11 +86,11 @@
     3.4  		echo ""
     3.5  		boldify $(echo "Updating TinyCM installs...")
     3.6  		
     3.7 -		# Priority to cmdline path argument
     3.8 -		if [ "$path" ]; then
     3.9 +		# File liste of args
    3.10 +		if [ -f "$path" ]; then
    3.11 +			paths="$(cat ${list})"
    3.12 +		else
    3.13  			paths="$path"
    3.14 -		else
    3.15 -			paths="$(cat ${list})"
    3.16  		fi
    3.17  		
    3.18  		for path in ${paths}