2024-11-02 18:53:21 +00:00
|
|
|
# Always use devbox environment to run commands.
|
|
|
|
set shell := ["devbox", "run"]
|
|
|
|
# Load dotenv
|
|
|
|
set dotenv-load
|
|
|
|
|
|
|
|
default:
|
|
|
|
@just --list
|
|
|
|
|
|
|
|
lint:
|
|
|
|
@tofu fmt -check -recursive .
|
|
|
|
@tflint --recursive
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
#!/usr/bin/env sh
|
|
|
|
cd {{justfile_directory()}}/terraform
|
|
|
|
tofu init
|
|
|
|
tofu apply
|
|
|
|
|
|
|
|
destroy:
|
|
|
|
#!/usr/bin/env sh
|
|
|
|
cd {{justfile_directory()}}/terraform
|
|
|
|
tofu destroy
|
2024-11-03 21:33:24 +00:00
|
|
|
|
2024-11-08 20:54:59 +00:00
|
|
|
configure:
|
2024-11-03 21:33:24 +00:00
|
|
|
#!/usr/bin/env sh
|
2024-11-08 20:54:59 +00:00
|
|
|
set -euo pipefail
|
2024-11-03 21:33:24 +00:00
|
|
|
|
2024-11-08 20:54:59 +00:00
|
|
|
for node in $(ls configs/node.*.yaml | cut -d '.' -f 2)
|
2024-11-03 21:33:24 +00:00
|
|
|
do
|
2024-11-08 20:54:59 +00:00
|
|
|
echo "Configuring ${node}.network.tjo.cloud"
|
|
|
|
|
|
|
|
for file in {{justfile_directory()}}/openwrt/etc/config/*
|
|
|
|
do
|
|
|
|
echo "Deploying /etc/config/$(basename $file)"
|
|
|
|
gomplate --file $file \
|
|
|
|
--datasource common=configs/common.yaml \
|
|
|
|
--datasource node=configs/node.${node}.yaml \
|
|
|
|
| tailscale ssh "root@${node}-network-tjo-cloud" "cat > /etc/config/$(basename $file)"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Reboot router in 5 seconds..."
|
|
|
|
sleep 5
|
|
|
|
echo "Rebooting router..."
|
|
|
|
tailscale ssh "root@${node}-network-tjo-cloud" "reboot"
|
2024-11-03 21:33:24 +00:00
|
|
|
done
|