# Alpine Linux setup mod alpine "./just/alpine.just" _default: just --list # Check if host directory exists [group("check")] host-dir-exists host: #!/usr/bin/env sh if [ ! -d {{host}} ]; then echo "{{host}} does not exist" exit 1 fi # Check host reachability via ping [group("check")] host-reachable host: (host-dir-exists host) #!/usr/bin/env sh ping -w 1 -c 1 $(cat ./{{host}}/ADDRESS) if [ $? -ne 0 ]; then echo "{{host}} is not reachable" exit 1 fi # All checks [group("check")] check host: (host-dir-exists host) (host-reachable host) # Remove common files from host [group("cleanup")] remove-common host: (host-dir-exists host) #!/usr/bin/env sh prefix="./common/" for file in $(find ./common/ -type f); do path=${file#$"$prefix"} rm -f "./{{host}}/files/$path" done # Remove build artifacts [group("cleanup")] remove-artifacts host: (host-dir-exists host) rm -f "./{{host}}/{{host}}.img" rm -f "./{{host}}/{{host}}.packages" rm -f "./{{host}}/payload.tar.gz" # All cleanups [group("cleanup")] cleanup host: (remove-common host) (remove-artifacts host) # Merge common files into host directory merge-with-common host: (host-dir-exists host) cp --archive --force ./common/. ./{{host}}/files/ # Test the IMGBUILD by building an image test host: (host-dir-exists host) (merge-with-common host) && (cleanup host) #!/usr/bin/env sh cd ./{{host}} sudo makeimg --format "raw 4g msdos ext4" # Download anemos to the host get-anemos host: (host-reachable host) ssh root@$(cat ./{{host}}/ADDRESS) curl https://git.sr.ht/~bitfehler/anemos-cli/blob/master/anemos -o anemos ssh root@$(cat ./{{host}}/ADDRESS) chmod +x ./anemos # Tar the payload for a host payload host: (host-dir-exists host) (merge-with-common host) #!/usr/bin/env sh cd ./{{host}} makeimg -R anemos-secrets tar czf payload.tar.gz IMGBUILD files anemos-secrets keys repositories rm -rf anemos-secrets # Initialize a new host init host: (check host) (get-anemos host) (payload host) && (cleanup host) scp ./{{host}}/payload.tar.gz ./{{host}}/files/etc/anemos.conf root@$(cat ./{{host}}/ADDRESS): ssh root@$(cat ./{{host}}/ADDRESS) ./anemos -c anemos.conf # Deploy an existing host deploy host: (check host) (get-anemos host) (payload host) && (cleanup host) scp ./{{host}}/payload.tar.gz root@$(cat ./{{host}}/ADDRESS): ssh root@$(cat ./{{host}}/ADDRESS) mount /boot ssh root@$(cat ./{{host}}/ADDRESS) ./anemos