]>
Commit | Line | Data |
---|---|---|
999d659b MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2012 IPFire Network Development Team # | |
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 | function pppoe_server_start() { | |
23 | local zone=${1} | |
24 | assert isset zone | |
25 | ||
26 | service_start "pppoe-server@${zone}" | |
27 | } | |
28 | ||
29 | function pppoe_server_stop() { | |
30 | local zone=${1} | |
31 | assert isset zone | |
32 | ||
33 | service_stop "pppoe-server@${zone}" | |
34 | } | |
35 | ||
36 | function pppoe_server_status() { | |
37 | local zone=${1} | |
38 | assert isset zone | |
39 | ||
40 | service_status "pppoe-server@${zone}" | |
41 | } | |
42 | ||
43 | function pppoe_server_options() { | |
44 | local file=${1} | |
45 | assert isset file | |
46 | ||
47 | local zone=${2} | |
48 | assert isset zone | |
49 | ||
50 | shift 2 | |
51 | ||
52 | local auth="false" | |
53 | local default_asyncmap="true" | |
54 | local dns_servers | |
55 | local lcp_echo_failure=5 | |
56 | local lcp_echo_interval=60 | |
57 | local proxyarp="true" | |
58 | local required_auths | |
59 | local value | |
60 | ||
61 | while [ $# -gt 0 ]; do | |
62 | case "${1}" in | |
63 | --auth=*) | |
64 | auth=$(cli_get_val ${1}) | |
65 | ;; | |
66 | --default-asyncmap=*) | |
67 | default_asyncmap=$(cli_get_val ${1}) | |
68 | ;; | |
69 | --dns-server=*) | |
70 | dns_servers="${dns_servers} $(cli_get_val ${1})" | |
71 | ;; | |
72 | --lcp-echo-failure=*) | |
73 | lcp_echo_failure=$(cli_get_val ${1}) | |
74 | assert isinteger ${lcp_echo_failure} | |
75 | ;; | |
76 | --lcp-echo-interval=*) | |
77 | lcp_echo_interval=$(cli_get_val ${1}) | |
78 | assert isinteger ${lcp_echo_interval} | |
79 | ;; | |
80 | --proxyarp=*) | |
81 | proxyarp=$(cli_get_val ${1}) | |
82 | ;; | |
83 | --require-auth=*) | |
84 | required_auths="${required_auths} $(cli_get_val ${1})" | |
85 | ;; | |
86 | esac | |
87 | shift | |
88 | done | |
89 | ||
90 | mkdir -p $(dirname ${file}) 2>/dev/null | |
91 | config_header "pppoe-server options configuration file" > ${file} | |
92 | ||
93 | # Authentication | |
94 | ( | |
95 | print "# Authentication" | |
96 | if enabled auth; then | |
97 | print "auth" | |
98 | else | |
99 | print "noauth" | |
100 | fi | |
101 | ||
102 | ) >> ${file} | |
103 | ||
104 | # If there are only a number of auth algorithms allowed, we | |
105 | # define them here. | |
106 | if isset required_auths; then | |
107 | print "# Required authentication methods" >> ${file} | |
108 | local method | |
109 | for method in ${required_auths}; do | |
110 | print "require-${method}" | |
111 | done >> ${file} | |
112 | print >> ${file} | |
113 | fi | |
114 | ||
115 | # DNS servers | |
116 | if isset dns_servers; then | |
117 | print "# DNS servers" >> ${file} | |
118 | local server | |
119 | for server in ${dns_servers}; do | |
120 | print "ms-dns ${server}" | |
121 | done >> ${file} | |
122 | print >> ${file} | |
123 | fi | |
124 | ||
125 | # Default asyncmap | |
126 | if enabled default_asyncmap; then | |
127 | ( | |
128 | print "# Default asyncmap" | |
129 | print "default-asyncmap" | |
130 | ||
131 | ) >> ${file} | |
132 | fi | |
133 | ||
134 | # LCP settings. | |
135 | ( | |
136 | print "# LCP settings" | |
137 | print "lcp-echo-failure ${lcp_echo_failure}" | |
138 | print "lcp-echo-interval ${lcp_echo_interval}" | |
139 | ||
140 | ) >> ${file} | |
141 | ||
142 | # Proxy ARP | |
143 | ( | |
144 | print "# Proxy ARP" | |
145 | if enabled proxyarp; then | |
146 | print "proxyarp" | |
147 | else | |
148 | print "noproxyarp" | |
149 | fi | |
150 | ||
151 | ) >> ${file} | |
152 | ||
153 | # Default options, we always set. | |
154 | ( | |
155 | print "debug" | |
156 | print "nodefaultroute" | |
157 | print "noipdefault" | |
158 | print "noipx" | |
159 | ) >> ${file} | |
160 | ||
161 | return ${EXIT_OK} | |
162 | } | |
163 | ||
164 | function pppoe_server_poolfile() { | |
165 | local file=${1} | |
166 | assert isset file | |
167 | ||
168 | local subnet=${2} | |
169 | assert isset subnet | |
170 | ||
171 | config_header "PPPoE server IP address pool file" > ${file} | |
172 | ||
173 | # The network address will be the gateway address. | |
174 | local netaddr=$(ipv4_get_network ${subnet}) | |
175 | ||
176 | local addr | |
177 | for addr in $(ipv4_range_explicit ${subnet}); do | |
178 | [ "${addr}" = "${netaddr}" ] && continue | |
179 | print "${addr}" | |
180 | done >> ${file} | |
181 | ||
182 | return ${EXIT_OK} | |
183 | } |