Skip to content

Instantly share code, notes, and snippets.

@coffeegoddd
Last active February 14, 2023 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coffeegoddd/655669b436dbf28d78d5610749350811 to your computer and use it in GitHub Desktop.
Save coffeegoddd/655669b436dbf28d78d5610749350811 to your computer and use it in GitHub Desktop.
Easily install DoltLab's dependencies on CentOS 7
#!/bin/bash
set -e
set -o pipefail
with_sudo=""
version=""
if [ "$#" -eq 2 ]; then
if [ "$1" == "with-sudo" ]; then
with_sudo="sudo"
version="$2"
else
echo "unrecognized argument $1"
echo ""
echo ""
echo "Usage: ./centos-bootstrap.sh <DoltLab version>"
echo "Or: ./centos-bootstrap.sh with-sudo <DoltLab version>"
echo "to prefix appropriate commands with 'sudo'"
echo ""
echo ""
exit 1
fi
else
version="$1"
fi
export DEBIAN_FRONTEND=noninteractive
export PATH=$PATH:/usr/local/bin
# create docker group if it doesnt exist
group=docker
eval "$with_sudo getent group $group" || eval "$with_sudo groupadd $group"
# do this here to avoid 'newgrp' command
# which doesnt work well in scripts
if [ $(id -gn) != $group ]; then
exec "$with_sudo" sg $group "$0 $*"
fi
echo "Preparing to download DoltLab $version"
# install tools make, unzip, git
eval "$with_sudo yum makecache -y"
eval "$with_sudo yum install unzip make git -y"
# install docker and docker-compose
eval "$with_sudo yum install -y yum-utils"
eval "$with_sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo"
eval "$with_sudo yum install -y docker-ce docker-ce-cli containerd.io"
eval "$with_sudo systemctl start docker"
# sanity check
docker --version
eval "$with_sudo curl -L 'https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)' -o /usr/local/bin/docker-compose"
eval "$with_sudo chmod +x /usr/local/bin/docker-compose"
# sanity check
docker-compose --version
eval "$with_sudo usermod -aG docker $USER"
# sanity check
docker ps
# install creds-helper and create config
git clone https://github.com/awslabs/amazon-ecr-credential-helper.git
cd amazon-ecr-credential-helper && make docker
eval "$with_sudo mv ./bin/local/docker-credential-ecr-login /usr/local/bin/"
docker-credential-ecr-login -v
cd .. && mkdir -p ~/.docker
echo '{"credHelpers":{"public.ecr.aws":"ecr-login"}}' > ~/.docker/config.json
# download and unzip DoltLab
curl -LO https://doltlab-releases.s3.amazonaws.com/linux/amd64/doltlab-"$version".zip
unzip doltlab-"$version".zip -d doltlab
cd doltlab
echo "All dependencies installed successfully, ready to start DoltLab"
echo "Please run 'sudo newgrp docker' to use docker without 'sudo'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment