aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/update-dotnet
blob: 84451833bb73e50d06e7fe1701f5a3b80dcfde76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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"