Last active
February 25, 2022 01:04
-
-
Save m-radzikowski/c9e54fa9e4f096e345e3b1bb1b643781 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# Personal script to setup Linux Mint | |
# and install bunch of tools. | |
set -euo pipefail | |
echoerr() { echo "$@" 1>&2; } | |
ensure_sudo() { | |
if [[ $UID != 0 ]]; then | |
echoerr "Script must be run with sudo:" | |
echoerr "sudo $0 $*" | |
exit 1 | |
fi | |
} | |
echoversion() { | |
echo | |
echo "$1 installed: $2" | |
echo | |
} | |
get_ubuntu_codename() { | |
local UBUNTU_CODENAME | |
# For Linux Mint we need the underlying Ubuntu version | |
UBUNTU_CODENAME="$(. /etc/os-release && echo "$UBUNTU_CODENAME")" | |
# Otherwise we get normal codename | |
if [[ -z "$UBUNTU_CODENAME" ]]; then | |
UBUNTU_CODENAME="$(lsb_release -cs)" | |
fi | |
if [[ -z "$UBUNTU_CODENAME" ]]; then | |
echoerr "Could not determine Ubuntu codename" | |
exit 1 | |
fi | |
echo "$UBUNTU_CODENAME" | |
} | |
install_git() { | |
echo "Installing Git from PPA repository..." | |
add-apt-repository -y ppa:git-core/ppa | |
apt update | |
apt install -y git | |
echoversion "Git" "$(git --version)" | |
} | |
install_docker() { | |
echo "Installing Docker..." | |
apt update | |
apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
add-apt-repository -y "deb https://download.docker.com/linux/ubuntu $UBUNTU_CODENAME stable" | |
apt update | |
apt install -y docker-ce docker-ce-cli containerd.io | |
groupadd docker || true | |
usermod -aG docker "$(logname)" | |
systemctl enable docker | |
echoversion "Docker" "$(docker --version)" | |
} | |
install_docker_compose() { | |
echo "Installing Docker Compose..." | |
curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
curl -L https://raw.githubusercontent.com/docker/compose/1.24.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose | |
echoversion "Docker Compose" "$(docker-compose --version)" | |
} | |
install_fish() { | |
echo "Installing fish..." | |
apt-add-repository -y ppa:fish-shell/release-3 | |
apt update | |
apt install -y fish | |
echo /usr/bin/fish | tee -a /etc/shells | |
echoversion "fish" "$(fish --version)" | |
} | |
install_other_tools() { | |
echo "Installing other tools..." | |
add-apt-repository -y ppa:inkscape.dev/stable | |
apt update | |
apt install -y inkscape fonts-powerline jq graphviz | |
} | |
final_notes() { | |
echo | |
echo | |
echo "Setup completed." | |
echo | |
echo "Execute:" | |
printf "\t%s\n" "chsh -s /usr/bin/fish" | |
echo "to change default shell to fish" | |
echo | |
echo "Reboot to finish initialization of all components." | |
echo | |
} | |
main() { | |
ensure_sudo "$@" | |
UBUNTU_CODENAME=$(get_ubuntu_codename) | |
echo "Ubuntu codename is $UBUNTU_CODENAME" | |
echo | |
install_git | |
install_docker | |
install_docker_compose | |
install_fish | |
install_other_tools | |
final_notes | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment