# conflict with any functions that were defined somewhere else.
#
-. /lib/network/functions
+. /usr/lib/network/functions
HOOK=$(basename ${0})
exit ${DISCOVER_NOT_SUPPORTED}
}
+# The default help function.
+function _help() {
+ # If no man page has been configured, we print an error message.
+ if [ -z "${HOOK_MANPAGE}" ]; then
+ error "There is no help available for hook '${HOOK}'. Exiting."
+ exit ${EXIT_ERROR}
+ fi
+
+ cli_show_man ${HOOK_MANPAGE}
+}
+
# Do nothing
function _parse_cmdline() {
return ${EXIT_OK}
_${action} $@
;;
+ # Help requested by the user.
+ help)
+ _help $@
+ ;;
+
*)
error "Unknown action: ${action}"
;;
.RE
.PP
+\fBhelp [<type> <hook>]\fR
+.RS 4
+Running "network help" without any arguments will show you this man page.
+.PP
+You may optionally give two arguments, to view the help of a certain hook.
+The type of the hook (\fB<type>\fR) needs to be passed as well as the
+name of the hook (\fB<hook>\fR).
+.RE
+.PP
+
\fBhostname [new-hostname]\fR
.RS 4
The \fBhostname\fR command will return the currently configured hostname of the system.
exit ${EXIT_OK}
}
+# Help function: will show the default man page to the user.
+# Optionally, there are two arguments taken, the type of hook
+# and which hook should be shown.
+function cli_help() {
+ local type=${1}
+ local what=${2}
+
+ # Remove unknown types.
+ if ! listmatch ${type} zone port config; then
+ type=""
+ fi
+
+ # If no arguments were given, we will show the default page.
+ if [ -z "${type}" ]; then
+ cli_show_man network
+ return ${EXIT_OK}
+ fi
+
+ if ! hook_exists ${type} ${what}; then
+ error "Hook of type '${type}' and name '${what}' could not be found."
+ exit "${EXIT_ERROR}"
+ fi
+
+ hook_exec ${type} ${what} help
+}
+
# Process the given action
case "${action}" in
init)
;;
""|help|--help|-h)
- cli_show_man network
- exit ${EXIT_OK}
+ cli_help $@
;;
*)
exit ${EXIT_CONF_ERROR}
;;
esac
+
+exit ${EXIT_OK}