refactoring user section: new html formating

This commit is contained in:
Serghey Rodin 2012-09-10 14:06:30 +03:00
commit 427b254138
22 changed files with 1825 additions and 1443 deletions

View file

@ -1,64 +0,0 @@
#!/bin/bash
# info: list system users
# options: [format]
#
# The function for obtaining the list of system users.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
format=${1-shell}
# Includes
source $VESTA/func/main.sh
# Json function
json_list_users() {
users=$(grep @ /etc/passwd|cut -f 1 -d :)
int_counter=$(echo "$users" | wc -l)
i=1
echo '['
for user in $users; do
if [ "$i" -lt "$int_counter" ]; then
echo -e "\t\"$user\","
else
echo -e "\t\"$user\""
fi
(( ++i))
done
echo "]"
}
# Shell function
shell_list_users() {
if [ -z "$nohead" ]; then
echo "USERS"
echo "----------"
fi
for user in $(grep @ /etc/passwd|cut -f 1 -d :); do
echo "$user"
done
}
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Listing domains
case $format in
json) json_list_users ;;
plain) nohead=1; shell_list_users ;;
shell) shell_list_users ;;
*) check_args '1' '0' '[format]' ;;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit