-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
47e0763
commit 0d89a96
Showing
9 changed files
with
360 additions
and
0 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,28 @@ | ||
:toc: | ||
toc::[] | ||
|
||
= docker | ||
|
||
The `docker` commandlet allows to install https://www.docker.com/[docker]. This command is implemented to currently work on Windows. Other OS are not supported yet. | ||
|
||
.Usage of `devon docker` | ||
|
||
On Windows | ||
|
||
* Checks whether https://docs.microsoft.com/en-us/windows/wsl/install-win10[Windows Subsystem for Linux(WSL)] has been enabled and any linux distribution has been installed. | ||
|
||
* If yes, checks whether Docker has already been installed either on Windows or on WSL. | ||
|
||
* If yes, program quits since Docker is already available. | ||
|
||
* If not, this commandlet will install Docker on WSL | ||
|
||
The arguments (`devon docker «args»`) are explained by the following table: | ||
|
||
.Usage of `devon docker` | ||
[options="header"] | ||
|======================= | ||
|*Argument(s)* |*Meaning* | ||
|`setup` |setup Docker (install and verify) as per above flow. | ||
|`«args»` |call docker with the specified arguments. Call `docker help` for details or use docker directly as preferred." (`«args»`) | ||
|======================= |
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,30 @@ | ||
:toc: | ||
toc::[] | ||
|
||
= kubernetes | ||
|
||
The `kubernetes` commandlet allows to install https://kubernetes.io/[kubernetes]. This command is implemented to currently work on Windows. Other OS are not supported yet. | ||
|
||
.Usage of `devon kubernetes` | ||
|
||
On Windows | ||
|
||
* Checks whether https://docs.microsoft.com/en-us/windows/wsl/install-win10[Windows Subsystem for Linux(WSL)] has been enabled and any linux distribution has been installed. | ||
|
||
* If yes, checks whether Kubernetes has already been installed either on Windows or on WSL. | ||
|
||
* If yes, program quits since Kubernetes is already available. | ||
|
||
* If not, this will install Kubernetes on WSL along with https://k3d.io[K3D] | ||
|
||
* As part of the setup, K3D will create a cluster with a single node with a default name as "devonfw-cluster" | ||
|
||
The arguments (`devon kubernetes «args»`) are explained by the following table: | ||
|
||
.Usage of `devon kubernetes` | ||
[options="header"] | ||
|======================= | ||
|*Argument(s)* |*Meaning* | ||
|`setup` |setup Kubernetes (install and verify) as per above flow. | ||
|`«args»` |call kubernetes(kubectl) with the specified arguments. Call `kubectl help` for details or use kubectl directly as preferred. (`«args»`) | ||
|======================= |
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,107 @@ | ||
#!/usr/bin/env bash | ||
|
||
# autocompletion list | ||
if [ "${1}" = "shortlist" ] | ||
then | ||
if [ -z "${2}" ] | ||
then | ||
echo "setup help" | ||
fi | ||
exit | ||
fi | ||
|
||
if [ -n "${DEVON_IDE_TRACE}" ]; then set -vx; fi | ||
# shellcheck source=scripts/functions | ||
source "$(dirname "${0}")"/../functions | ||
|
||
# $1: optional setup | ||
function doSetup() { | ||
if doIsDockerInstalled | ||
then | ||
doEcho "docker is already installed at $(command -v docker)" | ||
exit 0 | ||
else | ||
if doIsBatch | ||
then | ||
doFail "Interactive installation is required, cannot proceed in batch mode. Please rerun without batch option." | ||
fi | ||
#Start setup | ||
if doIsWindows | ||
then | ||
if doIsWSLEnabled | ||
then | ||
# Verify if docker is installed on Windows Subsystem for Linux(WSL) | ||
docker_win_version=$(wsl docker version 2>/dev/null) | ||
if [[ $docker_win_version == *"Client:"* ]];then | ||
if [ "${1}" = "setup" ] | ||
then | ||
doEcho Docker already installed on WSL. | ||
wsl docker version | ||
fi | ||
if [[ $docker_win_version != *"Server:"* ]];then | ||
doEcho Please start Docker engine on WSL. | ||
fi | ||
else | ||
doEcho Docker not installed on WSL. | ||
# Install Docker on WSL | ||
wsl bash ../scripts/setup-docker | ||
fi | ||
else | ||
return 255 | ||
fi | ||
else | ||
doEcho "Sorry, docker-installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request." | ||
exit 0 | ||
fi | ||
fi | ||
} | ||
|
||
# Call Docker with specified arguments. | ||
function doRun() { | ||
if doSetup | ||
then | ||
# Run docker command if installed. | ||
if doIsDockerInstalled | ||
then | ||
doEcho "Running: docker ${*}" | ||
docker "${@}" | ||
# Run docker command on Windows WSL if installed. | ||
elif doIsWSLEnabled | ||
then | ||
if doIsDockerInstalledOnWSL | ||
then | ||
doEcho "Running: docker ${*} on WSL." | ||
wsl docker "${@}" | ||
fi | ||
fi | ||
fi | ||
} | ||
|
||
# OS independent check if docker is installed. | ||
function doIsDockerInstalled() { | ||
if command -v docker &> /dev/null | ||
then | ||
echo "docker is already installed at $(command -v docker)" | ||
return | ||
else | ||
return 255 | ||
fi | ||
} | ||
|
||
# CLI | ||
case ${1} in | ||
"help" | "-h") | ||
echo "Setup docker." | ||
echo | ||
echo "Arguments:" | ||
echo " setup setup docker on Windows WSL." | ||
echo " «args» call docker with the specified arguments. Call docker help for details or use docker directly as preferred." | ||
echo | ||
;; | ||
"setup" | "s" | "") | ||
doSetup setup | ||
;; | ||
*) | ||
doRun "${@}" | ||
;; | ||
esac |
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,116 @@ | ||
#!/usr/bin/env bash | ||
|
||
# autocompletion list | ||
if [ "${1}" = "shortlist" ] | ||
then | ||
if [ -z "${2}" ] | ||
then | ||
echo "setup help" | ||
fi | ||
exit | ||
fi | ||
|
||
if [ -n "${DEVON_IDE_TRACE}" ]; then set -vx; fi | ||
# shellcheck source=scripts/functions | ||
source "$(dirname "${0}")"/../functions | ||
|
||
# $1: optional setup | ||
function doSetup() { | ||
if doIsKubernetesInstalled | ||
then | ||
doEcho "Kubernetes is already installed at $(command -v kubectl)" | ||
exit 0 | ||
else | ||
if doIsBatch | ||
then | ||
doFail "Interactive installation is required, cannot proceed in batch mode. Please rerun without batch option." | ||
fi | ||
|
||
if doIsWindows | ||
then | ||
if doIsWSLEnabled | ||
then | ||
# Check if Kubernetes is already installed on WSL | ||
if doIsKubernetesInstalledOnWSL | ||
then | ||
if [ "${1}" = "setup" ] | ||
then | ||
echo Kubernetes is already installed on WSL and ready to use. devonfw-ide did not make any changes. | ||
wsl kubectl version | ||
fi | ||
else | ||
echo Kubernetes not installed on WSL. | ||
# Install Kubernetes on WSL | ||
wsl bash ../scripts/setup-kubernetes | ||
fi | ||
else | ||
return 255 | ||
fi | ||
else | ||
echo "Sorry, kubernetes-installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request." | ||
exit 0 | ||
fi | ||
fi | ||
} | ||
|
||
|
||
# Call Kubernetes with specified arguments | ||
function doRun() { | ||
if doSetup | ||
then | ||
# Run Kubernetes command if installed on Windows. | ||
if doIsKubernetesInstalled | ||
then | ||
doEcho "Running: kubectl ${*}" | ||
kubectl "${@}" | ||
# Run Kubernetes command on WSL if installed on WSL. | ||
elif doIsWSLEnabled | ||
then | ||
if doIsKubernetesInstalledOnWSL | ||
then | ||
doEcho "Running: kubectl ${*} on WSL." | ||
wsl kubectl "${@}" | ||
else | ||
echo "Kubernetes is not installed neither on Windows nor on WSL. Please call devon kubernetes setup to install on WSL." | ||
fi | ||
fi | ||
fi | ||
} | ||
|
||
# OS independent check if Kubernetes is installed. | ||
function doIsKubernetesInstalled() { | ||
if command -v kubectl &> /dev/null | ||
then | ||
return | ||
else | ||
return 255 | ||
fi | ||
} | ||
|
||
# Checks if Kubernetes is installed on Windows Subsystem for Linux(WSL) | ||
function doIsKubernetesInstalledOnWSL() { | ||
if wsl command -v kubectl &> /dev/null | ||
then | ||
return | ||
else | ||
return 255 | ||
fi | ||
} | ||
|
||
# CLI | ||
case ${1} in | ||
"help" | "-h") | ||
echo "Setup Kubernetes." | ||
echo | ||
echo "Arguments:" | ||
echo " setup setup Kubernetes on Windows WSL." | ||
echo " «args» call Kubernetes with the specified arguments. Call kubernetes help for details or use Kubernetes(kubectl) directly as preferred." | ||
echo | ||
;; | ||
"setup" | "s" | "") | ||
doSetup setup | ||
;; | ||
*) | ||
doRun "${@}" | ||
;; | ||
esac |
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,20 @@ | ||
#!/usr/bin/env bash | ||
docker_check=$(docker --version 2>/dev/null) | ||
source "$(dirname "${0}")"/functions | ||
|
||
if [[ $docker_check != *"Docker version"* ]];then | ||
doEcho "Hint:You may be required to enter sudo user password of your Windows Subsystem for Linux(WSL) when prompted." | ||
doEcho "Installing Docker..." | ||
sudo apt-get update -y | ||
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common gnupg-agent | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
sudo apt-get update -y | ||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | ||
sudo service docker start | ||
sudo usermod -aG docker $USER | ||
doEcho Docker installed successfully on WSL. Please allow few moments for the docker engine to start using docker. | ||
else | ||
doEcho Docker already installed on WSL. | ||
docker version | ||
fi |
Oops, something went wrong.