diff --git a/windows/install-docker-in-wsl.sh b/windows/install-docker-in-wsl.sh index 2609809..0a385e8 100755 --- a/windows/install-docker-in-wsl.sh +++ b/windows/install-docker-in-wsl.sh @@ -1,5 +1,43 @@ #!/usr/bin/env bash +installDocker() { + local continue + local distribution + local codename + + echo "Installing prerequisites for Docker" + sudo apt update && sudo apt install -y apt-transport-https ca-certificates curl software-properties-common + + echo "Fetching GPG key" + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + + echo "Verify the fingerprint is correct:" + sudo apt-key fingerprint 0EBFCD88 + + echo "Does the fingerprint match [9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88] ? [y]/n" + read continue + + [[ "${continue}" != "" ]] && [[ "${continue}" = "y" ]] && [[ "${continue}" = "Y" ]] && return 137 + + distribution=$(lsb_release -is | tr '[:upper:]' '[:lower:]') + codename=$(lsb_release -cs) + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/${distribution} ${codename} stable" + + sudo apt update && sudo apt install -y docker-ce + + [[ $? -ne 0 ]] && return 137 + + echo "Do you want to run docker commands without sudo? This will make your system less secure, effectively granting your user root privileges through the use of docker" + echo "y/[n]" + read continue + + [[ "${continue}" != "" ]] && [[ "${continue}" = "y" ]] && [[ "${continue}" = "Y" ]] && return 0 + + sudo usermod -aG docker ${USER} + + return 0 +} + installGo() { echo "Installing golang" echo "Fetching latest tags from github..." @@ -71,9 +109,9 @@ installRelay() { sudo ln -s /mnt/c/Users/${USER}/go/bin/npiperelay.exe /usr/local/bin/npiperelay.exe [[ $? -ne 0 ]] && echo "Could not link the binary" && return 137 - echo "Installing socat and docker.io" + echo "Installing socat" sudo apt update - sudo apt install -y socat docker.io + sudo apt install -y socat [[ $? -ne 0 ]] && echo "Could not install the requirements" && return 137 return 0 @@ -184,6 +222,9 @@ installDockerCompose() { } initialize() { + installDocker + [[ $? -ne 0 ]] && echo "Could not install Docker" && return 137 + installGo [[ $? -ne 0 ]] && echo "Could not install Go" && return 137