Add Get servers script
This commit is contained in:
parent
1fe899744d
commit
c4ad09c4f3
1 changed files with 23 additions and 0 deletions
23
scripts/get_servers
Executable file
23
scripts/get_servers
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
regex=${1}
|
||||
domains_regex=$(yq -r '.domains_regex' ${HOME}/.config/sunet/config.yaml 2>/dev/null)
|
||||
|
||||
if [[ -z ${regex} ]]; then
|
||||
regex='.*'
|
||||
fi
|
||||
|
||||
if [[ -z ${domains_regex} ]] || [[ ${domains_regex} == 'null' ]]; then
|
||||
domains_regex='sunet.se|sunet.dev|eduid.se|swamid.se'
|
||||
fi
|
||||
|
||||
readarray -t directories < <(yq -r '.ops_repos[]' ${HOME}/.config/sunet/config.yaml 2>/dev/null)
|
||||
if [[ -z ${directories} ]]; then
|
||||
echo "No ops repos found in ${HOME}/.config/sunet/config.yaml"
|
||||
exit 1
|
||||
fi
|
||||
for directory in "${directories[@]}"; do
|
||||
servers="$(ls "${directory}"|grep -E "${domains_regex}")"
|
||||
echo "${servers}" | grep -E "${regex}"
|
||||
done
|
||||
|
Loading…
Add table
Reference in a new issue