Automation and setup for sites I own.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 line
1.4 KiB

  1. TF:=terraform
  2. SSH:=ssh
  3. USER_SSH_OPTS:=
  4. SSH_OPTS:=-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $(USER_SSH_OPTS)
  5. RUN_EPOCH:=$(shell date +%s)
  6. .PHONY: all
  7. all: up
  8. .PHONY: rebuild
  9. rebuild: down up
  10. .PHONY: up
  11. up:
  12. $(TF) apply -auto-approve
  13. .PHONY: down
  14. down:
  15. $(TF) destroy -auto-approve
  16. .PHONY: ssh
  17. ssh:
  18. $(SSH) $(SSH_OPTS) root@`$(TF) output ipv4`
  19. attic:
  20. install -dm755 $@
  21. .PHONY: backup
  22. backup: backup-history backup-ssl backup-gitea backup-syncthing
  23. .PHONY: backup-history
  24. backup-history: attic
  25. -$(SSH) $(SSH_OPTS) root@`$(TF) output ipv4` 'cat /root/.ash_history' > attic/.ash_history.$(RUN_EPOCH)
  26. [ -z attic/.ash_history.$(RUN_EPOCH) ] && rm attic/.ash_history.$(RUN_EPOCH) || ln -f attic/.ash_history.$(RUN_EPOCH) attic/.ash_history
  27. .PHONY: backup-gitea
  28. backup-gitea: attic
  29. $(SSH) $(SSH_OPTS) root@`$(TF) output ipv4` 'tar --exclude /var/lib/gitea/unix-domain-socket -cvJf - /var/lib/gitea /etc/gitea' > attic/gitea.txz.$(RUN_EPOCH)
  30. ln -f attic/gitea.txz.$(RUN_EPOCH) attic/gitea.txz
  31. .PHONY: backup-ssl
  32. backup-ssl: attic
  33. $(SSH) $(SSH_OPTS) root@`$(TF) output ipv4` 'tar cvJf - /etc/ssl/uacme' > attic/uacme.txz.$(RUN_EPOCH)
  34. ln -f attic/uacme.txz.$(RUN_EPOCH) attic/uacme.txz
  35. .PHONY: backup-syncthing
  36. backup-syncthing: attic
  37. $(SSH) $(SSH_OPTS) root@`$(TF) output ipv4` 'tar cvJf - /var/lib/syncthing' > attic/syncthing.txz.$(RUN_EPOCH)
  38. ln -f attic/syncthing.txz.$(RUN_EPOCH) attic/syncthing.txz