2020-08-19 03:37:16 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#-------------------------------------------------------------------------------------------------------------
|
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
|
|
|
#-------------------------------------------------------------------------------------------------------------
|
2020-09-21 20:16:31 +03:00
|
|
|
#
|
2021-05-25 16:51:04 +03:00
|
|
|
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/powershell.md
|
2021-03-09 21:34:45 +03:00
|
|
|
# Maintainer: The VS Code and Codespaces Teams
|
2020-09-21 20:16:31 +03:00
|
|
|
#
|
2020-08-19 03:37:16 +03:00
|
|
|
# Syntax: ./powershell-debian.sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
2020-09-18 20:40:56 +03:00
|
|
|
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
|
2020-08-19 03:37:16 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
2021-07-01 03:13:59 +03:00
|
|
|
# Install curl, apt-transport-https, or gpg if missing
|
|
|
|
if ! dpkg -s apt-transport-https curl ca-certificates gnupg2 > /dev/null 2>&1 || ! type gpg > /dev/null 2>&1; then
|
2020-08-19 03:37:16 +03:00
|
|
|
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
|
|
|
|
apt-get update
|
|
|
|
fi
|
2021-07-01 03:13:59 +03:00
|
|
|
apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates gnupg2
|
2020-08-19 03:37:16 +03:00
|
|
|
fi
|
|
|
|
|
2021-07-01 03:13:59 +03:00
|
|
|
ARCHITECTURE="$(uname -m)"
|
|
|
|
if [ "${ARCHITECTURE}" != "amd64" ] && [ "${ARCHITECTURE}" != "x86_64" ]; then
|
|
|
|
echo "(!) Architecture $ARCHITECTURE unsupported"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Source /etc/os-release to get OS info
|
|
|
|
. /etc/os-release
|
|
|
|
# Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install
|
|
|
|
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
|
|
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list
|
2020-08-19 03:37:16 +03:00
|
|
|
apt-get update -yq
|
|
|
|
apt-get install -yq powershell
|
|
|
|
echo "Done!"
|