]> git.ipfire.org Git - people/stevee/network.git/blame - src/hooks/configs/ipv6-auto
Remove the function keyword which is a bashism
[people/stevee/network.git] / src / hooks / configs / ipv6-auto
CommitLineData
b73e9d43
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2010 Michael Tremer & Christian Schmidt #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22. /usr/lib/network/header-config
23
24HOOK_CONFIG_SETTINGS="HOOK PRIVACY_EXTENSIONS"
25
26# Privacy Extensions are disabled by default
27PRIVACY_EXTENSIONS="off"
28
1c6a4e30 29hook_check_config_settings() {
b73e9d43
MT
30 assert isbool PRIVACY_EXTENSIONS
31}
32
1c6a4e30 33hook_create() {
b73e9d43
MT
34 local zone="${1}"
35 shift
36
37 while read arg; do
38 case "${arg}" in
39 --privacy-extensions=*)
40 local val="$(cli_get_val "${arg}")"
41
42 if enabled val; then
43 PRIVACY_EXTENSIONS="on"
44 else
45 PRIVACY_EXTENSIONS="off"
46 fi
47 ;;
48 esac
49 done <<< "$(args $@)"
50
51 zone_config_settings_write "${zone}" "${HOOK}"
52
53 exit ${EXIT_OK}
54}
55
1c6a4e30 56hook_up() {
b73e9d43
MT
57 local zone=${1}
58 shift
59
60 if ! device_exists ${zone}; then
61 error "Zone '${zone}' doesn't exist."
62 exit ${EXIT_ERROR}
63 fi
64
65 zone_config_settings_read "${zone}" "${HOOK}"
66
67 # Enable IPv6 auto-configuration
68 ipv6_device_autoconf_enable "${zone}"
69
70 # Set up privacy extensions (RFC3041)
71 if enabled PRIVACY_EXTENSIONS; then
72 ipv6_device_privacy_extensions_enable "${zone}"
73 else
74 ipv6_device_privacy_extensions_disable "${zone}"
75 fi
76
77 exit ${EXIT_OK}
78}
79
1c6a4e30 80hook_down() {
b73e9d43
MT
81 local zone=${1}
82 local config=${2}
83 shift 2
84
85 if ! device_exists ${zone}; then
86 error "Zone '${zone}' doesn't exist."
87 exit ${EXIT_ERROR}
88 fi
89
90 # Disable IPv6 auto-configuration
91 ipv6_device_autoconf_disable "${zone}"
92
93 exit ${EXIT_OK}
94}
95
1c6a4e30 96hook_status() {
b73e9d43
MT
97 local zone=${1}
98 local config=${2}
99 shift 2
100
101 if ! device_exists ${zone}; then
102 error "Zone '${zone}' doesn't exist."
103 exit ${EXIT_ERROR}
104 fi
105
106 zone_config_settings_read "${zone}" "${config}"
107
108 local addresses=$(ipv6_device_get_addresses "${zone}" --scope="global")
109 local status
110 if isset addresses; then
111 status="${MSG_HOOK_UP}"
112 else
113 status="${MSG_HOOK_DOWN}"
114 fi
115 cli_statusline 3 "${HOOK}" "${status}"
116
117 if enabled PRIVACY_EXTENSIONS; then
118 cli_print_fmt1 3 "Privacy Extensions enabled"
119 cli_space
120 fi
121
122 local addr
123 for addr in ${addresses}; do
124 cli_print_fmt1 3 "IPv6 address" "${addr}"
125 done
126 cli_space
127
128 exit ${EXIT_OK}
129}