-
-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathunset-static-ip
More file actions
executable file
·80 lines (68 loc) · 1.7 KB
/
unset-static-ip
File metadata and controls
executable file
·80 lines (68 loc) · 1.7 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
#
# Reverts any changes made by the set-static-ip script.
# Exit on first error.
set -e
print_help() {
cat << EOF
Usage: ${0##*/} [--quiet] [--help]
Reverts any changes made by the set-static-ip script.
--quiet: Suppress the confirmation message.
--help: Display this help text.
EOF
}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
readonly SCRIPT_DIR
# shellcheck source=lib/markers.sh
. "${SCRIPT_DIR}/lib/markers.sh"
# Parse command-line arguments.
if ! NEW_ARGS=$(getopt -q -o "" -l "quiet,help,interface:" -- "$@"); then
print_help
exit 1
fi
# Process command-line arguments.
eval set -- "${NEW_ARGS}"
while true; do
case "$1" in
--quiet)
readonly QUIET="true"
shift 1
;;
--interface)
# See https://github.com/tiny-pilot/tinypilot/issues/1710#issuecomment-1885680744.
echo 'The --interface flag is no longer supported' >&2
exit 1
;;
--help)
print_help
exit
;;
--)
shift
break
;;
esac
done
# Default to not quiet.
if [[ -z "${QUIET}" ]] ; then
readonly QUIET="false"
fi
# Exit on unset variable
set -u
# Determine which version of the OS is running.
OS_VERSION="$(lsb_release --release --short)"
if [[ "${OS_VERSION}" == 11 ]]; then
# Remove any existing marker sections from the config file.
"${SCRIPT_DIR}/strip-marker-sections" /etc/dhcpcd.conf
else
nmcli connection modify 'Wired connection 1' \
ipv4.method auto \
ipv4.addresses '' \
ipv4.gateway '' \
ipv4.dns ''
fi
# Apply changes.
"${SCRIPT_DIR}/apply-static-ip"
if [[ "${QUIET}" == "false" ]] ; then
echo "Any changes made by the set-static-ip script have been reverted."
fi