diff --git a/Dockerfile b/Dockerfile index 7d2af0b..ee60171 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN \ git config --system credential.helper store && \ echo 'source /usr/share/bash-completion/completions/git' >> /etc/bash.bashrc -ADD install/install* /usr/bin/ +ADD install-devruntime /usr/bin/ RUN \ - chmod +x /usr/bin/install-* && \ - echo "echo \"Install required dev runtimes with the 'install-*' scripts.\"" >> /etc/bash.bashrc + chmod +x /usr/bin/install-devruntime && \ + echo "echo \"Use 'install-devruntime' to install missing runtimes like dotnet or NodeJs.\"" >> /etc/bash.bashrc diff --git a/finalize-codeserver.sh b/finalize-codeserver.sh deleted file mode 100644 index 207c2ac..0000000 --- a/finalize-codeserver.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -echo "**** install dev runtimes ****" -curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - -sudo apt-get install --no-install-recommends -y \ - nodejs \ - golang-go - -echo "**** clean up ****" -sudo apt-get clean -sudo rm -rf \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/tmp/* diff --git a/install-devruntime b/install-devruntime new file mode 100755 index 0000000..58b2a9d --- /dev/null +++ b/install-devruntime @@ -0,0 +1,133 @@ +#!/bin/bash + +set -e + +function showHelp() { + cat <&2 + else + echo -e "\e[31mInstall-DevRuntime\e[0m: $1" 1>&2 + fi +} + +function instDotNet() { + say "Downloading latest install script..." "dotnet" + curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh + chmod +x /tmp/dotnet-install.sh + + say "Installing latest .NET Core LTS release..." "dotnet" + /tmp/dotnet-install.sh --channel LTS + echo 'export PATH=$PATH:/config/.dotnet' | sudo tee -a /etc/bash.bashrc > /dev/null + + say "dotnet done. " "dotnet" +} + +function instGoLang() { + if [[ -z "$1" ]]; then + GOVERSION="1.19.3" + else + GOVERSION="$1" + fi + + say "Downloading golang ($GOVERSION)..." "GoLang" + curl -fsSL "https://go.dev/dl/go$GOVERSION.linux-amd64.tar.gz" -o /tmp/golang.tar.gz + say "Installing golang ($GOVERSION)...." "GoLang" + sudo rm -rf /usr/local/go + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/bash.bashrc > /dev/null + say "Cleaning up..." "GoLang" + rm -f /tmp/golang.tar.gz + say "done." "GoLang" + say "Please reload bash profile to finalize." "GoLang" +} + +function instNodeJs() { + say "Adding nodesource package source (NodeJS LTS)..." "NodeJs" + curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - + say "Updating package lists and installing NodeJS LTS..." "NodeJs" + sudo apt-get install --no-install-recommends -y \ + nodejs + + say "Cleaning up..." "NodeJs" + sudo apt-get clean + sudo rm -rf \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/* + + say "done." "NodeJs" +} + +function instPwsh() { + say "Installing PowerShell requirements..." "PowerShell" + sudo apt-get install --no-install-recommends -y \ + apt-transport-https \ + software-properties-common + + say "Adding powershell package sources..." "PowerShell" + # Download the Microsoft repository GPG keys + curl -fsSL "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" -o /tmp/packages-microsoft-prod.deb + # Register the Microsoft repository GPG keys + sudo dpkg -i /tmp/packages-microsoft-prod.deb + # Update the list of packages after we added packages.microsoft.com + sudo apt-get update + + say "Installing PowerShell..." "PowerShell" + # Install PowerShell + sudo apt-get install --no-install-recommends -y powershell + + echo "done." "PowerShell" +} + +function main() { + if [[ "$#" == "0" ]]; then + showHelp + exit 0 + fi + + for i in $@; do + if [[ "$1" == "-h" ]]; then + showHelp + exit 0 + elif [[ "$i" == "dotnet" ]]; then + instDotNet + elif [[ "$i" == "golang" ]]; then + instGoLang + elif [[ "$i" == "nodejs" ]]; then + instNodeJs + elif [[ "$i" == "powershell" ]]; then + instPwsh + else + sayE "Unknown parameter value given!($i)." + showHelp + exit 1 + fi + done +} + +main $@ diff --git a/install/install-dotnet.sh b/install/install-dotnet.sh deleted file mode 100644 index 4a3c3e9..0000000 --- a/install/install-dotnet.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -e - -echo "**** downloading latest install script ****" -curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh -chmod +x /tmp/dotnet-install.sh - -echo "**** installing latest .NET Core LTS release ****" -/tmp/dotnet-install.sh --channel LTS -echo 'export PATH=$PATH:/config/.dotnet' | sudo tee -a /etc/bash.bashrc > /dev/null - -echo "**** done. ****" diff --git a/install/install-golang.sh b/install/install-golang.sh deleted file mode 100644 index f761b77..0000000 --- a/install/install-golang.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -set -e -if [[ -z "$1" ]] -then - GOVERSION="1.19.3" -else - GOVERSION="$1" -fi - -echo "**** downloading golang ($GOVERSION)****" -curl -fsSL "https://go.dev/dl/go$GOVERSION.linux-amd64.tar.gz" -o /tmp/golang.tar.gz -echo "**** installing golang ($GOVERSION)****" -sudo rm -rf /usr/local/go -sudo tar -C /usr/local -xzf /tmp/golang.tar.gz -echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/bash.bashrc > /dev/null -echo "**** cleaning up ****" -rm -f /tmp/golang.tar.gz -echo "**** done. ****" -echo "**** please reload bashprofile to finalize ****" diff --git a/install/install-nodejs.sh b/install/install-nodejs.sh deleted file mode 100644 index 5b659df..0000000 --- a/install/install-nodejs.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -set -e - -echo "**** adding nodesource package source (NodeJS LTS) ****" -curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - -echo "**** updating package lists + installing NodeJS LTS ****" -sudo apt-get install --no-install-recommends -y \ - nodejs - -echo "**** cleaning up ****" -sudo apt-get clean -sudo rm -rf \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/tmp/* - -echo "**** done. ****" diff --git a/install/install-powershell.sh b/install/install-powershell.sh deleted file mode 100644 index a89ca41..0000000 --- a/install/install-powershell.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -echo "**** installing powershell requirements ****" -sudo apt-get install --no-install-recommends -y \ - apt-transport-https \ - software-properties-common - -echo "**** adding powershell package sources ****" -# Download the Microsoft repository GPG keys -curl -fsSL "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" -o /tmp/packages-microsoft-prod.deb -# Register the Microsoft repository GPG keys -sudo dpkg -i /tmp/packages-microsoft-prod.deb -# Update the list of packages after we added packages.microsoft.com -sudo apt-get update -echo "**** installing powershell ****" -# Install PowerShell -sudo apt-get install --no-install-recommends -y powershell -echo "**** done. ****" -# Start PowerShell -#pwsh