Created
May 26, 2023 15:00
-
-
Save snydergd/795ccc4dd8a5df92ae4cd03557cbae09 to your computer and use it in GitHub Desktop.
PowerShell installer Script for Linux - to make installation/upgrade easier
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/bash | |
usage() { | |
echo "Usage: $0 <version> # version example: 7.4.0-preview.3" >&2; | |
} | |
if [ "$1x" = "x" ]; then | |
usage; | |
echo "No version supplied - using default" >&2; | |
VERSION="7.4.0-preview.3"; | |
else | |
VERSION="$1"; | |
fi; | |
DOWNLOAD_URL="https://github.com/PowerShell/PowerShell/releases/download/v${VERSION}/powershell-${VERSION}-linux-x64.tar.gz"; | |
OUTPUT_FOLDER="${HOME}/pwsh/pwsh-${VERSION}"; | |
LINK_FOLDER="${HOME}/pwsh/current"; | |
if [ -e "${OUTPUT_FOLDER}" ]; then | |
echo "Folder ${OUTPUT_FOLDER} already exists. Not installing." >&2; | |
else | |
echo "Using version ${VERSION}"; | |
mkdir -p "${OUTPUT_FOLDER}"; | |
cd "${OUTPUT_FOLDER}"; | |
curl -L "${DOWNLOAD_URL}" | tar -xzv; | |
fi; | |
echo "Creating symlink to ${OUTPUT_FOLDER} at ${LINK_FOLDER}" >&2; | |
ln -sf "${OUTPUT_FOLDER}" "${LINK_FOLDER}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment