hjson and jq in bash
This commit is contained in:
parent
87250d5c77
commit
c3ed03e865
@ -5,6 +5,20 @@ usage() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
get_hosts_json() {
|
||||
curl -s http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts | ${HOME}/bin/hjson -j
|
||||
}
|
||||
|
||||
get_user_hosts() {
|
||||
User=${1}
|
||||
Domain=${2}
|
||||
|
||||
get_hosts_json | jq -r \
|
||||
--arg domain "${Domain}" \
|
||||
--arg usr "${User}" \
|
||||
'.[$domain] | to_entries[] | select(.value.users[] | contains($usr)) | .key'
|
||||
}
|
||||
|
||||
echo "Started ${0} ${*} ..."
|
||||
|
||||
Domain=cvtt.vpn
|
||||
@ -21,13 +35,10 @@ echo ${Cmd} && eval ${Cmd}
|
||||
for User in cvtt oleg
|
||||
do
|
||||
echo "User=$User"
|
||||
hosts=$(
|
||||
curl -s http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts | jq -r \
|
||||
--arg domain "${Domain}" \
|
||||
--arg usr "${User}" \
|
||||
'.[$domain] | to_entries[] | select(.value.users[] | contains($usr)) | .key'
|
||||
)
|
||||
hosts=$(get_user_hosts ${User} ${Domain})
|
||||
mkdir -p ${RootDir}/${User}
|
||||
print ${hosts}
|
||||
exit
|
||||
for host in ${hosts}
|
||||
do
|
||||
echo "===================="
|
||||
|
||||
@ -1 +1 @@
|
||||
1.3.1
|
||||
1.3.2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user