Last active
September 23, 2021 17:05
-
-
Save tinytengu/7ac0d10b76dbd95c01781887bd54cfce to your computer and use it in GitHub Desktop.
Docker & Docker-Compose installation and configuration shell script
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
# Utils | |
prompt_yn() { | |
def=$2 | |
case $def in | |
[yY]) def="y"; read -r -p "${1} [Y/n] " input;; | |
[nN]) def="n"; read -r -p "${1} [y/N] " input;; | |
esac | |
case $input in | |
"") | |
if [ $def = "y" ]; then | |
echo 1 | |
else | |
echo 0 | |
fi | |
;; | |
[yY][eE][sS]|[yY]) echo 1;; | |
[nN][oO]|[nN]|*) echo 0;; | |
esac | |
} | |
get_latest_release() { | |
curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | |
} | |
# Docker | |
yes y | pacman -S docker | |
sudo usermod -aG docker $(logname) | |
sudo systemctl enable docker | |
sudo systemctl start docker | |
# Docker-Compose | |
REPO="docker/compose" | |
COMPOSE_VER=$(get_latest_release $REPO) | |
sudo curl -L "https://github.com/${REPO}/releases/download/${COMPOSEVER}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
yn=$(prompt_yn "You need to reboot your system in order to apply docker settings. Reboot now?" "n") | |
if [ $yn == 1 ]; then | |
sudo reboot | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment