From ee31a9f8e2c5c42460f8cdcf32db57906a8bf02a Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Fri, 23 Aug 2024 20:36:01 +0200 Subject: [PATCH] create check_dependency function --- update.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/update.sh b/update.sh index e973328..2436823 100755 --- a/update.sh +++ b/update.sh @@ -7,13 +7,20 @@ TAILWINDCSS_REPO_URL=https://api.github.com/repos/tailwindlabs/tailwindcss/relea TMP_DIR=/tmp BIN_DIR=/usr/local/bin +check_dependency() { + if ! which $1 >/dev/null 2>&1; then + echo "$1 needs to be installed" >&2 + exit 1 + fi +} + ! groups | grep -E 'root|wheel|sudo' >/dev/null && echo "You need administrative privileges for this script" && exit 1 -! which curl >/dev/null 2>&1 && echo "curl needs to be installed" >&2 && exit 1 -! which go >/dev/null 2>&1 && echo "go needs to be installed" >&2 && exit 1 -! which jq >/dev/null 2>&1 && echo "jq needs to be installed" >&2 && exit 1 -! which tar >/dev/null 2>&1 && echo "tar needs to be installed" >&2 && exit 1 -! which xargs >/dev/null 2>&1 && echo "xargs needs to be installed" >&2 && exit 1 +check_dependency curl +check_dependency go +check_dependency jq +check_dependency tar +check_dependency xargs echo -e '\nDownloading cpolis...' rm -fr $CPOLIS_DIR/*