# 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 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 # Skip node specific configs if [[ "$file" == *\.* ]] then continue fi 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)" # Deploy node specific configs if [ -f "${file}.{{node}}" ] then cat "${file}.{{node}}" | envsubst | tailscale ssh "root@{{node}}-network-tjo-cloud" "cat >> /etc/config/$(basename $file)" fi done echo "Reboot router in 5 seconds..." sleep 5 echo "Rebooting router..." tailscale ssh "root@{{node}}-network-tjo-cloud" "reboot"