fixing PATH in pimox worker

This commit is contained in:
juvdiaz 2026-07-02 11:12:57 -06:00
parent cfcfc39f1f
commit 77e31bba0b
1 changed files with 21 additions and 9 deletions

30
jeannie
View File

@ -1584,17 +1584,29 @@ configure_pimox_worker_forwarding() {
worker_address="${worker_ip%%/*}" worker_address="${worker_ip%%/*}"
pimox_ssh "${pimox_host}" "${pimox_user}" "${pimox_key}" "set -eu pimox_ssh "${pimox_host}" "${pimox_user}" "${pimox_key}" "set -eu
if ! command -v iptables >/dev/null 2>&1; then iptables_bin=\"\$(command -v iptables 2>/dev/null || true)\"
if [ -z \"\$iptables_bin\" ] && [ -x /usr/sbin/iptables ]; then
iptables_bin=/usr/sbin/iptables
fi
if [ -z \"\$iptables_bin\" ]; then
if command -v apt-get >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then
echo 'iptables not found on Pimox host; installing iptables for worker forwarding rules.' echo 'iptables not found on Pimox host; installing iptables for worker forwarding rules.'
sudo apt-get update sudo apt-get update
sudo apt-get install -y --no-install-recommends iptables sudo apt-get install -y --no-install-recommends iptables
fi fi
fi fi
if ! command -v iptables >/dev/null 2>&1; then iptables_bin=\"\$(command -v iptables 2>/dev/null || true)\"
if [ -z \"\$iptables_bin\" ] && [ -x /usr/sbin/iptables ]; then
iptables_bin=/usr/sbin/iptables
fi
if [ -z \"\$iptables_bin\" ]; then
echo 'iptables not found on Pimox host and could not be installed; cannot configure worker forwarding rules.' >&2 echo 'iptables not found on Pimox host and could not be installed; cannot configure worker forwarding rules.' >&2
exit 1 exit 1
fi fi
iptables_save_bin=\"\$(command -v iptables-save 2>/dev/null || true)\"
if [ -z \"\$iptables_save_bin\" ] && [ -x /usr/sbin/iptables-save ]; then
iptables_save_bin=/usr/sbin/iptables-save
fi
backup_dir='${backup_dir}' backup_dir='${backup_dir}'
case \"\$backup_dir\" in case \"\$backup_dir\" in
'~'|'~/') backup_dir=\"\$HOME\" ;; '~'|'~/') backup_dir=\"\$HOME\" ;;
@ -1602,22 +1614,22 @@ case \"\$backup_dir\" in
esac esac
mkdir -p \"\$backup_dir\" mkdir -p \"\$backup_dir\"
backup_file=\"\$backup_dir/iptables-before-jeannie-workers-\$(date +%Y%m%d-%H%M%S).rules\" backup_file=\"\$backup_dir/iptables-before-jeannie-workers-\$(date +%Y%m%d-%H%M%S).rules\"
if command -v iptables-save >/dev/null 2>&1; then if [ -n \"\$iptables_save_bin\" ]; then
sudo iptables-save >\"\$backup_file\" sudo \"\$iptables_save_bin\" >\"\$backup_file\"
echo \"Saved Pimox iptables backup: \$backup_file\" echo \"Saved Pimox iptables backup: \$backup_file\"
fi fi
sudo mkdir -p /etc/sysctl.d sudo mkdir -p /etc/sysctl.d
printf '%s\n' 'net.ipv4.ip_forward = 1' | sudo tee /etc/sysctl.d/99-homelab-pimox-worker-forwarding.conf >/dev/null printf '%s\n' 'net.ipv4.ip_forward = 1' | sudo tee /etc/sysctl.d/99-homelab-pimox-worker-forwarding.conf >/dev/null
sudo sysctl -w net.ipv4.ip_forward=1 >/dev/null sudo sysctl -w net.ipv4.ip_forward=1 >/dev/null
chain=FORWARD chain=FORWARD
if sudo iptables -S DOCKER-USER >/dev/null 2>&1; then if sudo \"\$iptables_bin\" -S DOCKER-USER >/dev/null 2>&1; then
chain=DOCKER-USER chain=DOCKER-USER
fi fi
if ! sudo iptables -C \"\$chain\" -s '${worker_address}/32' -j ACCEPT 2>/dev/null; then if ! sudo \"\$iptables_bin\" -C \"\$chain\" -s '${worker_address}/32' -j ACCEPT 2>/dev/null; then
sudo iptables -I \"\$chain\" 1 -s '${worker_address}/32' -j ACCEPT sudo \"\$iptables_bin\" -I \"\$chain\" 1 -s '${worker_address}/32' -j ACCEPT
fi fi
if ! sudo iptables -C \"\$chain\" -d '${worker_address}/32' -j ACCEPT 2>/dev/null; then if ! sudo \"\$iptables_bin\" -C \"\$chain\" -d '${worker_address}/32' -j ACCEPT 2>/dev/null; then
sudo iptables -I \"\$chain\" 1 -d '${worker_address}/32' -j ACCEPT sudo \"\$iptables_bin\" -I \"\$chain\" 1 -d '${worker_address}/32' -j ACCEPT
fi fi
echo \"Pimox worker forwarding rules active in \$chain for ${worker_address}\"" echo \"Pimox worker forwarding rules active in \$chain for ${worker_address}\""
} }