Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -1115,3 +1115,8 @@ NTLM
NumberBytes
ResponseHeaders
#endregion
includeide
interactivetesting
allowprerelease
prereleases
url
15 changes: 8 additions & 7 deletions tools/install-powershell-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
* native package manager available
* `curl` (auto-installed if missing)

## Parameters

* -includeide - installs vscode and vscode powershell extension (only relevant to machines with desktop environment)
* -interactivetesting - do a quick launch test of vscode - only relevant when used with -includeide
* -skip-sudo-check - use sudo without verifying it's availability (hard to accurately do on some distros)
* -allowprerelease - includes prereleases of powershell core when selection allows this. Repository based installs take the latest on the repo url regardless of this switch.

## Usage

### Direct from Github
Expand Down Expand Up @@ -55,12 +62,6 @@ bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/
bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) -includeide -interactivetesting
```

### Install AppImage

```bash
bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) -appimage
```

### Installation To do list

* Detect and wait when package manager is busy/locked? - at least Ubuntu (CentOS does this internally)
* Detect and wait when package manager is busy/locked? - at least Ubuntu (CentOS does this internally)
2 changes: 1 addition & 1 deletion tools/install-powershell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ install(){

#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution

local VERSION="1.1.1"
local VERSION="1.2.0"
local gitreposubpath="PowerShell/PowerShell/master"
local gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
local gitscriptname="install-powershell.psh"
Expand Down
39 changes: 25 additions & 14 deletions tools/installpsh-amazonlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution


VERSION="1.1.2"
VERSION="1.2.0"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=amazonlinux
Expand Down Expand Up @@ -120,19 +120,20 @@ fi

## Check requirements and prerequisites

#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
#Check for sudo if not root
if [[ "${CI}" == "true" ]]; then
echo "Running on CI (as determined by env var CI set to true), skipping SUDO check."
set -- "$@" '-skip-sudo-check'
fi

#Check that sudo is available
if [[ "$SUDO" -eq "sudo" ]]; then

$SUDO -v
if [ $? -ne 0 ]; then
echo "ERROR: You must either be root or be able to use sudo" >&2
exit 5
SUDO=''
if (( $EUID != 0 )); then
#Check that sudo is available
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
SUDO='sudo'
else
echo "ERROR: You must either be root or be able to use sudo" >&2
#exit 5
fi
fi

Expand All @@ -155,7 +156,17 @@ $SUDO yum install -y \

echo
echo "*** Installing PowerShell Core for $DistroBasedOn..."
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`

echo "ATTENTION: As of version 1.2.0 this script no longer uses pre-releases unless the '-allowprereleases' switch is used"

