network/justfile

41 lines
1 KiB
Makefile
Raw Normal View History

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
deploy-config node ipv4_subnet ipv6_subnet:
#!/usr/bin/env sh
echo "Configuring {{node}}.network.tjo.cloud"
echo " - IPv4: {{ipv4_subnet}}"
echo " - IPv6: {{ipv6_subnet}}"
for file in {{justfile_directory()}}/openwrt/etc/config/*
do
echo "Deploying /etc/config/$(basename $file)"
export IPV4_SUBNET="{{ipv4_subnet}}"
export IPV6_SUBNET="{{ipv6_subnet}}"
export HOSTNAME="{{node}}.network.tjo.cloud"
cat $file | envsubst | tailscale ssh "root@{{node}}-network-tjo-cloud" "cat > /etc/config/$(basename $file)"
done
echo "Reloading network configuration"
tailscale ssh "root@{{node}}-network-tjo-cloud" "/etc/init.d/network reload"