mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
37 lines
753 B
Bash
Executable file
37 lines
753 B
Bash
Executable file
#!/bin/sh
|
|
|
|
BBF_DIAG_SCRIPTS="/usr/share/bbfdm/bbf_diag"
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
case "$1" in
|
|
list)
|
|
# Open the JSON object
|
|
output_json="{"
|
|
|
|
first_iteration=true
|
|
|
|
for file in "${BBF_DIAG_SCRIPTS}"/*; do
|
|
[ -f "${file}" ] || continue
|
|
|
|
file_output=$(sh "${file}" "$1")
|
|
|
|
# Add a comma for all iterations after the first one
|
|
[ "$first_iteration" = true ] || output_json="${output_json},"
|
|
first_iteration=false
|
|
|
|
# Concatenate the output to the result
|
|
output_json="${output_json}${file_output}"
|
|
done
|
|
|
|
# Close the JSON object
|
|
output_json="${output_json}}"
|
|
|
|
# Return the concatenated JSON output
|
|
echo "$output_json"
|
|
;;
|
|
call)
|
|
# Read the arguments
|
|
read -r input
|
|
sh "${BBF_DIAG_SCRIPTS}/${2}" "${input}"
|
|
;;
|
|
esac
|