-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathunset-static-ip
executable file
·69 lines (58 loc) · 1.43 KB
/
unset-static-ip
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
#!/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
# Remove any existing marker sections from the config file.
"${SCRIPT_DIR}/strip-marker-sections" /etc/dhcpcd.conf
# 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