]>
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 | # This is a wrapper script which does some on-the-fly configuration of the | |
23 | # pppoe-server daemon, which does not support any configuration files. | |
24 | ||
25 | LOG_FACILITY="pppoe-server" | |
26 | . /usr/lib/network/functions | |
27 | ||
e9df08ad MT |
28 | # Read network settings |
29 | network_settings_read | |
30 | ||
999d659b MT |
31 | zone=${1} |
32 | assert zone_exists ${zone} | |
33 | ||
34 | action=${2} | |
35 | ||
36 | # Read the configuration file of this hook. | |
79b2155d | 37 | zone_config_settings_read_by_hook "${zone}" "pppoe-server" |
999d659b MT |
38 | assert isset SUBNET |
39 | ||
40 | pppd_options="${RUN_DIR}/${zone}/pppoe-server-options" | |
41 | pool_file="${RUN_DIR}/${zone}/pppoe-server-pool" | |
42 | ||
43 | case "${action}" in | |
44 | cleanup) | |
45 | # Cleanup all temporary files. | |
46 | rm -f ${pppd_options} ${pool_file} | |
47 | ||
48 | exit ${EXIT_OK} | |
49 | ;; | |
50 | ||
51 | *) | |
52 | # Don't let the server fork to background. | |
53 | pppoe_cmdline="-F" | |
54 | ||
55 | # Add the interface to listen to. | |
56 | pppoe_cmdline="${pppoe_cmdline} -I ${zone}" | |
57 | ||
999d659b MT |
58 | # Randomize session IDs. |
59 | pppoe_cmdline="${pppoe_cmdline} -r" | |
60 | ||
61 | # Add the service name. | |
62 | if isset SERVICE_NAME; then | |
63 | pppoe_cmdline="${pppoe_cmdline} -S ${SERVICE_NAME// /_}" | |
64 | fi | |
65 | ||
f94b87ab MT |
66 | # Add the max. number of sessions per MAC address. |
67 | if [ ${MAX_SESSIONS} -gt 0 ]; then | |
68 | pppoe_cmdline="${pppoe_cmdline} -x ${MAX_SESSIONS}" | |
69 | fi | |
70 | ||
999d659b | 71 | # Create the pppoe-server-options file. |
70c971ce SS |
72 | pppoe_server_options ${pppd_options} ${zone} \ |
73 | --dns-servers="${DNS_SERVERS}" | |
999d659b MT |
74 | pppoe_cmdline="${pppoe_cmdline} -O ${pppd_options}" |
75 | ||
76 | # Configure the IP addresses. | |
77 | local_address=$(ipv4_get_network ${SUBNET}) | |
78 | pppoe_cmdline="${pppoe_cmdline} -L ${local_address}" | |
79 | ||
80 | # Create the address pool. | |
81 | pppoe_server_poolfile ${pool_file} ${SUBNET} | |
82 | pppoe_cmdline="${pppoe_cmdline} -p ${pool_file}" | |
83 | ||
84 | log INFO "Starting pppoe-server daemon..." | |
85 | log DEBUG "pppoe-server options: ${pppoe_cmdline}" | |
86 | ||
87 | # Now exec the actual pppoe-server binary. | |
d4abb642 | 88 | exec /usr/sbin/pppoe-server ${pppoe_cmdline} |
999d659b MT |
89 | |
90 | error "Could not execute pppoe-server. Exiting." | |
91 | exit ${EXIT_ERROR} | |
92 | ;; | |
93 | esac | |
94 | ||
95 | exit ${EXIT_ERROR} |