Skip to content

Instantly share code, notes, and snippets.

@dmp1ce
Last active December 19, 2021 17:47
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmp1ce/84c31085745101f8c241 to your computer and use it in GitHub Desktop.
Save dmp1ce/84c31085745101f8c241 to your computer and use it in GitHub Desktop.
Configure Ubuntu 15.04 for docker-compose and decompose on Vultr.com
#!/bin/bash
# To run from shell:
# bash <(curl -sSL https://gist.githubusercontent.com/dmp1ce/84c31085745101f8c241/raw)
do_config() {
# Make sure to run as root
user="$(id -un 2>/dev/null || true)"
if [ "$user" != 'root' ]; then
echo "Please try again as root"
return 1
fi
# Collect hostname
echo "Please enter the new hostname for this machine:"
read new_hostname
# Update system
apt-get update
apt-get upgrade
# Change hostname
echo "$new_hostname" > /etc/hostname
hostname $new_hostname
sed -i "s/install/$new_hostname/" /etc/hosts
# Install Docker
curl -sSL https://get.docker.com/ | sh
# Create user based on hostname and Add hostname user to docker group
useradd -m -G sudo,docker -s /bin/bash $new_hostname
echo $new_hostname:password | chpasswd
# Copy ssh authorized_keys to hostname user
cp -r /home/david/.ssh /home/$new_hostname/
chown -R $new_hostname:$new_hostname /home/$new_hostname/.ssh/
# Install Docker compose
curl -L https://github.com/docker/compose/releases/download/1.4.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose --version | awk 'NR==1{print $NF}')/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose
# Install decompose
git -C /opt clone --recursive https://github.com/dmp1ce/decompose.git
ln -s /opt/decompose/decompose /usr/local/bin
ln -s /opt/decompose/completion/decompose-bash-completion /usr/share/bash-completion/completions/decompose
}
do_config
@Xosmond
Copy link

Xosmond commented Mar 31, 2017

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment