]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/hooks/zones/pppoe
Convert HOOK_SETTINGS into an array
[people/stevee/network.git] / src / hooks / zones / pppoe
index 865bbc59fb4e4648169075db474a07532c9688eb..4f7ae51596d41e7bfdd8c74b76ab3d0c10c4f299 100644 (file)
 
 . /usr/lib/network/header-zone
 
-HOOK_SETTINGS="HOOK ACCESS_CONCENTRATOR AUTH USERNAME PASSWORD"
-HOOK_SETTINGS="${HOOK_SETTINGS} SERVICE_NAME MTU IPV6 PREFIX_DELEGATION"
-
-# User credentials for the dialin.
-USERNAME=""
-PASSWORD=""
-
-# Set the authentication mechanism.
-AUTH=
-
-# Access Concentrator.
-ACCESS_CONCENTRATOR=""
-
-# Service name.
-SERVICE_NAME=""
-
-# Maximum Transmission Unit.
-# 1492 is a very common value for that.
-MTU=1492
+HOOK_SETTINGS=(
+       "ACCESS_CONCENTRATOR"
+       "AUTH"
+       "USERNAME"
+       "PASSWORD"
+       "SERVICE_NAME"
+       "MTU"
+       "IPV6"
+       "PREFIX_DELEGATION"
+)
 
 # This hook can work with all authentication methods supported by pppd.
 PPPOE_SUPPORTED_AUTH_METHODS="${PPP_SUPPORTED_AUTH_METHODS}"
 PPPOE_PLUGIN="rp-pppoe.so"
 
 # Request an IPv6 address.
-IPV6="true"
+DEFAULT_IPV6="true"
 
 # Use IPv6 prefix delegation.
-PREFIX_DELEGATION="true"
+DEFAULT_PREFIX_DELEGATION="true"
 
 hook_check_settings() {
        assert isset USERNAME
@@ -65,10 +56,10 @@ hook_parse_cmdline() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --access-concentrator=*)
-                               ACCESS_CONCENTRATOR=$(cli_get_val ${1})
+                               ACCESS_CONCENTRATOR=$(cli_get_val "${1}")
                                ;;
                        --auth=*)
-                               AUTH=$(cli_get_val ${1})
+                               AUTH=$(cli_get_val "${1}")
                                ;;
                        --ipv6=*)
                                local value="$(cli_get_val "${1}")"
@@ -79,19 +70,19 @@ hook_parse_cmdline() {
                                fi
                                ;;
                        --mtu=*)
-                               MTU=$(cli_get_val ${1})
+                               MTU=$(cli_get_val "${1}")
                                ;;
                        --password=*)
-                               PASSWORD=$(cli_get_val ${1})
+                               PASSWORD=$(cli_get_val "${1}")
                                ;;
                        --prefix-delegation=*)
                                PREFIX_DELEGATION="$(cli_get_bool "${1}")"
                                ;;
                        --service-name=*)
-                               SERVICE_NAME=$(cli_get_val ${1})
+                               SERVICE_NAME=$(cli_get_val "${1}")
                                ;;
                        --username=*)
-                               USERNAME=$(cli_get_val ${1})
+                               USERNAME=$(cli_get_val "${1}")
                                ;;
                        *)
                                warning "Unknown argument: ${1}" >&2
@@ -364,6 +355,36 @@ hook_port_detach() {
        exit ${EXIT_OK}
 }
 
+hook_port_up() {
+       assert [ $# -eq 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       # Try bringing up the port if it has not been brought up before
+       if ! device_exists "${port}"; then
+               port_create "${port}"
+       fi
+
+       # Make sure that the port is up
+       port_up "${port}"
+
+       exit ${EXIT_OK}
+}
+
+hook_port_down() {
+       assert [ $# -eq 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       if device_exists "${port}"; then
+               port_down "${port}"
+       fi
+
+       exit ${EXIT_OK}
+}
+
 hook_ppp_ipv6_up() {
        local zone="${1}"