/
v-list-sys-shells
executable file
·83 lines (71 loc) · 1.7 KB
/
v-list-sys-shells
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# info: list system shells
# options: [FORMAT]
#
# example: v-list-sys-shells
#
# This function for obtaining the list of system shells.
#----------------------------------------------------------#
# Variables & Functions #
#----------------------------------------------------------#
# Argument definition
format=${1-shell}
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# load config file
source_conf "$HESTIA/conf/hestia.conf"
# JSON list function
json_list() {
sh_counter=$(echo "$shells" | wc -l)
i=1
echo '['
for shell in $shells; do
if [ "$i" -lt "$sh_counter" ]; then
echo -e "\t\"$shell\","
else
echo -e "\t\"$shell\""
fi
((++i))
done
echo "]"
}
# SHELL list function
shell_list() {
echo "SHELL"
echo "-----"
for shell in $shells; do
echo "$shell"
done
}
# PLAIN list function
plain_list() {
for shell in $shells; do
echo "$shell"
done
}
# CSV list function
csv_list() {
echo "SHELL"
for shell in $shells; do
echo "$shell"
done
}
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining system shells
shells=$(grep -v '#' /etc/shells | awk -F '/' '{print $NF}' | sort -u)
# Listing data
case $format in
json) json_list ;;
plain) plain_list ;;
csv) csv_list ;;
shell) shell_list ;;
esac
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
exit