add dhcp to vastconnect + some subnets

This commit is contained in:
Lockszmith (@VAST) 2025-03-11 15:48:39 -04:00
parent f7d2944ed4
commit 9a15113955
1 changed files with 44 additions and 20 deletions

View File

@ -27,7 +27,6 @@ fi
TO="${1}" TO="${1}"
IFACE="${IFACE:-en9}" IFACE="${IFACE:-en9}"
SLEEP="${SLEEP:-3s}"
PINGOK=1 PINGOK=1
CMDs=("${@:2}") CMDs=("${@:2}")
@ -52,24 +51,43 @@ if _ping &>/dev/null; then
printf "Connection detected.\n" printf "Connection detected.\n"
else else
PINGOK=0 PINGOK=0
case "${TO}" in if [ "${FROM:-${2:-}}" == "dhcp" ]; then
10.117.10.*) FROM=dhcp
FROM=10.117.10.254 FROM_SN=auto
FROM_SN=255.255.255.0 SLEEP="${SLEEP:-15s}"
;; else
192.168.1.*) SLEEP="${SLEEP:-3s}"
FROM=192.168.1.254 case "${TO}" in
FROM_SN=255.255.255.0 10.117.10.*)
;; FROM=10.117.10.254
192.168.2.*) FROM_SN=255.255.255.0
FROM=192.168.2.254 ;;
FROM_SN=255.255.255.0 192.168.1.*)
;; FROM=192.168.1.254
*) FROM_SN=255.255.255.0
FROM=${FROM:?FROM and FROM_SN Must be supplied for unknown IPv4 destination $1} ;;
FROM_SN${FROM_SN:?FROM and FROM_SN Must be supplied for unknown IPv4 destination $1} 192.168.2.*)
;; FROM=192.168.2.254
esac FROM_SN=255.255.255.0
;;
169.254.1.*)
FROM=169.254.1.15
FROM_SN=255.255.255.224
;;
169.254.111.*)
FROM=169.254.111.15
FROM_SN=255.255.255.224
;;
169.254.3.*)
FROM=169.254.3.254
FROM_SN=255.255.255.0
;;
*)
FROM=${FROM:-${2:?FROM and FROM_SN Must be supplied for unknown IPv4 destination $1}}
FROM_SN=${FROM_SN:?FROM and FROM_SN Must be supplied for unknown IPv4 destination $1}
;;
esac
fi
MYIP='' MYIP=''
MYIP="$(_myip)" MYIP="$(_myip)"
@ -81,7 +99,13 @@ else
echo "$MYIP detected on $IFACE, Setting up $FROM / $FROM_SN - \`sudo\` might be prompting you for your password" echo "$MYIP detected on $IFACE, Setting up $FROM / $FROM_SN - \`sudo\` might be prompting you for your password"
sudo ipconfig set "${IFACE}" manual "${FROM}" "${FROM_SN}" \ if [ "${FROM}" == "dhcp" ]; then
sudo ipconfig set "${IFACE}" bootp || true
sudo ipconfig set "${IFACE}" dhcp
else
sudo ipconfig set "${IFACE}" manual "${FROM}" "${FROM_SN}"
fi \
&& printf 'Waiting %s...' "${SLEEP}" \
&& sleep "${SLEEP}" \ && sleep "${SLEEP}" \
&& MYIP="$(_myip)" && MYIP="$(_myip)"
fi fi