#!/bin/bash
#
# Guralp Configuration System
#   Copyright (c) 2010 Guralp Systems Ltd. All rights reserved.
#
#   Generate top level user config menu

if [ "X$1" == "X--navbar" ]
then
	echo "usertop	Users"
	exit 0
fi


# Load support functions
script_dir=$(dirname $0)
. $script_dir/functions.sh

# Build a sorted list of configurable users.  
declare -i i=0

awk -F : '{ if ( $3 >= 1000 && $3 <= 65000 ) print $1 }' < /etc/passwd \
	| sort \
	| ( echo root ; cat ) \
	| while read id
do
	name=$(awk -v ID=$id -F : '{ if ( ID == $1 ) print $5 }' < /etc/passwd)
	[ -z "$name" ] && name=$id
	echo "select_user${i}=$id $id - $name"
	((i++))
done

exit 0
