Last active
May 19, 2021 19:25
-
-
Save roberttoups/eb2fd05b1684de4f862e172a78e6a757 to your computer and use it in GitHub Desktop.
Will automatically download and install the latest and greatest version of PowerShell for Raspberry Pi then make it available for the 'pi' user. It uses the PowerShell stable version API return for the version. The script will leave behind the gzip tarball. The contents will be expanded into '/home/pi/PowerShell'. A symbolic link to '/home/pi/Po…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Update the Pi and ensure dependencies | |
sudo apt-get update && sudo apt-get install '^libssl1.0.[0-9]$' libunwind8 jq -y | |
# Variables | |
# Ask Microsoft for the version | |
VERSION=$(curl -s https://pscoretestdata.blob.core.windows.net/buildinfo/stable.json | jq .ReleaseTag | cut -c3-7) | |
# Payload nomenclature | |
TARBALL="powershell-$VERSION-linux-arm32.tar.gz" | |
# Where its coming from | |
BASEURI="https://github.com/PowerShell/PowerShell/releases/download/v$VERSION" | |
# Where we are putting it | |
TARGETDIR=$(realpath ~/PowerShell) | |
# Where it will be executed from | |
PWSHPATH='/usr/local/bin/pwsh' | |
# Form the URI | |
URI="$BASEURI/$TARBALL" | |
# Moving Parts | |
# Destroy existing | |
rm $TARBALL | |
rm -rf $TARGETDIR | |
# wget it | |
wget $URI | |
# Make the target directory | |
mkdir -p $TARGETDIR | |
# Explode the tarball | |
tar -xvf ./$TARBALL -C $TARGETDIR | |
# Make a symbolic gesture | |
if [ ! -f $PWSHPATH ]; then | |
sudo ln -s $TARGETDIR/pwsh $PWSHPATH | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment