summaryrefslogtreecommitdiffstats
path: root/bootstrap
blob: ef985fc052a931dfbe69178e402b0f658596ba53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -eux
set -o pipefail

host="$1"
conf_location="/usr/local/share/puppet-tozt"
conf_repo="git://github.com/doy/puppet-tozt"

remote() {
    ssh root@$host "$@"
}

ensure_conf_exists() {
    if remote test -d "$conf_location"; then
        remote "cd '$conf_location' && git pull"
    else
        remote "mkdir -p '$conf_location'"
        remote "cd '$conf_location' && git clone '$conf_repo' ."
    fi
    remote "cd '$conf_location' && git submodule update --init --recursive"
}

if remote test ! -e /usr/bin/pacman; then
    remote apt-get -y update
    remote apt-get -y install git
    ensure_conf_exists
    remote "cd '$conf_location/digitalocean-debian-to-arch' && bash install.sh --i_understand_that_this_droplet_will_be_completely_wiped --extra_packages 'puppet git ruby-shadow'"
    sleep 30
fi

ensure_conf_exists
remote "cd '$conf_location' && puppet apply --modulepath=./modules -e 'include tozt'"