From c49ff7d35943ea4f38835bcbcd6432b22a7f4965 Mon Sep 17 00:00:00 2001 From: achi Date: Wed, 5 Jun 2024 12:11:35 +1000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20powershell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install-powershell.sh | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 install-powershell.sh diff --git a/install-powershell.sh b/install-powershell.sh new file mode 100644 index 0000000..ed22b36 --- /dev/null +++ b/install-powershell.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +POWERSHELL_VERSION="7.4.2" + +# Предварительные требования + +apt-get update +apt-get install -y wget apt-transport-https software-properties-common + +source /etc/os-release + +function Install-Ubuntu { + # 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 не установлен" + + if [ "$ID" = "ubuntu" ]; then + Install-Ubuntu + elif [ $"ID" = "redos" ]; then + Install-Rhel + else + echo "Установите powershell для вашей ОС $NAME, чтобы воспользоваться скриптом установки ЛЭРС" + fi +else + echo "Powershell установлен" +fi