mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-27 03:46:23 +08:00
Make install scripts more consistent over different operating systems (#9071)
I noticed a couple of inconsistencies when reading through the install bash scripts. - Make documentation for switches consistent over all files. - Replace all `sed` implementations of `lowercase` with a more maintainable `tr` implementation. - Set the `OS` variable in every install script, making it so previously unused checks are actually used. - Exit with a non-zero exit code when the script reaches an illegal state. ## PR Context A lot of people, including myself, read the install scripts before executing them. While doing so I noticed they contained inconsistencies. For example, certain flags you can pass to the install script were either undocumented or had an incorrect description. This PR fixes some of these inconsistencies, which should make them easier to maintain and easier to read. Co-authored-by: Travis Plunk <github@ez13.net>
This commit is contained in:
parent
b23e835d2d
commit
7031954669
@ -44,6 +44,19 @@ phases:
|
||||
jobName: InstallPowerShellUbuntu
|
||||
pool: Hosted Ubuntu 1604
|
||||
|
||||
# amazonlinux was missing adduser
|
||||
|
||||
- template: templates/install-ps-phase.yml
|
||||
parameters:
|
||||
scriptName: ./tools/install-powershell.sh
|
||||
jobName: InstallPowerShellCentOS
|
||||
pool: Hosted Ubuntu 1604
|
||||
container: mcr.microsoft.com/powershell:centos-7
|
||||
|
||||
# VSTS could not find pwsh in:
|
||||
# mcr.microsoft.com/powershell:opensuse-42.3
|
||||
# could not repo locally
|
||||
|
||||
- template: templates/install-ps-phase.yml
|
||||
parameters:
|
||||
scriptName: ./tools/install-powershell.sh
|
||||
|
@ -2,14 +2,18 @@ parameters:
|
||||
pool: 'Hosted Ubuntu 1604'
|
||||
jobName: 'none'
|
||||
scriptName: ''
|
||||
container: ''
|
||||
|
||||
jobs:
|
||||
|
||||
- job: ${{ parameters.jobName }}
|
||||
variables:
|
||||
scriptName: ${{ parameters.scriptName }}
|
||||
|
||||
pool:
|
||||
name: ${{ parameters.pool }}
|
||||
${{ if ne(parameters.container, '') }}:
|
||||
container: ${{ parameters.container }}
|
||||
|
||||
pool: ${{ parameters.pool }}
|
||||
|
||||
displayName: ${{ parameters.jobName }}
|
||||
|
||||
|
@ -51,7 +51,7 @@ function New-XmlElement
|
||||
}
|
||||
}
|
||||
|
||||
# Removes an XmlElement and it's parent if it is empty
|
||||
# Removes an XmlElement and its parent if it is empty
|
||||
function Remove-XmlElement
|
||||
{
|
||||
param(
|
||||
|
@ -21,10 +21,11 @@
|
||||
|
||||
## 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)
|
||||
* -preview - installs preview of powershell core side-by-side with any existing production releases.
|
||||
* -includeide - installs VSCode and VSCode PowerShell extension (only relevant to machines with a desktop environment)
|
||||
* -interactivetesting - do a quick launch test of VSCode (only relevant when used with -includeide)
|
||||
* -skip-sudo-check - use sudo without verifying its availability (hard to accurately do on some distros)
|
||||
* -preview - installs the latest preview release of PowerShell core side-by-side with any existing production releases
|
||||
* -appimage - perform an AppImage install instead of a native install
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -18,9 +18,11 @@ install(){
|
||||
#Completely automated install requires a root account or sudo with a password requirement
|
||||
|
||||
#Switches
|
||||
# -includeide - the script is being run headless, do not perform actions that require response from the console
|
||||
# -interactivetesting - requires a human user in front of the machine - loads a script into the ide to test with F5 to ensure the IDE can run scripts
|
||||
# -appimage - does appimage instead of native install
|
||||
# -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 its availability (hard to accurately do on some distros)
|
||||
# -preview - installs the latest preview release of PowerShell core side-by-side with any existing production releases
|
||||
# -appimage - perform an AppImage install instead of a native install
|
||||
|
||||
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
|
||||
|
||||
@ -31,7 +33,7 @@ install(){
|
||||
|
||||
echo "Get-PowerShell Core MASTER Installer Version $VERSION"
|
||||
echo "Installs PowerShell Core and Optional The Development Environment"
|
||||
echo " Original script is at: $gitreposcriptroot\$gitscriptname"
|
||||
echo " Original script is at: $gitreposcriptroot\\$gitscriptname"
|
||||
|
||||
echo "Arguments used: $*"
|
||||
echo ""
|
||||
@ -44,12 +46,15 @@ install(){
|
||||
' INT
|
||||
|
||||
lowercase(){
|
||||
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
echo "$1" | tr "[:upper:]" "[:lower:]"
|
||||
}
|
||||
|
||||
local OS=`lowercase \`uname\``
|
||||
local KERNEL=`uname -r`
|
||||
local MACH=`uname -m`
|
||||
local OS
|
||||
OS=$(lowercase "$(uname)")
|
||||
local KERNEL
|
||||
KERNEL=$(uname -r)
|
||||
local MACH
|
||||
MACH=$(uname -m)
|
||||
local DIST
|
||||
local DistroBasedOn
|
||||
local PSUEDONAME
|
||||
@ -58,33 +63,33 @@ install(){
|
||||
if [ "${OS}" == "windowsnt" ]; then
|
||||
OS=windows
|
||||
DistroBasedOn=windows
|
||||
SCRIPTFOLDER=$(dirname $(readlink -f $0))
|
||||
SCRIPTFOLDER=$(dirname "$(readlink -f "$0")")
|
||||
elif [ "${OS}" == "darwin" ]; then
|
||||
OS=osx
|
||||
DistroBasedOn=osx
|
||||
# readlink doesn't work the same on macOS
|
||||
SCRIPTFOLDER=$(dirname $0)
|
||||
SCRIPTFOLDER=$(dirname "$0")
|
||||
else
|
||||
SCRIPTFOLDER=$(dirname $(readlink -f $0))
|
||||
OS=`uname`
|
||||
SCRIPTFOLDER=$(dirname "$(readlink -f "$0")")
|
||||
OS=$(uname)
|
||||
if [ "${OS}" == "SunOS" ] ; then
|
||||
OS=solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
ARCH=$(uname -p)
|
||||
OSSTR="${OS} ${REV}(${ARCH} $(uname -v))"
|
||||
DistroBasedOn=sunos
|
||||
elif [ "${OS}" == "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
OSSTR="${OS} $(oslevel) ($(oslevel -r))"
|
||||
DistroBasedOn=aix
|
||||
elif [ "${OS}" == "Linux" ] ; then
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
DistroBasedOn='redhat'
|
||||
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
|
||||
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
DIST=$(sed s/\ release.*// < /etc/redhat-release)
|
||||
PSUEDONAME=$( (sed s/.*\(// | sed s/\)//) < /etc/redhat-release )
|
||||
REV=$( (sed s/.*release\ // | sed s/\ .*//) < /etc/redhat-release )
|
||||
elif [ -f /etc/system-release ] ; then
|
||||
DIST=`cat /etc/system-release |sed s/\ release.*//`
|
||||
PSUEDONAME=`cat /etc/system-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/system-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
DIST=$(sed s/\ release.*// < /etc/system-release)
|
||||
PSUEDONAME=$( (sed s/.*\(// | sed s/\)//) < /etc/system-release )
|
||||
REV=$( (sed s/.*release\ // | sed s/\ .*//) < /etc/system-release )
|
||||
if [[ $DIST == *"Amazon Linux"* ]] ; then
|
||||
DistroBasedOn='amazonlinux'
|
||||
else
|
||||
@ -92,23 +97,23 @@ install(){
|
||||
fi
|
||||
elif [ -f /etc/SuSE-release ] ; then
|
||||
DistroBasedOn='suse'
|
||||
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
|
||||
REV=`cat /etc/SuSE-release | grep 'VERSION' | sed s/.*=\ //`
|
||||
PSUEDONAME=$( (tr "\n" ' '| sed s/VERSION.*//) < /etc/SuSE-release )
|
||||
REV=$( (grep 'VERSION' | sed s/.*=\ //) < /etc/SuSE-release )
|
||||
elif [ -f /etc/mandrake-release ] ; then
|
||||
DistroBasedOn='mandrake'
|
||||
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
PSUEDONAME=$( (sed s/.*\(// | sed s/\)//) < /etc/mandrake-release )
|
||||
REV=$( (sed s/.*release\ // | sed s/\ .*//) < /etc/mandrake-release )
|
||||
elif [ -f /etc/debian_version ] ; then
|
||||
DistroBasedOn='debian'
|
||||
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
|
||||
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
|
||||
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
|
||||
DIST=$( (grep '^DISTRIB_ID' | awk -F= '{ print $2 }') < /etc/lsb-release )
|
||||
PSUEDONAME=$( (grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }') < /etc/lsb-release )
|
||||
REV=$( (grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }') < /etc/lsb-release)
|
||||
fi
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
|
||||
DIST="${DIST}[$( (tr "\n" ' ' | sed s/VERSION.*//) < /etc/UnitedLinux-release )]"
|
||||
fi
|
||||
OS=`lowercase $OS`
|
||||
DistroBasedOn=`lowercase $DistroBasedOn`
|
||||
OS=$(lowercase $OS)
|
||||
DistroBasedOn=$(lowercase $DistroBasedOn)
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -120,42 +125,45 @@ install(){
|
||||
echo " REV: $REV"
|
||||
echo " KERNEL: $KERNEL"
|
||||
echo " MACH: $MACH"
|
||||
echo " OSSTR: $OSSTR"
|
||||
|
||||
|
||||
|
||||
if [[ "'$*'" =~ appimage ]] ; then
|
||||
if [ -f $SCRIPTFOLDER/appimage.sh ]; then
|
||||
if [ -f "$SCRIPTFOLDER/appimage.sh" ]; then
|
||||
#Script files were copied local - use them
|
||||
. $SCRIPTFOLDER/appimage.sh
|
||||
# shellcheck source=/dev/null
|
||||
. "$SCRIPTFOLDER/appimage.sh"
|
||||
else
|
||||
#Script files are not local - pull from remote
|
||||
echo "Could not find \"appimage.sh\" next to this script..."
|
||||
echo "Pulling and executing it from \"$gitreposcriptroot/appimage.sh\""
|
||||
if [ -n "$(command -v curl)" ]; then
|
||||
echo "found and using curl"
|
||||
bash <(curl -s $gitreposcriptroot/appimage.sh) $@
|
||||
bash <(curl -s $gitreposcriptroot/appimage.sh) "$@"
|
||||
elif [ -n "$(command -v wget)" ]; then
|
||||
echo "found and using wget"
|
||||
bash <(wget -qO- $gitreposcriptroot/appimage.sh) $@
|
||||
bash <(wget -qO- $gitreposcriptroot/appimage.sh) "$@"
|
||||
else
|
||||
echo "Could not find curl or wget, install one of these or manually download \"$gitreposcriptroot/appimage.sh\""
|
||||
fi
|
||||
fi
|
||||
elif [ "$DistroBasedOn" == "redhat" ] || [ "$DistroBasedOn" == "debian" ] || [ "$DistroBasedOn" == "osx" ] || [ "$DistroBasedOn" == "suse" ] || [ "$DistroBasedOn" == "amazonlinux" ]; then
|
||||
echo "Configuring PowerShell Core Environment for: $DistroBasedOn $DIST $REV"
|
||||
if [ -f $SCRIPTFOLDER/installpsh-$DistroBasedOn.sh ]; then
|
||||
if [ -f "$SCRIPTFOLDER/installpsh-$DistroBasedOn.sh" ]; then
|
||||
#Script files were copied local - use them
|
||||
. $SCRIPTFOLDER/installpsh-$DistroBasedOn.sh
|
||||
# shellcheck source=/dev/null
|
||||
. "$SCRIPTFOLDER/installpsh-$DistroBasedOn.sh"
|
||||
else
|
||||
#Script files are not local - pull from remote
|
||||
echo "Could not find \"installpsh-$DistroBasedOn.sh\" next to this script..."
|
||||
echo "Pulling and executing it from \"$gitreposcriptroot/installpsh-$DistroBasedOn.sh\""
|
||||
if [ -n "$(command -v curl)" ]; then
|
||||
echo "found and using curl"
|
||||
bash <(curl -s $gitreposcriptroot/installpsh-$DistroBasedOn.sh) $@
|
||||
bash <(curl -s $gitreposcriptroot/installpsh-"$DistroBasedOn".sh) "$@"
|
||||
elif [ -n "$(command -v wget)" ]; then
|
||||
echo "found and using wget"
|
||||
bash <(wget -qO- $gitreposcriptroot/installpsh-$DistroBasedOn.sh) $@
|
||||
bash <(wget -qO- $gitreposcriptroot/installpsh-"$DistroBasedOn".sh) "$@"
|
||||
else
|
||||
echo "Could not find curl or wget, install one of these or manually download \"$gitreposcriptroot/installpsh-$DistroBasedOn.sh\""
|
||||
fi
|
||||
@ -166,4 +174,4 @@ install(){
|
||||
}
|
||||
|
||||
# run the install function
|
||||
install;
|
||||
install "$@";
|
||||
|
@ -14,8 +14,10 @@
|
||||
#Completely automated install requires a root account or sudo with a password requirement
|
||||
|
||||
#Switches
|
||||
# -includeide - the script is being run headless, do not perform actions that require response from the console
|
||||
# -interactivetests - requires a human user in front of the machine - loads a script into the ide to test with F5 to ensure the IDE can run scripts
|
||||
# -includeide - ignored, as Amazon Linux does not have a desktop environment
|
||||
# -interactivetesting - ignored, as Amazon Linux does not have a desktop environment
|
||||
# -skip-sudo-check - use sudo without verifying its availability (hard to accurately do on some distros)
|
||||
# -preview - installs the latest preview release of PowerShell core side-by-side with any existing production releases
|
||||
|
||||
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
|
||||
|
||||
@ -30,7 +32,6 @@ pwshlink=/usr/bin/pwsh
|
||||
|
||||
echo
|
||||
echo "*** PowerShell Core Development Environment Installer $VERSION for $thisinstallerdistro"
|
||||
echo "*** Current PowerShell Core Version: $currentpshversion"
|
||||
echo "*** Original script is at: $gitreposcriptroot/$gitscriptname"
|
||||
echo
|
||||
echo "*** Arguments used: $*"
|
||||
@ -43,82 +44,47 @@ trap '
|
||||
kill -s INT "$$"
|
||||
' INT
|
||||
|
||||
#Verify The Installer Choice (for direct runs of this script)
|
||||
lowercase(){
|
||||
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
echo "$1" | tr "[:upper:]" "[:lower:]"
|
||||
}
|
||||
|
||||
OS=`lowercase \`uname\``
|
||||
KERNEL=`uname -r`
|
||||
MACH=`uname -m`
|
||||
|
||||
OS=$(lowercase "$(uname)")
|
||||
if [ "${OS}" == "windowsnt" ]; then
|
||||
OS=windows
|
||||
DistroBasedOn=windows
|
||||
SCRIPTFOLDER=$(dirname $(readlink -f $0))
|
||||
elif [ "${OS}" == "darwin" ]; then
|
||||
OS=osx
|
||||
DistroBasedOn=osx
|
||||
# readlink doesn't work the same on macOS
|
||||
SCRIPTFOLDER=$(dirname $0)
|
||||
else
|
||||
SCRIPTFOLDER=$(dirname $(readlink -f $0))
|
||||
OS=`uname`
|
||||
OS=$(uname)
|
||||
if [ "${OS}" == "SunOS" ] ; then
|
||||
OS=solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
DistroBasedOn=sunos
|
||||
elif [ "${OS}" == "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
DistroBasedOn=aix
|
||||
elif [ "${OS}" == "Linux" ] ; then
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
DistroBasedOn='redhat'
|
||||
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
|
||||
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
elif [ -f /etc/system-release ] ; then
|
||||
DIST=`cat /etc/system-release |sed s/\ release.*//`
|
||||
PSUEDONAME=`cat /etc/system-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/system-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
if [[ $DIST == *"Amazon Linux"* ]] ; then
|
||||
DistroBasedOn='amazonlinux'
|
||||
else
|
||||
DistroBasedOn='redhat'
|
||||
fi
|
||||
elif [ -f /etc/SuSE-release ] ; then
|
||||
DistroBasedOn='suse'
|
||||
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
|
||||
REV=`cat /etc/SuSE-release | grep 'VERSION' | sed s/.*=\ //`
|
||||
elif [ -f /etc/mandrake-release ] ; then
|
||||
DistroBasedOn='mandrake'
|
||||
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
elif [ -f /etc/debian_version ] ; then
|
||||
DistroBasedOn='debian'
|
||||
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
|
||||
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
|
||||
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
|
||||
fi
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
|
||||
DIST="${DIST}[$( (tr "\n" ' ' | sed s/VERSION.*//) < /etc/UnitedLinux-release )]"
|
||||
DistroBasedOn=unitedlinux
|
||||
fi
|
||||
OS=`lowercase $OS`
|
||||
DistroBasedOn=`lowercase $DistroBasedOn`
|
||||
readonly OS
|
||||
readonly DIST
|
||||
readonly DistroBasedOn
|
||||
readonly PSUEDONAME
|
||||
readonly REV
|
||||
readonly KERNEL
|
||||
readonly MACH
|
||||
OS=$(lowercase "$OS")
|
||||
DistroBasedOn=$(lowercase "$DistroBasedOn")
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ "$DistroBasedOn" != "$thisinstallerdistro" ]; then
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreporoot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 0
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreposcriptroot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Check requirements and prerequisites
|
||||
@ -130,7 +96,7 @@ if [[ "${CI}" == "true" ]]; then
|
||||
fi
|
||||
|
||||
SUDO=''
|
||||
if (( $EUID != 0 )); then
|
||||
if (( EUID != 0 )); then
|
||||
#Check that sudo is available
|
||||
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
|
||||
SUDO='sudo'
|
||||
@ -167,7 +133,7 @@ echo "ATTENTION: As of version 1.2.0 this script no longer uses pre-releases unl
|
||||
if [[ "'$*'" =~ preview ]] ; then
|
||||
echo
|
||||
echo "-preview was used, the latest preview release will be installed (side-by-side with your production release)"
|
||||
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`
|
||||
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)
|
||||
pwshlink=/usr/bin/pwsh-preview
|
||||
else
|
||||
echo "Finding the latest production release"
|
||||
@ -190,14 +156,14 @@ fi
|
||||
|
||||
echo "Installing PowerShell to /opt/microsoft/powershell/$release in overwrite mode"
|
||||
## Create the target folder where powershell will be placed
|
||||
$SUDO mkdir -p /opt/microsoft/powershell/$release
|
||||
$SUDO mkdir -p "/opt/microsoft/powershell/$release"
|
||||
## Expand powershell to the target folder
|
||||
$SUDO tar zxf $package -C /opt/microsoft/powershell/$release
|
||||
$SUDO tar zxf "$package" -C "/opt/microsoft/powershell/$release"
|
||||
|
||||
## Change the mode of 'pwsh' to 'rwxr-xr-x' to allow execution
|
||||
$SUDO chmod 755 /opt/microsoft/powershell/$release/pwsh
|
||||
$SUDO chmod 755 "/opt/microsoft/powershell/$release/pwsh"
|
||||
## Create the symbolic link that points to powershell
|
||||
$SUDO ln -sfn /opt/microsoft/powershell/$release/pwsh $pwshlink
|
||||
$SUDO ln -sfn "/opt/microsoft/powershell/$release/pwsh" $pwshlink
|
||||
|
||||
## Add the symbolic link path to /etc/shells
|
||||
if [ ! -f /etc/shells ] ; then
|
||||
@ -207,8 +173,9 @@ else
|
||||
fi
|
||||
|
||||
## Remove the downloaded package file
|
||||
rm -f $package
|
||||
rm -f "$package"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
|
||||
Run `"pwsh`" to start a PowerShell session."'
|
||||
|
||||
|
@ -12,9 +12,10 @@
|
||||
#Completely automated install requires a root account or sudo with a password requirement
|
||||
|
||||
#Switches
|
||||
# -includeide - the script is being run headless, do not perform actions that require response from the console
|
||||
# -interactivetests - requires a human user in front of the machine - loads a script into the ide to test with F5 to ensure the IDE can run scripts
|
||||
# -skip-sudo-check - skips the check that the user has permission to use sudo. This is required to run in the VSTS Hosted Linux Preview.
|
||||
# -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 its availability (hard to accurately do on some distros)
|
||||
# -preview - installs the latest preview release of PowerShell core side-by-side with any existing production releases
|
||||
|
||||
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
|
||||
|
||||
@ -28,17 +29,10 @@ powershellpackageid=powershell
|
||||
|
||||
echo ;
|
||||
echo "*** PowerShell Core Development Environment Installer $VERSION for $thisinstallerdistro"
|
||||
echo "*** Current PowerShell Core Version: $currentpshversion"
|
||||
echo "*** Original script is at: $gitreposcriptroot/$gitscriptname"
|
||||
echo
|
||||
echo "*** Arguments used: $*"
|
||||
|
||||
#Verify The Installer Choice (for direct runs of this script)
|
||||
lowercase(){
|
||||
#echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
echo "$1" | tr [A-Z] [a-z]
|
||||
}
|
||||
|
||||
# Let's quit on interrupt of subcommands
|
||||
trap '
|
||||
trap - INT # restore default INT handler
|
||||
@ -46,6 +40,12 @@ trap '
|
||||
kill -s INT "$$"
|
||||
' INT
|
||||
|
||||
#Verify The Installer Choice (for direct runs of this script)
|
||||
lowercase(){
|
||||
echo "$1" | tr "[:upper:]" "[:lower:]"
|
||||
}
|
||||
|
||||
OS=$(lowercase "$(uname)")
|
||||
if [ "${OS}" == "windowsnt" ]; then
|
||||
OS=windows
|
||||
DistroBasedOn=windows
|
||||
@ -53,14 +53,11 @@ elif [ "${OS}" == "darwin" ]; then
|
||||
OS=osx
|
||||
DistroBasedOn=osx
|
||||
else
|
||||
OS=`uname`
|
||||
OS=$(uname)
|
||||
if [ "${OS}" == "SunOS" ] ; then
|
||||
OS=solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
DistroBasedOn=sunos
|
||||
elif [ "${OS}" == "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
DistroBasedOn=aix
|
||||
elif [ "${OS}" == "Linux" ] ; then
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
@ -73,17 +70,17 @@ else
|
||||
DistroBasedOn='debian'
|
||||
fi
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
|
||||
DIST="${DIST}[$( (tr "\n" ' ' | sed s/VERSION.*//) < /etc/UnitedLinux-release )]"
|
||||
DistroBasedOn=unitedlinux
|
||||
fi
|
||||
OS=`lowercase $OS`
|
||||
DistroBasedOn=`lowercase $DistroBasedOn`
|
||||
OS=$(lowercase "$OS")
|
||||
DistroBasedOn=$(lowercase "$DistroBasedOn")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$DistroBasedOn" != "$thisinstallerdistro" ]; then
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreporoot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 0
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreposcriptroot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Check requirements and prerequisites
|
||||
@ -95,7 +92,7 @@ if [[ "${CI}" == "true" ]]; then
|
||||
fi
|
||||
|
||||
SUDO=''
|
||||
if (( $EUID != 0 )); then
|
||||
if (( EUID != 0 )); then
|
||||
#Check that sudo is available
|
||||
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
|
||||
SUDO='sudo'
|
||||
@ -106,8 +103,9 @@ if (( $EUID != 0 )); then
|
||||
fi
|
||||
|
||||
#Collect any variation details if required for this distro
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/lsb-release
|
||||
DISTRIB_ID=`lowercase $DISTRIB_ID`
|
||||
DISTRIB_ID=$(lowercase "$DISTRIB_ID")
|
||||
#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:
|
||||
@ -129,7 +127,7 @@ if [[ "'$*'" =~ preview ]] ; then
|
||||
powershellpackageid=powershell-preview
|
||||
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`
|
||||
currentversion=$(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..."
|
||||
echo "*** Setting up PowerShell Core repo..."
|
||||
@ -199,6 +197,7 @@ $SUDO apt-get update
|
||||
# Install PowerShell
|
||||
$SUDO apt-get install -y ${powershellpackageid}
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
|
||||
Run `"pwsh`" to start a PowerShell session."'
|
||||
|
||||
@ -231,6 +230,6 @@ fi
|
||||
|
||||
if [[ "$repobased" == true ]] ; then
|
||||
echo
|
||||
echo "*** NOTE: Run your regular package manager update cycle to update PowerShell Core\n"
|
||||
echo "*** NOTE: Run your regular package manager update cycle to update PowerShell Core"
|
||||
fi
|
||||
echo "*** Install Complete"
|
||||
|
@ -12,8 +12,9 @@
|
||||
#Completely automated install requires a root account or sudo with a password requirement
|
||||
|
||||
#Switches
|
||||
# -includeide - the script is being run headless, do not perform actions that require response from the console
|
||||
# -interactivetests - requires a human user in front of the machine - loads a script into the ide to test with F5 to ensure the IDE can run scripts
|
||||
# -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)
|
||||
# -preview - installs the latest preview release of PowerShell core side-by-side with any existing production releases
|
||||
|
||||
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
|
||||
|
||||
@ -27,7 +28,6 @@ gitscriptname="installpsh-osx.sh"
|
||||
powershellpackageid=powershell
|
||||
|
||||
echo "*** PowerShell Core Development Environment Installer $VERSION for $thisinstallerdistro"
|
||||
echo "*** Current PowerShell Core Version: $currentpshversion"
|
||||
echo "*** Original script is at: $gitreposcriptroot/$gitscriptname"
|
||||
echo "*** Arguments used: $*"
|
||||
|
||||
@ -40,11 +40,10 @@ trap '
|
||||
|
||||
#Verify The Installer Choice (for direct runs of this script)
|
||||
lowercase(){
|
||||
echo "$1" | tr [A-Z] [a-z]
|
||||
echo "$1" | tr "[:upper:]" "[:lower:]"
|
||||
}
|
||||
|
||||
OS=`lowercase \`uname\``
|
||||
|
||||
OS=$(lowercase "$(uname)")
|
||||
if [ "${OS}" == "windowsnt" ]; then
|
||||
OS=windows
|
||||
DistroBasedOn=windows
|
||||
@ -52,14 +51,11 @@ elif [ "${OS}" == "darwin" ]; then
|
||||
OS=osx
|
||||
DistroBasedOn=osx
|
||||
else
|
||||
OS=`uname`
|
||||
OS=$(uname)
|
||||
if [ "${OS}" == "SunOS" ] ; then
|
||||
OS=solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
DistroBasedOn=sunos
|
||||
elif [ "${OS}" == "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
DistroBasedOn=aix
|
||||
elif [ "${OS}" == "Linux" ] ; then
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
@ -72,17 +68,17 @@ else
|
||||
DistroBasedOn='debian'
|
||||
fi
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
|
||||
DIST="${DIST}[$( (tr "\n" ' ' | sed s/VERSION.*//) < /etc/UnitedLinux-release )]"
|
||||
DistroBasedOn=unitedlinux
|
||||
fi
|
||||
OS=`lowercase $OS`
|
||||
DistroBasedOn=`lowercase $DistroBasedOn`
|
||||
OS=$(lowercase "$OS")
|
||||
DistroBasedOn=$(lowercase "$DistroBasedOn")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$DistroBasedOn" != "$thisinstallerdistro" ]; then
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreporoot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 0
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreposcriptroot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Check requirements and prerequisites
|
||||
@ -165,7 +161,7 @@ if [[ "'$*'" =~ includeide ]] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
|
||||
Run `"pwsh`" to start a PowerShell session."'
|
||||
|
||||
|
@ -12,9 +12,10 @@
|
||||
#Completely automated install requires a root account or sudo with a password requirement
|
||||
|
||||
#Switches
|
||||
# -includeide - the script is being run headless, do not perform actions that require response from the console
|
||||
# -interactivetests - requires a human user in front of the machine - loads a script into the ide to test with F5 to ensure the IDE can run scripts
|
||||
# -skip-sudo-check - skips the check that the user has permission to use sudo. This is required to run in the VSTS Hosted Linux Preview.
|
||||
# -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 its availability (this is required to run in the VSTS Hosted Linux Preview)
|
||||
# -preview - installs the latest preview release of PowerShell core side-by-side with any existing production releases
|
||||
|
||||
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
|
||||
|
||||
@ -29,7 +30,6 @@ powershellpackageid=powershell
|
||||
|
||||
echo
|
||||
echo "*** PowerShell Core Development Environment Installer $VERSION for $thisinstallerdistro"
|
||||
echo "*** Current PowerShell Core Version: $currentpshversion"
|
||||
echo "*** Original script is at: $gitreposcriptroot/$gitscriptname"
|
||||
echo
|
||||
echo "*** Arguments used: $* "
|
||||
@ -44,9 +44,10 @@ trap '
|
||||
|
||||
#Verify The Installer Choice (for direct runs of this script)
|
||||
lowercase(){
|
||||
#echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
echo "$1" | tr [A-Z] [a-z]
|
||||
echo "$1" | tr "[:upper:]" "[:lower:]"
|
||||
}
|
||||
|
||||
OS=$(lowercase "$(uname)")
|
||||
if [ "${OS}" == "windowsnt" ]; then
|
||||
OS=windows
|
||||
DistroBasedOn=windows
|
||||
@ -54,20 +55,15 @@ elif [ "${OS}" == "darwin" ]; then
|
||||
OS=osx
|
||||
DistroBasedOn=osx
|
||||
else
|
||||
OS=`uname`
|
||||
OS=$(uname)
|
||||
if [ "${OS}" == "SunOS" ] ; then
|
||||
OS=solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
DistroBasedOn=sunos
|
||||
elif [ "${OS}" == "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
DistroBasedOn=aix
|
||||
elif [ "${OS}" == "Linux" ] ; then
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
DistroBasedOn='redhat'
|
||||
elif [ -f /etc/system-release ] ; then
|
||||
DistroBasedOn='redhat'
|
||||
elif [ -f /etc/SuSE-release ] ; then
|
||||
DistroBasedOn='suse'
|
||||
elif [ -f /etc/mandrake-release ] ; then
|
||||
@ -76,17 +72,17 @@ else
|
||||
DistroBasedOn='debian'
|
||||
fi
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
|
||||
DIST="${DIST}[$( (tr "\n" ' ' | sed s/VERSION.*//) < /etc/UnitedLinux-release )]"
|
||||
DistroBasedOn=unitedlinux
|
||||
fi
|
||||
OS=`lowercase $OS`
|
||||
DistroBasedOn=`lowercase $DistroBasedOn`
|
||||
OS=$(lowercase "$OS")
|
||||
DistroBasedOn=$(lowercase "$DistroBasedOn")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$DistroBasedOn" != "$thisinstallerdistro" ]; then
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreporoot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 0
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreposcriptroot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Check requirements and prerequisites
|
||||
@ -98,7 +94,7 @@ if [[ "${CI}" == "true" ]]; then
|
||||
fi
|
||||
|
||||
SUDO=''
|
||||
if (( $EUID != 0 )); then
|
||||
if (( EUID != 0 )); then
|
||||
#Check that sudo is available
|
||||
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
|
||||
SUDO='sudo'
|
||||
@ -114,13 +110,13 @@ if [[ "'$*'" =~ preview ]] ; then
|
||||
powershellpackageid=powershell-preview
|
||||
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
|
||||
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 "*** Installing PowerShell Core for $DistroBasedOn..."
|
||||
if ! hash curl 2>/dev/null; then
|
||||
echo "curl not found, installing..."
|
||||
$SUDO yum install -y curl
|
||||
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`
|
||||
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: $release, repo version may differ slightly..."
|
||||
|
||||
@ -128,6 +124,7 @@ echo "*** Setting up PowerShell Core repo..."
|
||||
$SUDO curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo
|
||||
$SUDO yum install -y ${powershellpackageid}
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
|
||||
Run `"pwsh`" to start a PowerShell session."'
|
||||
|
||||
|
@ -12,9 +12,10 @@
|
||||
#Completely automated install requires a root account or sudo with a password requirement
|
||||
|
||||
#Switches
|
||||
# -includeide - the script is being run headless, do not perform actions that require response from the console
|
||||
# -interactivetests - requires a human user in front of the machine - loads a script into the ide to test with F5 to ensure the IDE can run scripts
|
||||
# -skip-sudo-check - skips the check that the user has permission to use sudo. This is required to run in the VSTS Hosted Linux Preview.
|
||||
# -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 its availability (this is required to run in the VSTS Hosted Linux Preview)
|
||||
# -preview - installs the latest preview release of PowerShell core side-by-side with any existing production releasesS
|
||||
|
||||
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
|
||||
|
||||
@ -25,12 +26,10 @@ gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
|
||||
thisinstallerdistro=suse
|
||||
repobased=false
|
||||
gitscriptname="installpsh-suse.psh"
|
||||
powershellpackageid=powershell
|
||||
pwshlink=/usr/bin/pwsh
|
||||
|
||||
echo
|
||||
echo "*** PowerShell Core Development Environment Installer $VERSION for $thisinstallerdistro"
|
||||
echo "*** Current PowerShell Core Version: $currentpshversion"
|
||||
echo "*** Original script is at: $gitreposcriptroot/$gitscriptname"
|
||||
echo
|
||||
echo "*** Arguments used: $*"
|
||||
@ -45,9 +44,10 @@ trap '
|
||||
|
||||
#Verify The Installer Choice (for direct runs of this script)
|
||||
lowercase(){
|
||||
#echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
echo "$1" | tr [A-Z] [a-z]
|
||||
echo "$1" | tr "[:upper:]" "[:lower:]"
|
||||
}
|
||||
|
||||
OS=$(lowercase "$(uname)")
|
||||
if [ "${OS}" == "windowsnt" ]; then
|
||||
OS=windows
|
||||
DistroBasedOn=windows
|
||||
@ -55,14 +55,11 @@ elif [ "${OS}" == "darwin" ]; then
|
||||
OS=osx
|
||||
DistroBasedOn=osx
|
||||
else
|
||||
OS=`uname`
|
||||
OS=$(uname)
|
||||
if [ "${OS}" == "SunOS" ] ; then
|
||||
OS=solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
DistroBasedOn=sunos
|
||||
elif [ "${OS}" == "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
DistroBasedOn=aix
|
||||
elif [ "${OS}" == "Linux" ] ; then
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
@ -75,17 +72,17 @@ else
|
||||
DistroBasedOn='debian'
|
||||
fi
|
||||
if [ -f /etc/UnitedLinux-release ] ; then
|
||||
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION//`]"
|
||||
DIST="${DIST}[$( (tr "\n" ' ' | sed s/VERSION.*//) < /etc/UnitedLinux-release )]"
|
||||
DistroBasedOn=unitedlinux
|
||||
fi
|
||||
OS=`lowercase $OS`
|
||||
DistroBasedOn=`lowercase $DistroBasedOn`
|
||||
OS=$(lowercase "$OS")
|
||||
DistroBasedOn=$(lowercase "$DistroBasedOn")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$DistroBasedOn" != "$thisinstallerdistro" ]; then
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreporoot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 0
|
||||
echo "*** This installer is only for $thisinstallerdistro and you are running $DistroBasedOn, please run \"$gitreposcriptroot\install-powershell.sh\" to see if your distro is supported AND to auto-select the appropriate installer if it is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Check requirements and prerequisites
|
||||
@ -97,7 +94,7 @@ if [[ "${CI}" == "true" ]]; then
|
||||
fi
|
||||
|
||||
SUDO=''
|
||||
if (( $EUID != 0 )); then
|
||||
if (( EUID != 0 )); then
|
||||
#Check that sudo is available
|
||||
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
|
||||
SUDO='sudo'
|
||||
@ -108,16 +105,17 @@ if (( $EUID != 0 )); then
|
||||
fi
|
||||
|
||||
#Collect any variation details if required for this distro
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/os-release
|
||||
MAJORREV=`echo $VERSION_ID | sed 's/\..*//'`
|
||||
MAJORREV=${VERSION_ID/\.*/}
|
||||
#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:
|
||||
if [[ $ID == 'opensuse' && $MAJORREV < 42 ]]; then
|
||||
if [[ $ID == 'opensuse' && $MAJORREV -lt 42 ]]; then
|
||||
echo "OpenSUSE $VERSION_ID is not supported!" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ $ID == 'sles' && $MAJORREV < 12 ]]; then
|
||||
if [[ $ID == 'sles' && $MAJORREV -lt 12 ]]; then
|
||||
echo "SLES $VERSION_ID is not supported!" >&2
|
||||
exit 2
|
||||
fi
|
||||
@ -146,12 +144,12 @@ echo "ATTENTION: As of version 1.2.0 this script no longer uses pre-releases unl
|
||||
if [[ "'$*'" =~ preview ]] ; then
|
||||
echo
|
||||
echo "-preview was used, the latest preview release will be installed (side-by-side with your production release)"
|
||||
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`
|
||||
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)
|
||||
pwshlink=/usr/bin/pwsh-preview
|
||||
else
|
||||
echo "Finding the latest 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
|
||||
fi
|
||||
#DIRECT DOWNLOAD
|
||||
package=powershell-${release}-linux-x64.tar.gz
|
||||
downloadurl=https://github.com/PowerShell/PowerShell/releases/download/v$release/$package
|
||||
@ -181,14 +179,14 @@ fi
|
||||
|
||||
echo "Installing PowerShell to /opt/microsoft/powershell/$release in overwrite mode"
|
||||
## Create the target folder where powershell will be placed
|
||||
$SUDO mkdir -p /opt/microsoft/powershell/$release
|
||||
$SUDO mkdir -p "/opt/microsoft/powershell/$release"
|
||||
## Expand powershell to the target folder
|
||||
$SUDO tar zxf $package -C /opt/microsoft/powershell/$release
|
||||
$SUDO tar zxf "$package" -C "/opt/microsoft/powershell/$release"
|
||||
|
||||
## Change the mode of 'pwsh' to 'rwxr-xr-x' to allow execution
|
||||
$SUDO chmod 755 /opt/microsoft/powershell/$release/pwsh
|
||||
$SUDO chmod 755 "/opt/microsoft/powershell/$release/pwsh"
|
||||
## Create the symbolic link that points to powershell
|
||||
$SUDO ln -sfn /opt/microsoft/powershell/$release/pwsh $pwshlink
|
||||
$SUDO ln -sfn "/opt/microsoft/powershell/$release/pwsh" $pwshlink
|
||||
|
||||
## Add the symbolic link path to /etc/shells
|
||||
if [ ! -f /etc/shells ] ; then
|
||||
@ -198,8 +196,9 @@ else
|
||||
fi
|
||||
|
||||
## Remove the downloaded package file
|
||||
rm -f $package
|
||||
rm -f "$package"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
|
||||
Run `"pwsh`" to start a PowerShell session."'
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
.DESCRIPTION
|
||||
Defaults to machine scope and leaving the last sorted path alone.
|
||||
Does not touch path if there is nothing to clean.
|
||||
Emits one simple log line about it's actions for each scope.
|
||||
Emits one simple log line about its actions for each scope.
|
||||
|
||||
Also accessible in the powershell-core Chocolatey package by using -params '"/CleanUpSystemPath"'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user