From 7f26b72190700a874712a6f57661b4659e42c450 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 27 Apr 2024 16:19:22 -0700 Subject: [PATCH] Pull down script for s3 --- .../ansible/playbooks/setup-s3-scripts.yml | 8 +++++++ .../ansible/scripts/pull-down-s3.sh | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 infra/static-vultr/ansible/playbooks/setup-s3-scripts.yml create mode 100644 infra/static-vultr/ansible/scripts/pull-down-s3.sh diff --git a/infra/static-vultr/ansible/playbooks/setup-s3-scripts.yml b/infra/static-vultr/ansible/playbooks/setup-s3-scripts.yml new file mode 100644 index 0000000..ef75aac --- /dev/null +++ b/infra/static-vultr/ansible/playbooks/setup-s3-scripts.yml @@ -0,0 +1,8 @@ +--- +- hosts: webhost + remote_user: root + tasks: + - name: Copy pull script + copy: + src: ../scripts/pull-down-s3.sh + dest: /opt/nginx/pull-down-s3.sh diff --git a/infra/static-vultr/ansible/scripts/pull-down-s3.sh b/infra/static-vultr/ansible/scripts/pull-down-s3.sh new file mode 100644 index 0000000..19506d1 --- /dev/null +++ b/infra/static-vultr/ansible/scripts/pull-down-s3.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +bucket="$1" +s3env=/opt/nginx/s3.env + +[[ -z "$bucket" ]] && echo "No bucket selected" && exit 1 + +[[ ! -f $s3env ]] && echo "No credentials to source!" && exit 1 +source $s3env + +pull() { + aws s3 sync s3://$bucket /opt/nginx/$bucket +} + + +case $bucket in + resume.shockrah.xyz|shockrah.xyz|temper.tv) pull;; + *) echo "Invalid bucket name" && exit 1 ;; +esac + +