#!/bin/bash # Where in the world is bootstrap? BOOTSTRAP_ARCHIVE="https://github.com/br0ns/bootstrap/archive/master.zip" DIR="$(realpath "$(dirname "$0")")" export BOOTSTRAP_ALL=true # Fail on any error set -e # If this file does not exist it's probably because we're bootstrapping a fresh # system. So we download the Git repository and bootstrap from there if [ ! -e "$DIR/bs.sh" ] ; then # Required packages for pkg in ca-certificates unzip wget ; do if ! dpkg --status $pkg >/dev/null 2>&1 ; then echo Installing $pkg sudo CHECK_PKGS_DONT_RUN=1 apt-get install --yes --no-install-recommends $pkg fi done TEMPDIR="$(mktemp -d /tmp/bootstrap.XXXXXXXXXX)" echo -e "Downloading \x1b[32m$BOOTSTRAP_ARCHIVE\x1b[m => \x1b[32m$TEMPDIR/\x1b[m" cd $TEMPDIR wget "$BOOTSTRAP_ARCHIVE" unzip master.zip DIR="$(realpath "$TEMPDIR/bootstrap-master/")" fi # Go through all the step scripts and execute them for f in $(ls "$DIR" | sort -n) ; do p="$DIR/$f" # Path must be an executable (-x) file (-f) which starts with a digit [[ "$f" =~ ^[0-9] ]] && [ -f "$p" ] && [ -x "$p" ] || continue "$p" "$@" done exit 0