Files
VestaCP/bin/v-list-sys-shells

68 lines
1.5 KiB
Plaintext
Raw Normal View History

2013-01-19 23:07:26 +02:00
#!/bin/bash
# info: list system shells
# options: [FORMAT]
#
# The function for obtaining the list of system shells.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-01-19 23:07:26 +02:00
format=${1-shell}
# Includes
source $VESTA/func/main.sh
# Json function
json_list_sh() {
2013-07-09 09:50:18 +03:00
shells=$(grep -v '#' /etc/shells)
2013-01-19 23:07:26 +02:00
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() {
2013-07-09 09:50:18 +03:00
shells=$(grep -v '#' /etc/shells)
2013-01-19 23:07:26 +02:00
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