-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_dynamic_ip.sh
More file actions
executable file
·47 lines (39 loc) · 1.07 KB
/
set_dynamic_ip.sh
File metadata and controls
executable file
·47 lines (39 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# MotionNode POE: Set dynamic ip script
# This script will ssh in to a network connected MotionNode POE device
# and set a new network configuration enabling DHCP, removing any
# static ip address assignment.
# parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--host)
HOST="$2"
shift # Past argument
shift # Past value
;;
--help)
echo "Usage: $0 --host <device_hostname_or_ip>"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
if [ "${HOST}" == "" ] ; then
echo "Usage: $0 --host <device_hostname_or_ip>"
exit 1
fi
echo "Setting networking config for host ${HOST}"
echo "Dynamic IP using DHCP."
CMD1="sudo rm /etc/netplan/*.yaml &> /dev/null"
CMD2="sudo netplan apply"
CMD3="sudo nmcli connection modify \"Wired connection 1\" ipv4.method auto"
SSH_CMD="ssh -t remote@${HOST} ${CMD1}; ${CMD2}; ${CMD3}"
${SSH_CMD}
if [ $? -eq 0 ]; then
echo "New networking config set. Please power cycle the MotionNode POE device now."
else
echo "Error setting networking config."
fi