diff --git a/routerapi.sh b/routerapi.sh index 4f41490..1f9522f 100755 --- a/routerapi.sh +++ b/routerapi.sh @@ -1,5 +1,15 @@ #!/bin/bash +dependency_check(){ + for DEPENDENCY; do + if ! command -v "$DEPENDENCY" 1>/dev/null; then + printf "%s not found. Please install it.\n" "$DEPENDENCY" >&2 + exit 2 + fi + done + unset DEPENDENCY +} +dependency_check "htmlq" "xmlstarlet" "tail" "head" "curl" home_html=$(curl -s $ROUTER_ADDRESS/html/home.html) csrf_token1=$(echo $home_html | htmlq 'meta[name="csrf_token"]' --attribute content | head -n1)