Last active
November 27, 2022 16:13
-
-
Save Lucho00Cuba/5a0685662273045c08132410065f3e6f to your computer and use it in GitHub Desktop.
Docker Install
This file contains hidden or 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
#!/bin/bash | |
# Install Docker Ubuntu | |
# Ubuntu 20.04.2 LTS (Focal Fossa) | |
# Author : Lucho | Just Me | |
# Linkedin : https://www.linkedin.com/in/luis-octavio-mota-verdasco-sys-admin/ | |
banner(){ | |
# Banner | |
echo " " | |
echo " ____ __ ____ __ ____ " | |
echo " / __ \____ _____/ /_____ _____ / _/___ _____/ /_____ _/ / / " | |
echo " / / / / __ \/ ___/ //_/ _ \/ ___/ / // __ \/ ___/ __/ __ / / / " | |
echo " / /_/ / /_/ / /__/ ,< / __/ / _/ // / / (__ ) /_/ /_/ / / / " | |
echo " /_____/\____/\___/_/|_|\___/_/ /___/_/ /_/____/\__/\__,_/_/_/ " | |
echo " " | |
} | |
updated(){ | |
$(apt update 2>/dev/null 1>/dev/null) | |
} | |
unistalled_old(){ | |
$(apt-get remove docker docker-engine docker.io containerd runc -y --purge --autoremove 2>/dev/null 1>/dev/null) | |
} | |
installed(){ | |
$(apt-get update 2>/dev/null 1>/dev/null) | |
$(apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y 2>/dev/null 1>/dev/null) | |
$(curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 2>/dev/null 1>/dev/null) | |
$(echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null) | |
$(apt-get update 2>/dev/null 1>/dev/null) | |
$(apt-get install docker-ce docker-ce-cli containerd.io -y 2>/dev/null 1>/dev/null) | |
} | |
users(){ | |
# User | |
echo -n "Escribe tu nombre de usuario: " | |
read user | |
$(usermod -aG docker $user) | |
echo "[*] Asignando Permisos" | |
sleep 5 | |
testing | |
} | |
testing(){ | |
# Testing | |
echo -n "Desplegaremos un Contenedor de Prueba [y/n]: " | |
read con | |
if [ $con = 'y' ]; then | |
docker run hello-world | |
echo "[*] Finalizado" | |
else | |
echo "[*] Finalizado" | |
fi | |
} | |
compose(){ | |
$(curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 2>/dev/null 1>/dev/null) | |
$(chmod +x /usr/local/bin/docker-compose) | |
} | |
# Main | |
if [ $(whoami) = 'root' ]; then | |
#Banner | |
banner | |
# Update | |
echo "[*] Actualizando Sistema" | |
updated | |
echo "[*] Hecho" | |
sleep 5 | |
# Unistall Old Versions | |
echo "[*] Desintalando Versiones Anteriores" | |
unistalled_old | |
echo "[*] Hecho" | |
sleep 5 | |
# Install | |
echo "[*] Instalando" | |
installed | |
echo "[*] Hecho" | |
sleep 5 | |
# Compose | |
echo "[*] Instalando Compose" | |
compose | |
echo "[*] Hecho" | |
# Users | |
echo -n "Quieres asignar permisos a un usuario no root [y/n]: " | |
read per | |
if [ $per = 'y' ]; then | |
# User | |
users | |
else | |
testing | |
fi | |
else | |
echo " " | |
echo "[-] Modo de Ejecucion" | |
echo "sudo docker.sh" | |
echo " " | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment