-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into releases/v1
- Loading branch information
Showing
10 changed files
with
7,296 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/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. | ||
#------------------------------------------------------------------------------------------------------------- | ||
# | ||
# ** This script is community supported ** | ||
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/fish.md | ||
# Maintainer: @andreiborisov | ||
# | ||
# Syntax: ./fish-debian.sh [whether to install Fisher] [non-root user] | ||
|
||
INSTALL_FISHER=${1:-"true"} | ||
USERNAME=${2:-"automatic"} | ||
|
||
set -e | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
# Determine the appropriate non-root user | ||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then | ||
USERNAME="" | ||
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") | ||
for CURRENT_USER in ${POSSIBLE_USERS[@]}; do | ||
if id -u ${CURRENT_USER} > /dev/null 2>&1; then | ||
USERNAME=${CURRENT_USER} | ||
break | ||
fi | ||
done | ||
if [ "${USERNAME}" = "" ]; then | ||
USERNAME=root | ||
fi | ||
elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then | ||
USERNAME=root | ||
fi | ||
|
||
# Function to run apt-get if needed | ||
apt_get_update_if_needed() | ||
{ | ||
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then | ||
echo "Running apt-get update..." | ||
apt-get update | ||
else | ||
echo "Skipping apt-get update." | ||
fi | ||
} | ||
|
||
# Checks if packages are installed and installs them if not | ||
check_packages() { | ||
if ! dpkg -s "$@" > /dev/null 2>&1; then | ||
apt_get_update_if_needed | ||
apt-get -y install --no-install-recommends "$@" | ||
fi | ||
} | ||
|
||
check_packages curl ca-certificates gnupg2 apt-transport-https | ||
|
||
# Install fish shell | ||
echo "Installing fish shell..." | ||
if grep -q 'Ubuntu' < /etc/os-release; then | ||
apt-get -y install --no-install-recommends software-properties-common | ||
apt-add-repository -y ppa:fish-shell/release-3 | ||
apt-get update | ||
apt-get -y install --no-install-recommends fish | ||
apt-get autoremove -y | ||
elif grep -q 'Debian' < /etc/os-release; then | ||
if grep -q 'stretch' < /etc/os-release; then | ||
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_9.0/ /' | tee /etc/apt/sources.list.d/shells:fish.list | ||
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_9.0/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish.gpg > /dev/null | ||
elif grep -q 'buster' < /etc/os-release; then | ||
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_10/ /' | tee /etc/apt/sources.list.d/shells:fish.list | ||
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_10/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish.gpg > /dev/null | ||
elif grep -q 'bullseye' < /etc/os-release; then | ||
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_11/ /' | tee /etc/apt/sources.list.d/shells:fish.list | ||
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_11/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish.gpg > /dev/null | ||
fi | ||
apt update | ||
apt install -y fish | ||
apt autoremove -y | ||
fi | ||
|
||
# Install Fisher | ||
if [ "${INSTALL_FISHER}" = "true" ]; then | ||
echo "Installing Fisher..." | ||
fish -c 'curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher' | ||
if [ "${USERNAME}" != "root" ]; then | ||
sudo -u $USERNAME fish -c 'curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher' | ||
fi | ||
fi | ||
|
||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.