diff --git a/gitops_router.sh b/gitops_router.sh index 77ae656..6084eae 100644 --- a/gitops_router.sh +++ b/gitops_router.sh @@ -6,7 +6,6 @@ HOST="alps:3222" PROTOCOL="http" REPO="babbarc/workspaces" BRANCH="master" -URL="$PROTOCOL://$HOST/$REPO/raw/branch/$BRANCH" LOG_FILE="/tmp/.gitops-router-${PERSON}.log" @@ -24,15 +23,22 @@ if [[ -z "${SSH_ORIGINAL_COMMAND:-}" ]]; then exit 1 fi +geurl() { + echo "$PROTOCOL://$HOST/$REPO/$1/branch/$BRANCH/$2" +} + function run() { "$HOME"/.local/bin/"$1" } function update() { + type=${4:-raw} fname=$(basename "$1") output_path="$HOME/$2/$fname" + url=$(geturl "$type" "$1") + [ -f "$output_path" ] && chmod 700 "$output_path" - curl -fsSL "$URL/$1" -o "$output_path" && log info "Downloaded $URL/$1 to $output_path" + curl -fsSL "$url" -o "$output_path" && log info "Downloaded $url to $output_path" chmod "$3" "$output_path" } @@ -74,6 +80,9 @@ update) clean_dangling_images) update .bin/clean_dangling_images.sh .local/bin 500 ;; + home_tar) + update home.tar.gz . 500 media + ;; *) log error "Invalid arguments for update command: $args" ;;