if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, prereleases will be included in the retrieval of the latest version"
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
else
echo "Finding the latest release production release"
release=$(curl https://api.github.com/repos/PowerShell/PowerShell/releases | grep -Po '"tag_name":(\d*?,|.*?[^\\]",)' | grep -Po '\d+.\d+.\d+[\da-z.-]*' | grep -v '[a-z]' | sort | tail -n1)
if

#DIRECT DOWNLOAD
pwshlink=/usr/bin/pwsh
Expand Down Expand Up @@ -210,7 +221,7 @@ fi

if [[ "'$*'" =~ -interactivetesting ]] ; then
echo
echo "Amazon Linux does not have a desktop manager to support vscode, ignoring -includeide"
echo "Amazon Linux does not have a desktop manager to support vscode, ignoring -interactivetesting"
fi

if [[ "$repobased" == true ]] ; then
Expand Down
42 changes: 24 additions & 18 deletions tools/installpsh-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution

VERSION="1.1.2"
VERSION="1.2.0"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=debian
Expand Down Expand Up @@ -87,19 +87,20 @@ fi

## Check requirements and prerequisites

#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
#Check for sudo if not root
if [[ "${CI}" == "true" ]]; then
echo "Running on CI (as determined by env var CI set to true), skipping SUDO check."
set -- "$@" '-skip-sudo-check'
fi

#Check that sudo is available
if [[ "$SUDO" == "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then

$SUDO -v
if [ $? -ne 0 ]; then
echo "ERROR: You must either be root or be able to use sudo" >&2
exit 5
SUDO=''
if (( $EUID != 0 )); then
#Check that sudo is available
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
SUDO='sudo'
else
echo "ERROR: You must either be root or be able to use sudo" >&2
#exit 5
fi
fi

Expand All @@ -120,6 +121,12 @@ if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
$SUDO apt-get install -y curl
fi

if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, but since $DistroBasedOn uses repositories - selection of releases will depend on the repository contents."
fi

release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`

echo "*** Current version on git is: $currentversion, repo version may differ slightly..."
Expand Down Expand Up @@ -188,12 +195,11 @@ if [[ "'$*'" =~ includeide ]] ; then
echo
echo "*** Installing VS Code PowerShell Extension"
code --install-extension ms-vscode.PowerShell
fi

if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
fi

if [[ "$repobased" == true ]] ; then
Expand Down
40 changes: 10 additions & 30 deletions tools/installpsh-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,12 @@ fi

## Check requirements and prerequisites

#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi

#Check that sudo is available
#if [[ "$SUDO" -eq "sudo" ]]; then
# $SUDO -v
# if [ $? -ne 0 ]; then
# echo "ERROR: You must either be root or be able to use sudo" >&2
# exit 5
# fi
#fi

#END Collect any variation details if required for this distro

#If there are known incompatible versions of this distro, put the test, message and script exit here:

#END Verify The Installer Choice

##END Check requirements and prerequisites

echo "*** Installing PowerShell Core for $DistroBasedOn..."

#release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, but since $DistroBasedOn uses repositories - selection of releases will depend on the repository contents."
fi

if ! hash brew 2>/dev/null; then
echo "Homebrew is not found, installing..."
Expand Down Expand Up @@ -176,8 +156,14 @@ if [[ "'$*'" =~ includeide ]] ; then

echo "*** Installing VS Code PowerShell Extension"
code --install-extension ms-vscode.PowerShell
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
fi


pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
Run `"pwsh`" to start a PowerShell session."'

Expand All @@ -188,12 +174,6 @@ if [[ "$success" != 0 ]]; then
exit "$success"
fi

if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
$SUDO curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi

if [[ "$repobased" == true ]] ; then
echo "*** NOTE: Run your regular package manager update cycle to update PowerShell Core"
fi
Expand Down
51 changes: 23 additions & 28 deletions tools/installpsh-redhat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution


VERSION="1.1.2"
VERSION="1.2.0"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=redhat
Expand Down Expand Up @@ -90,33 +90,29 @@ fi

## Check requirements and prerequisites

#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
#Check for sudo if not root
if [[ "${CI}" == "true" ]]; then
echo "Running on CI (as determined by env var CI set to true), skipping SUDO check."
set -- "$@" '-skip-sudo-check'
fi

#Check that sudo is available
if [[ "$SUDO" == "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then

$SUDO -v
if [ $? -ne 0 ]; then
echo "ERROR: You must either be root or be able to use sudo" >&2
exit 5
SUDO=''
if (( $EUID != 0 )); then
#Check that sudo is available
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
SUDO='sudo'
else
echo "ERROR: You must either be root or be able to use sudo" >&2
#exit 5
fi
fi

#Collect any variation details if required for this distro

#END Collect any variation details if required for this distro

#If there are known incompatible versions of this distro, put the test, message and script exit here:

#END Verify The Installer Choice

##END Check requirements and prerequisites
if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, but since $DistroBasedOn uses repositories - selection of releases will depend on the repository contents."
fi

echo
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`echo
echo "*** Installing PowerShell Core for $DistroBasedOn..."
if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
Expand Down Expand Up @@ -152,12 +148,11 @@ if [[ "'$*'" =~ includeide ]] ; then
echo
echo "*** Installing VS Code PowerShell Extension"
code --install-extension ms-vscode.PowerShell
fi

if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
fi

if [[ "$repobased" == true ]] ; then
Expand Down
Loading