Skip to content

Instantly share code, notes, and snippets.

Created January 13, 2015 09:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
docker, docker-enter installer + installs a wordpress dev instance
# Wordpress dev env installer for dummies.
command_exists() {
command -v "$@" > /dev/null 2>&1
user="$(id -un 2>/dev/null || true)"
sh_c='sh -c'
if [ "$user" != 'root' ]; then
if command_exists sudo; then
sh_c='sudo -E sh -c'
elif command_exists su; then
sh_c='su -c'
echo >&2 'Error: this installer needs the ability to run commands as root.'
echo >&2 'We are unable to find either "sudo" or "su" available to make this happen.'
exit 1
if command_exists curl; then
curl='curl -sSL'
elif command_exists wget; then
curl='wget -qO-'
elif command_exists busybox && busybox --list-modules | grep -q wget; then
curl='busybox wget -qO-'
# Install latest docker version (not the outdated package)
# -> does not support Archlinux yet
curl | sudo sh
# Taking care of the local copy of wordpress...
if [ -d wordpress ]; then
rm -rf wordpress
# Actually downloading it...
curl -sSL | tar xzC .
curl -sS > ; unzip -j posts.xml -d wordpress/wp-content/ ; rm
# Install docker-enter
curl -o /usr/local/bin/docker-enter
chmod 755 /usr/local/bin/docker-enter
# Run docker commands
if command_exists docker && [ -e /var/run/docker.sock ]; then
set -x
$sh_c 'docker run -d -p 80:80 --name wordpress -v $(pwd)/wordpress/wp-content/:/var/www/wordpress/wp-content rigelk/pressgang'
) || true
# Self destruct :)
rm -- "$0"
# Enter the newly created container
if command_exists docker && [ -e /var/run/docker.sock ]; then
set -x
$sh_c 'docker-enter wordpress'
) || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment