local commands="discover monitor status unlock ussd"
local cmd="$(_network_find_on_cmdline "${commands}")"
-
if [[ -z "${cmd}" ]]; then
- COMPREPLY=( $(compgen -W "discover monitor status unlock ussd" \
- -- "${cur}") )
+ COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
return 0
fi
esac
}
+function _network_dns_server() {
+ local words=( $@ )
+
+ local commands="add list remove update"
+ local cmd="$(_network_find_on_cmdline "${commands}")"
+ if [[ -z "${cmd}" ]]; then
+ COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+ return 0
+ fi
+
+ case "${cmd}" in
+ remove)
+ COMPREPLY=( $(compgen -W "$(network raw list-dns-servers)" \
+ -- "${cur}") )
+ ;;
+ esac
+}
+
function _network_port() {
local words=( $@ )
fi
}
+function _network_route() {
+ local words=( $@ )
+
+ local commands="add list remove"
+ local cmd="$(_network_find_on_cmdline "${commands}")"
+ if [[ -z "${cmd}" ]]; then
+ COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+ return 0
+ fi
+
+ case "${cmd}" in
+ add)
+ if [[ "${cur}" = -* ]]; then
+ COMPREPLY=( $(compgen -W "--blackhole --gateway= --mtu= \
+ --prohibit --unreachable" -- "${cur}") )
+ fi
+ ;;
+ list)
+ # TODO auto-complete options like --protocol here
+ COMPREPLY=( $(compgen -W "--protocol=" -- "${cur}") )
+ ;;
+ esac
+}
+
function _network_settings() {
local words=( $@ )
COMPREPLY=( $(compgen -W "--debug" -- "${cur}") )
;;
*)
- COMPREPLY=( $(compgen -W "device hostname port settings status zone" \
- -- "${cur}") )
+ COMPREPLY=( $(compgen -W "device dns-server help hostname \
+ port reset route settings status zone" -- "${cur}") )
;;
esac
device)
_network_device ${args}
;;
+ dns-server)
+ _network_dns_server ${args}
+ ;;
port)
_network_port ${args}
;;
+ route)
+ _network_route ${args}
+ ;;
settings)
_network_settings ${args}
;;
local line
local ${NETWORK_CONFIG_DNS_SERVER_PARAMS}
-
- local format="%-20s %-8s"
- print "${format}" "SERVER" "PRIORITY"
-
- while read -r line; do
+ while read line; do
dns_server_parse_line ${line} || continue
- print "${format}" "${server}" "${priority}"
+ print "${server}"
done < ${DNS_SERVER_CONFIG_FILE}
return ${EXIT_OK}
return ${EXIT_OK}
}
+function dns_server_show() {
+ [ -r "${DNS_SERVER_CONFIG_FILE}" ] || return ${EXIT_OK}
+
+ local line
+ local ${NETWORK_CONFIG_DNS_SERVER_PARAMS}
+
+ local format="%-20s %-8s"
+ print "${format}" "SERVER" "PRIORITY"
+
+ while read -r line; do
+ dns_server_parse_line ${line} || continue
+
+ print "${format}" "${server}" "${priority}"
+ done < ${DNS_SERVER_CONFIG_FILE}
+
+ return ${EXIT_OK}
+}
+
function dns_server_add() {
local server=${1}
assert isset server