diff options
| -rwxr-xr-x | scripts/.local/bin/update-dotnet | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/.local/bin/update-dotnet b/scripts/.local/bin/update-dotnet new file mode 100755 index 0000000..8445183 --- /dev/null +++ b/scripts/.local/bin/update-dotnet @@ -0,0 +1,30 @@ +#!/bin/sh + +set -ef + +INSTALLLOCATION="$HOME/dotnet" + +[ -z "$1" ] && echo "$0: missing url" && exit 1 + +if [ -n "$2" ]; then + INSTALLLOCATION="$2" +fi + +if [ -d "$INSTALLLOCATION" ]; then + echo "$INSTALLLOCATION already exists, do you want to remove it? <y/N>" + read -r RESPONSE + [ "$RESPONSE" = "y" ] && rm -r "$INSTALLLOCATION" +fi + +TMPFILE=$(mktemp) + +mkdir -p "$INSTALLLOCATION" + +echo "downloading..." +curl -o "$TMPFILE" "$1" +echo "extracting..." +tar zxf "$TMPFILE" -C "$INSTALLLOCATION" +echo "cleaning up temp files..." +rm "$TMPFILE" + +echo "dotnet was successfully installed in $INSTALLLOCATION" |
