From ac82537fb4a1fd83767a2177c9d9cc6a8c33f240 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Tue, 10 Mar 2020 09:52:04 +0100 Subject: [PATCH] added downloadURLFromGit --- Installomator.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index eddb4a6..d32d3b6 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -1,6 +1,10 @@ #!/bin/sh -# Downloads and installs the app +# Installomator + +# Downloads and installs an Applications + +# inspired by the download scripts from William Smith and Sander Schram export PATH=/usr/bin:/bin:/usr/sbin:/sbin @@ -13,7 +17,6 @@ else identifier=${4:?"argument $4 required"} fi - # each identifier needs to be listed in the case statement below # for each identifier these three variables must be set: # @@ -35,6 +38,23 @@ fi targetDir="/Applications" # this can be overridden below if you want a different location for a specific identifier + +# functions to help with getting info + +downloadURLFromGit() { # $1 git user name, $2 git repo name + gitusername=${1?:"no git user name"} + gitreponame=${2?:"no git repo name"} + + downloadURL=$(curl --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | awk -F '"' '/browser_download_url/ { print $4 }') + if [ -z "$downloadURL" ]; then + echo "could not retrieve download URL for $gitusername/$gitreponame" + cleanupAndExit 9 + else + echo "$downloadURL" + return 0 + fi +} + case $identifier in GoogleChrome)