Automation and setup for sites I own.
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

45 righe
1.2 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
  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 -sf 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 cvf - /var/lib/gitea /etc/gitea' > /attic/var-lib-gitea.tar.$(RUN_EPOCH)
  30. ln -sf attic/var-lib-gitea.tar.$(RUN_EPOCH) attic/var-lib-gitea.tar
  31. .PHONY: backup-ssl
  32. backup-ssl: attic
  33. $(SSH) $(SSH_OPTS) root@`$(TF) output ipv4` 'tar cvf - /etc/ssl/uacme' > attic/etc-ssl-uacme.tar.$(RUN_EPOCH)
  34. ln -sf attic/etc-ssl-uacme.tar.$(RUN_EPOCH) attic/etc-ssl-uacme.tar