fix(deploy): fix permissions on /persist/home/rafiq

This commit is contained in:
Mohammad Rafiq 2025-04-02 03:51:05 +08:00
parent a4c2792865
commit 4264c2c7c5
No known key found for this signature in database

View file

@ -37,8 +37,45 @@ sudo cp --verbose --archive --parents /home/rafiq/.config/sops/age/keys.txt "${r
sudo nix run github:nix-community/nixos-anywhere -- \
--flake "${flake}" \
--target-host "${target_host}" \
--copy-host-keys \
--extra-files "${root}" \
--chown /persist/home/rafiq 1000:100
--chown /persist/home/rafiq 1000:100 \
--chown /home/rafiq 1000:100
# Clean up the temporary directory
sudo rm -rf "$root"
# Wait for SSH to be back up
MAX_TRIES=60 # Maximum attempts
SLEEP_SECONDS=5 # Time to wait between attempts
tries=0
while true; do
tries=$((tries + 1))
# Check network reachability with ping
ping -c 1 "$(echo "${target_host}" | awk -F'@' '{print $NF}')" >/dev/null 2>&1 #Extract IP/hostname from username@host
if [ $? -eq 0 ]; then
# Network is reachable, try SSH
ssh -q -o "ConnectTimeout=5" "${target_host}" 'exit 0'
if [ $? -eq 0 ]; then
echo "SSH is up. Connecting..."
ssh "${target_host}" &&
nixos-rebuild switch --flake "${flake}" --use-remote-sudo --target-host "${target_host}"
exit 0
else
echo "SSH not yet available (attempt $tries/$MAX_TRIES). Waiting..."
fi
else
echo "Host is not reachable via ping (attempt $tries/$MAX_TRIES). Waiting..."
fi
if [ $tries -ge $MAX_TRIES ]; then
echo "Maximum attempts reached. SSH still not available."
exit 1
fi
sleep "$SLEEP_SECONDS"
done
echo "---DEPLOYMENT DONE!---"