-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller-8.0.sh
71 lines (44 loc) · 1.57 KB
/
installer-8.0.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
echo '---------------- Install .NET 8 SDK - Install/Setup Script ---------------'
echo 'For issues or suggestions, visit https://github.com/dahln/dotnet-installer'
echo '--------------------------------------------------------------------------'
dotnetver=8.0
sdkTar=/tmp/dotnetsdk.tar.gz
download() {
[[ $downloadspage =~ $1 ]]
linkpage=$(wget -qO - https://dotnet.microsoft.com${BASH_REMATCH[1]})
matchdl='id="directLink" href="([^"]*)"'
[[ $linkpage =~ $matchdl ]]
wget -O $2 "${BASH_REMATCH[1]}"
}
if [[ $EUID -ne 0 ]]; then
echo -e "==> This script must be run as root (sudo $0)"
exit 1
fi
echo '==> Installing Dependencies...'
apt install libunwind8 gettext -y
echo '==> Cleaning up old files...'
rm -f $sdkTar
echo "==> Downloading .NET SDK $dotnetver..."
downloadspage=$(wget -qO - https://dotnet.microsoft.com/download/dotnet/$dotnetver)
download 'href="([^"]*sdk-[^"/]*linux-arm64-binaries)"' $sdkTar
echo '==> Creating /opt/dotnet directory...'
if [[ -d /opt/dotnet ]]; then
echo "/opt/dotnet already exists"
else
mkdir /opt/dotnet
fi
echo "==> Extracing .NET SDK version $dotnetver..."
tar -xvf $sdkTar -C /opt/dotnet/
echo '==> Linking to user profile...'
ln -s /opt/dotnet/dotnet /usr/local/bin
echo '==> Updating Path...'
if grep -q 'export DOTNET_ROOT=' /root/.bashrc; then
echo '.bashrc already up-to-date'
else
echo 'Updating .bashrc'
echo 'export DOTNET_ROOT=/opt/dotnet' >> /root/.bashrc
fi
echo '==> Finished'
echo 'Rebooting is suggested'
echo 'run "dotnet --info" to test if SDK is correctly installed'