vesta/bin/v-list-sys-shells
2013-07-09 09:50:18 +03:00

68 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# info: list system shells
# options: [FORMAT]
#
# The function for obtaining the list of system shells.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
format=${1-shell}
# Includes
source $VESTA/func/main.sh
# Json function
json_list_sh() {
shells=$(grep -v '#' /etc/shells)
sh_counter=$(echo "$shells" | wc -l)
i=1
echo '['
for shell in $shells; do
shell=$(basename $shell)
if [ "$i" -lt "$sh_counter" ]; then
echo -e "\t\"$shell\","
else
echo -e "\t\"$shell\""
fi
(( ++i))
done
echo "]"
}
# Shell function
shell_list_sh() {
shells=$(grep -v '#' /etc/shells)
if [ -z "$nohead" ]; then
echo "SHELLS"
echo "----------"
fi
for shell in $shells; do
shell=$(basename $shell)
echo "$shell"
done
}
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Listing domains
case $format in
json) json_list_sh ;;
plain) nohead=1; shell_list_sh ;;
shell) shell_list_sh ;;
*) check_args '1' '0' '[FORMAT]' ;;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit