Skip to content

Instantly share code, notes, and snippets.

@yogendra
Last active January 29, 2019 17:13
Show Gist options
  • Save yogendra/7d23440d2d139cf8d426 to your computer and use it in GitHub Desktop.
Save yogendra/7d23440d2d139cf8d426 to your computer and use it in GitHub Desktop.
Boilerplate linux scripts. Mostly provisioners for Vagrant

Setup linux OS Scripts

Most of these scripts are run as sudo.

Example:

curl -L "https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/setup-ubuntu-docker.sh" | sudo bash

Or

wget -qO- "https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/setup-ubuntu-docker.sh"  | sudo bash

Vagrant Usage:

config.vm.provision "<provisioner-name>", 
  type: "shell", 
  path: "https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/<script-name>"

Example:

config.vm.provision "docker-enable-tcp", 
  type: "shell, 
  path: "https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/docker-enable-tcp.sh"
#!/bin/bash
#URL: https://gist.githubusercontent.com/yogendra/7d23440d2d139cf8d426/raw/centos-update.sh
yum -y -q upgrade
yum -y -q install open-vm-tools
yum -y -q autoremove
yum -y -q clean all
#!/bin/bash
#URL: https://gist.githubusercontent.com/yogendra/7d23440d2d139cf8d426/raw/vagrant-allow-docker.sh
usermod -aG docker vagrant
#!/bin/bash
# URL: https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/docker-enable-tcp.sh
test \! -d /etc/systemd/system/docker.service.d && mkdir -p /etc/systemd/system/docker.service.d
test \! -f /etc/systemd/system/docker.service.d/custom.conf && cat <<CONF >/etc/systemd/system/docker.service.d/custom.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -D -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
CONF
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
systemctl status docker
#!/bin/bash
# URL: https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/docker-info.sh
cat <<Information
-------------------------------------------------------------------------------
== HOST =======================================================================
Hostname : $(hostname) / $(hostname -A)
IP Address(s) : $(hostname -I)
Kernel Version : $(uname -a)
VMWare Tool Ver : $(vmware-toolbox-cmd -v)
OS Information :
$(lsb_release -a)
== DOCKER =====================================================================
Version :
$(docker version)
Images :
$(docker images)
Containers :
$(docker ps -a)
-------------------------------------------------------------------------------
Information
#!/bin/bash
# URL: https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/docker-install.sh
curl -sSL https://get.docker.com/ | sh
#!/bin/bash
# URL: https://gist.github.com/yogendra/7d23440d2d139cf8d426/raw/setup-ubuntu-java.sh
# WIP
#!/bin/bash
#URL: https://gist.githubusercontent.com/yogendra/7d23440d2d139cf8d426/raw/ubuntu-update.sh
echo Fix APT Sources
eval $(cat /etc/lsb-release)
mv /etc/apt/sources.list /etc/apt/sources.list.$(date '+%Y-%M-%d')
cat <<SOURCES >/etc/apt/sources.list
deb mirror://mirrors.ubuntu.com/mirrors.txt ${DISTRIB_CODENAME} main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt ${DISTRIB_CODENAME}-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt ${DISTRIB_CODENAME}-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt ${DISTRIB_CODENAME}-security main restricted universe multiverse
SOURCES
echo Triggering update
apt-get -qq update
apt-get -qq upgrade
apt-get -qq install open-vm-tools
apt-get -qq autoremove
docker-machine create --driver generic $(vagrant ssh-config | grep -E '(Host|HostName|User|Port|IdentityFile) ' | sed -e 's/ //;s/^Host //;s/^HostName /--generic-ip-address /;s/^User/--generic-ssh-user /;s/^Port/--generic-ssh-port /;s/^IdentityFile/--generic-ssh-key /' | tr '\n' ' ' | sed -Ee 's/([^[:space:]]+)(.*)/\2 vagrant-\1/')
#!/bin/bash
# URL: https://gist.githubusercontent.com/yogendra/7d23440d2d139cf8d426/raw/vagrant-export-public-key.sh
head -1 /home/vagrant/.ssh/authorized_keys >> /vagrant/.vagrant/machines/${1:default}/{2:vmware_fusion}/private_key.pub
#!/bin/bash
# URL: https://gist.githubusercontent.com/yogendra/7d23440d2d139cf8d426/raw/zero-empty-space.sh
dd if=/dev/zero of=/tmp/EMPTY bs=32M; rm -f /tmp/EMPTY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment