Installer/install-powershell.sh

46 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
POWERSHELL_VERSION="7.4.2"
# Предварительные требования
source /etc/os-release
function Install-Ubuntu {
apt-get update
apt-get install -y wget apt-transport-https software-properties-common
# Download the PowerShell package file
wget https://github.com/PowerShell/PowerShell/releases/download/v${POWERSHELL_VERSION}/powershell_${POWERSHELL_VERSION}-1.deb_amd64.deb
###################################
# Install the PowerShell package
dpkg -i powershell_${POWERSHELL_VERSION}-1.deb_amd64.deb
# Resolve missing dependencies and finish the install (if necessary)
apt-get install -f
# Delete the downloaded package file
rm powershell_${POWERSHELL_VERSION}-1.deb_amd64.deb
}
function Install-Rhel {
dnf install https://github.com/PowerShell/PowerShell/releases/download/v${POWERSHELL_VERSION}/powershell-${POWERSHELL_VERSION}-1.rh.x86_64.rpm
}
if ! command -v pwsh &> /dev/null
then
echo "Powershell не установлен"
echo "Операционная система: $ID"
if [ "$ID" = "ubuntu" ]; then
Install-Ubuntu
elif [ "$ID" = "redos" ]; then
Install-Rhel
else
echo "Установите powershell для вашей $NAME, чтобы воспользоваться скриптом установки ЛЭРС"
fi
else
echo "Powershell установлен"
fi