Skip to content

Instantly share code, notes, and snippets.

@pjgpetecodes
Created November 11, 2020 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjgpetecodes/a4f34a3963a7628ba1ebd302d5fcc913 to your computer and use it in GitHub Desktop.
Save pjgpetecodes/a4f34a3963a7628ba1ebd302d5fcc913 to your computer and use it in GitHub Desktop.
.NET 5 Install Script - 11-11-20
#!/bin/bash
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Dot Net 5 Installer"
echo -e "\e[1m----------------------------------------"
echo ""
echo -e "\e[1mPete Codes / PJG Creations 2020"
echo ""
echo -e "Latest update 11/11/2020"
echo ""
echo "This will install the following;"
echo ""
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
echo "- .NET 5.0.100"
echo "- ASP.NET 5.0.000"
echo ""
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
echo -e "Any suggestions or questions, email \e[1;4mpete@pjgcreations.co.uk"
echo -e "\e[0mSend me a tweet \e[1;4m@pete_codes"
echo -e "\e[0mTutorials on \e[1;4mhttps://www.petecodes.co.uk"
echo ""
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root"
exit 1
fi
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Installing Dependencies"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
apt-get -y install libunwind8 gettext
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Remove Old Binaries"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
cd ~/
rm dotnet-sdk*
rm aspnetcore*
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Getting Dot Net 5 Binaries"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
wget https://download.visualstudio.microsoft.com/download/pr/e8912d3b-483b-4d6f-bd3a-3066b3194313/20f2261fe4e16e55df4bbe03c65a7648/dotnet-sdk-5.0.100-linux-arm.tar.gz
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Getting ASP.NET 5 Runtime"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
wget https://download.visualstudio.microsoft.com/download/pr/1c5366e8-9b74-4017-96ae-47fc08832c22/504aed87590bd99c49d053bc6f980b6b/aspnetcore-runtime-5.0.0-linux-arm.tar.gz
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Creating Main Directory"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
if [[ -d /opt/dotnet ]]; then
echo "/opt/dotnet already exists on your filesystem."
else
echo "Creating Main Directory"
echo ""
mkdir /opt/dotnet
fi
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Extracting Dot NET 5 Binaries"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
tar -xvf dotnet-sdk-5.0.100-linux-arm.tar.gz -C /opt/dotnet/
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Extracting ASP.NET 5 Runtime"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
tar -xvf aspnetcore-runtime-5.0.0-linux-arm.tar.gz -C /opt/dotnet/
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Link Binaries to User Profile"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
ln -s /opt/dotnet/dotnet /usr/local/bin
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Make Link Permanent"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
if grep -q 'export DOTNET_ROOT=' /home/pi/.bashrc; then
echo 'Already added link to .bashrc'
else
echo 'Adding Link to .bashrc'
echo 'export DOTNET_ROOT=/opt/dotnet' >> /home/pi/.bashrc
fi
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m Run dotnet --info"
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
dotnet --info
echo -e "\e[0m"
echo -e "\e[1m----------------------------------------"
echo -e "\e[1m ALL DONE!"
echo ""
echo -e "\e[0mGo ahead and run \e[1mdotnet new console \e[0min a new directory!"
echo ""
echo ""
echo -e "Let me know how you get on by tweeting me at \e[1;5m@pete_codes"
echo ""
echo -e "\e[1m----------------------------------------"
echo -e "\e[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment