Last active
December 6, 2018 05:02
-
-
Save rossedman/bae6e073226bc1c897097b83b6fe33e0 to your computer and use it in GitHub Desktop.
Base Image Setup
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 | |
# | |
# This is meant for setting up a base image in Cubic for homelab | |
# bootstrapping. | |
# | |
# Installing: | |
# apt-get update -y && apt-get install -y curl wget | |
# bash <(curl -L $GIST_URL) | |
# | |
# create user | |
if getent passwd rossedman > /dev/null 2>&1; then | |
echo "==> user already exists" | |
else | |
adduser --disabled-password --gecos "" rossedman | |
fi | |
# setup ssh directory | |
if [ ! -d /home/rossedman/.ssh ]; then | |
mkdir -p /home/rossedman/.ssh | |
fi | |
# get ssh keys from github | |
if [ ! -f /home/rossedman/.ssh/authorized_keys ]; then | |
touch /home/rossedman/.ssh/authorized_keys | |
curl https://github.com/rossedman.keys >> /home/rossedman/.ssh/authorized_keys | |
fi | |
chown -R rossedman:rossedman /home/rossedman | |
chmod 700 /home/rossedman/.ssh && chmod 600 /home/rossedman/.ssh/* | |
# setup sudoers | |
if grep -q "rossedman" /etc/sudoers; then | |
echo "==> already in sudoers file" | |
else | |
echo "rossedman ALL=(ALL) NOPASSWD: ALL" | tee --append /etc/sudoers | |
fi | |
# set timezone | |
timedatectl set-timezone America/Chicago | |
# install puppet | |
wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb | |
dpkg -i puppetlabs-release-pc1-xenial.deb | |
# install packages | |
apt-get update -y && | |
apt-get install -y \ | |
apt-transport-https \ | |
bridge-utils \ | |
ca-certificates \ | |
puppet-agent \ | |
puppetserver \ | |
software-properties-common \ | |
vim \ | |
qemu-kvm \ | |
libvirt-bin | |
# install docker | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
apt-get update -y && apt-get install -y docker-ce=$(apt-cache madison docker-ce | grep 17.03 | head -1 | awk '{print $3}') | |
# install kubectl | |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl | |
mv kubectl /usr/local/bin/kubectl | |
chmod +x /usr/local/bin/kubectl | |
# set docker group | |
usermod -aG docker rossedman | |
# services | |
systemctl enable docker | |
# cleanup | |
rm puppetlabs-release-pc1-xenial.deb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment