| VERSION_CODENAME ?= $(shell grep VERSION_CODENAME /etc/os-release | cut -d'=' -f2) | |
| VERSION_ID ?= $(shell grep VERSION_ID /etc/os-release | cut -d'=' -f2| tr -d '"') | |
| VERSION_NAME ?= $(shell grep ^NAME= /etc/os-release | cut -d'=' -f2 | tr -d '"'| tr '[:upper:]' '[:lower:]') | |
| HOSTNAME ?= $(shell hostname) | |
| IMAGE_PROVIDER ?= docker.io | |
| IMAGE_NAME ?= rafaelcalleja/distrostore | |
| IMAGE_FLAVOR ?= GNOME | |
| IMAGE_TAG ?= $(VERSION_NAME)-$(VERSION_ID)-$(IMAGE_FLAVOR) | |
| IMAGE ?= $(IMAGE_NAME):$(IMAGE_TAG) | |
| REPOSITORY ?= hf.co/$(IMAGE) | |
| GOPASS_FILE ?= .autorestic.yml | |
| GOPASS_KEY ?= $(REPOSITORY)/$(GOPASS_FILE) | |
| CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | |
| COMMIT_MESSAGE ?= $(shell date) | |
| RESTORE_DST ?= /tmp/restore | |
| RESTORE_FROM ?= hdd | |
| RESTORE_LOCATION ?= root_backup | |
| SSH_USER ?= $(shell whoami) | |
| SSH_HOST ?= $(shell ip addr show | grep -A 2 'eth' | grep inet | awk '{print $$2}' | cut -d/ -f1 | head -n 1) | |
| SSH_AUTH_SOCK ?= $(shell echo ${SSH_AUTH_SOCK}) | |
| default: backup | |
| backup: | |
| time autorestic -c $(CURRENT_DIR)/$(GOPASS_FILE) backup -a && \ | |
| git add -A && \ | |
| git commit -m "$(COMMIT_MESSAGE)" && \ | |
| git push | |
| restore: | |
| cd $(RESTORE_DST); time autorestic restore --from $(RESTORE_FROM) -l $(RESTORE_LOCATION) -c $(CURRENT_DIR)/$(GOPASS_FILE) | |
| save: | |
| gopass insert -f $(GOPASS_KEY) < $(GOPASS_FILE) | |
| load: | |
| gopass show $(GOPASS_KEY) >$(GOPASS_FILE) | |
| show-cron: | |
| @cat $(CURRENT_DIR)/.cron | sed "s|CURRENT_DIR|$(CURRENT_DIR)|g" | |
| build: | |
| docker run --rm --privileged -e BUILDKITD_FLAGS="--allow-insecure-entitlement security.insecure" \ | |
| --volume $(CURRENT_DIR):/tmp/work \ | |
| --volume "$${HOME}/.docker:/root/.docker:ro" \ | |
| --volume $(SSH_AUTH_SOCK):$(SSH_AUTH_SOCK) \ | |
| --volume $(RESTORE_DST):$(RESTORE_DST) \ | |
| --entrypoint buildctl-daemonless.sh \ | |
| moby/buildkit:master \ | |
| build \ | |
| --frontend dockerfile.v0 \ | |
| --local context=/tmp/work \ | |
| --local dockerfile=/tmp/work \ | |
| --allow security.insecure \ | |
| --opt build-arg:SSH_USER=$(SSH_USER) \ | |
| --opt build-arg:SSH_HOST=$(SSH_HOST) \ | |
| --opt build-arg:ROOTFS=$(RESTORE_DST) \ | |
| --output type=image,name=$(IMAGE_PROVIDER)/$(IMAGE),push=true \ | |
| --ssh default=$(SSH_AUTH_SOCK) | |