From b38e6acfed1a7c91a623aaa962b18e4c862eeea3 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Wed, 24 May 2023 21:18:19 +0500 Subject: [PATCH] added dependecy check --- routerapi.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) 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)