2024-01-10 17:56:40 +03:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# TODO:
|
|
|
|
|
# - cleanup/destroy
|
|
|
|
|
# - update
|
|
|
|
|
# - backup
|
|
|
|
|
# - pull config
|
|
|
|
|
#
|
2024-09-21 22:57:42 +03:00
|
|
|
#
|
2024-01-10 17:56:40 +03:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
2024-10-21 16:37:19 +03:00
|
|
|
EDITOR ?= nano
|
2024-01-20 18:36:57 +03:00
|
|
|
|
|
|
|
|
|
2024-02-04 17:55:26 +03:00
|
|
|
# CTs...
|
|
|
|
|
#
|
2024-01-13 00:04:09 +03:00
|
|
|
MINIMAL_CTs := \
|
|
|
|
|
ssh wireguard
|
|
|
|
|
APP_CTs := \
|
2024-10-19 20:27:12 +03:00
|
|
|
syncthing nextcloud
|
2024-02-05 23:16:24 +03:00
|
|
|
# Optional (see dev target)...
|
2024-01-13 00:04:09 +03:00
|
|
|
DEV_CTs := \
|
|
|
|
|
gitea
|
2024-01-10 17:56:40 +03:00
|
|
|
|
|
|
|
|
|
2024-01-12 17:11:38 +03:00
|
|
|
DEPENDENCIES = make git dig pct
|
2024-01-12 17:10:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# dependency checking...
|
|
|
|
|
|
|
|
|
|
require(%):
|
|
|
|
|
@printf "%-20s %s\n" \
|
|
|
|
|
"$*" \
|
|
|
|
|
"`which $* &> /dev/null && echo '- OK' || echo '- FAIL'`"
|
|
|
|
|
|
|
|
|
|
.PHONY: check-message
|
|
|
|
|
check-message:
|
|
|
|
|
|
|
|
|
|
.PHONY: check
|
|
|
|
|
check: check-message $(foreach dep,$(DEPENDENCIES),require($(dep)))
|
|
|
|
|
|
|
|
|
|
|
2024-01-10 17:56:40 +03:00
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
.PHONY: FORCE
|
|
|
|
|
FORCE:
|
|
|
|
|
|
|
|
|
|
|
2024-10-17 14:38:01 +03:00
|
|
|
%-bootstrap: export BOOTSTRAP=1
|
|
|
|
|
%-bootstrap: %
|
2024-10-18 17:32:19 +03:00
|
|
|
@true
|
2024-10-17 14:25:02 +03:00
|
|
|
|
|
|
|
|
|
2024-10-17 14:38:01 +03:00
|
|
|
%-bootstrap-clean: export BOOTSTRAP_CLEAN=1
|
|
|
|
|
%-bootstrap-clean: %
|
2024-10-18 17:32:19 +03:00
|
|
|
@true
|
2024-10-17 14:25:02 +03:00
|
|
|
|
|
|
|
|
|
2024-01-15 01:06:15 +03:00
|
|
|
%: config %/make.sh FORCE
|
|
|
|
|
$*/make.sh
|
2024-10-22 03:36:04 +03:00
|
|
|
@echo
|
2024-01-10 16:14:59 +03:00
|
|
|
|
2024-01-06 18:31:13 +03:00
|
|
|
|
2024-01-13 00:04:09 +03:00
|
|
|
%.config: %/config.example
|
|
|
|
|
|
|
|
|
|
|
2024-10-31 16:49:41 +03:00
|
|
|
# NOTE: this will edit the config either if it does not exist or if it
|
|
|
|
|
# is the same as the example...
|
2024-01-06 18:31:13 +03:00
|
|
|
config.global: config.global.example
|
2024-01-12 17:10:43 +03:00
|
|
|
@ [ ! -e "$@" ] \
|
2024-10-31 16:47:02 +03:00
|
|
|
|| cmp --silent "$<" "$@" \
|
2024-10-31 16:38:41 +03:00
|
|
|
&& cp -p "$<" "$@" \
|
2024-10-31 16:40:45 +03:00
|
|
|
&& touch "$<" \
|
2024-01-12 17:10:43 +03:00
|
|
|
&& $(EDITOR) "$@" \
|
|
|
|
|
|| true
|
2024-01-06 18:31:13 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-10 17:56:40 +03:00
|
|
|
#----------------------------------------------------------------------
|
2024-10-19 20:27:12 +03:00
|
|
|
# Bootstrapping...
|
2024-01-06 18:31:13 +03:00
|
|
|
|
2024-10-19 19:19:19 +03:00
|
|
|
# Bootstrap stage 1: build basic infrastructure...
|
2024-09-19 17:13:49 +03:00
|
|
|
.PHONY: bootstrap
|
2024-10-19 19:19:19 +03:00
|
|
|
bootstrap: \
|
|
|
|
|
host-bootstrap \
|
2024-10-19 20:27:12 +03:00
|
|
|
gate-bootstrap ns \
|
2024-10-20 01:02:39 +03:00
|
|
|
$(MINIMAL_CTs)
|
2024-10-20 00:55:37 +03:00
|
|
|
make bootstrap-clean
|
2024-10-17 14:25:02 +03:00
|
|
|
|
2024-10-19 13:59:43 +03:00
|
|
|
|
2024-10-19 19:19:19 +03:00
|
|
|
# Bootstrap stage 2: reconnect host through the base infrastructure...
|
2024-10-20 01:02:39 +03:00
|
|
|
.PHONY: bootstrap-clean
|
2024-10-19 19:19:19 +03:00
|
|
|
bootstrap-clean: host-bootstrap-clean
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Finalize: reconect admin port/bridge correctly...
|
2024-10-21 19:15:53 +03:00
|
|
|
.PHONY: finalize
|
|
|
|
|
finalize: gate-bootstrap-clean
|
2024-10-21 21:52:00 +03:00
|
|
|
# cleanup: stage 1...
|
2024-10-21 19:15:53 +03:00
|
|
|
make host-bootstrap-clean
|
2024-10-21 21:52:00 +03:00
|
|
|
# cleanup: stage 2...
|
2024-10-20 00:55:37 +03:00
|
|
|
make host-bootstrap-clean
|
2024-09-19 17:13:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
2024-10-19 20:27:12 +03:00
|
|
|
# Shorthands...
|
2024-01-13 00:04:09 +03:00
|
|
|
|
2024-10-19 20:27:12 +03:00
|
|
|
.PHONY: config
|
|
|
|
|
config: config.global
|
2024-01-13 00:04:09 +03:00
|
|
|
|
|
|
|
|
|
2024-10-19 20:27:12 +03:00
|
|
|
.PHONY: gate
|
|
|
|
|
gate: gate-traefik
|
2024-01-13 00:04:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-19 20:27:12 +03:00
|
|
|
#----------------------------------------------------------------------
|
2024-01-13 00:04:09 +03:00
|
|
|
|
2024-01-06 18:31:13 +03:00
|
|
|
.PHONY: all
|
2024-10-19 20:27:12 +03:00
|
|
|
all: $(APP_CTs)
|
2024-01-10 17:56:40 +03:00
|
|
|
|
2024-01-06 18:31:13 +03:00
|
|
|
|
2024-10-19 20:27:12 +03:00
|
|
|
.PHONY: dev
|
|
|
|
|
dev: $(DEV_CTs)
|
2024-10-19 19:19:19 +03:00
|
|
|
|
|
|
|
|
|
2024-01-06 18:31:13 +03:00
|
|
|
|
2024-01-20 19:00:22 +03:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
clean:
|
2024-01-30 03:49:06 +03:00
|
|
|
-rm -rf \
|
|
|
|
|
*/staging \
|
2024-10-31 14:17:35 +03:00
|
|
|
*/traefik \
|
|
|
|
|
*/config.last-run
|
|
|
|
|
|
2024-11-01 15:19:56 +03:00
|
|
|
|
2024-10-31 16:56:31 +03:00
|
|
|
.PHONY: clean-interfaces
|
|
|
|
|
clean-interfaces: /etc/network/interfaces.orig
|
|
|
|
|
# NOTE: this may need 'ifreload -a' to take effect...
|
|
|
|
|
cp "$<" "$(subst .orig,,$<)"
|
|
|
|
|
|
2024-11-01 15:19:56 +03:00
|
|
|
|
2024-10-31 14:17:35 +03:00
|
|
|
.PHONY: clean-all
|
|
|
|
|
clean-all: clean
|
|
|
|
|
-rm -rf \
|
|
|
|
|
config.global
|
2024-01-20 19:00:22 +03:00
|
|
|
|
2024-01-06 18:31:13 +03:00
|
|
|
|
2024-01-17 15:07:18 +03:00
|
|
|
|
2024-10-31 16:27:08 +03:00
|
|
|
|
2024-01-10 17:56:40 +03:00
|
|
|
#----------------------------------------------------------------------
|
2024-09-19 17:13:49 +03:00
|
|
|
# vim:set ts=4 sw=4 nowrap :
|