setup-pixel-borg (750B)
1 #!/bin/bash 2 3 set -eu 4 5 if [ -z "${PIXEL_BORG_KEY:-}" ] 6 then 7 echo "You need to set the PIXEL_BORG_KEY in your environment before running this script (see admin-log/pixel/03-borg.txt)" 8 exit 1 9 fi 10 11 case "${1:-}" in 12 -*) 13 echo "Usage: $0 [host/group [ansible-playbook options...]]" >&2 14 exit 1 15 ;; 16 esac 17 18 target=${1:-spec} 19 if [ "$#" -gt 0 ]; then 20 shift 21 fi 22 23 ansible-playbook \ 24 --extra-vars "pixel_borg_key={{ lookup('env', 'PIXEL_BORG_KEY') }}" \ 25 --inventory inventories/default \ 26 --limit "$target" \ 27 --user root \ 28 playbooks/pixel-borg.yml \ 29 "$@" 30 mv borg-repokey/*/home/borg/borg-repo.key . 31 rm -rf borg-repokey/ 32 echo "Make sure to back up the borg-repo.key to admin-log/pixel/borg-repo.key" 33 exit 0