From 1414e4b06f9a6eb43087acf445c90a7f89e617b3 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 19 Oct 2018 23:20:08 -0400 Subject: start writing provisioning script for mail --- bin/helpers/launch-mail | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/helpers/launch-mail b/bin/helpers/launch-mail index 91ba123..5198173 100755 --- a/bin/helpers/launch-mail +++ b/bin/helpers/launch-mail @@ -29,6 +29,35 @@ echo "Done assigning floating ip" echo "Provisioning droplet..." -# ... +host="${1:-newmail.tozt.net}" +conf_location="/usr/local/share/puppet-tozt" +conf_repo="git://github.com/doy/puppet-tozt" + +remote() { + # shellcheck disable=SC2029 + 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" +} + +while ! remote true; do + sleep 5 +done + +remote apt-get update +remote apt-get upgrade +remote apt-get install git puppet + +ensure_conf_exists +scp -r /mnt/puppet/mail/ root@"$host":/usr/local/share/puppet-tozt/mail/secret/files +remote "cd '$conf_location' && puppet apply --modulepath=./mail -e 'include mail'" echo "Done" -- cgit v1.2.3-54-g00ecf