]> git.ipfire.org Git - people/stevee/network.git/blame - hooks/zones/bridge.configs/pppoe-server
pppoe-server: New (client) hook.
[people/stevee/network.git] / hooks / zones / bridge.configs / pppoe-server
CommitLineData
999d659b
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_SETTINGS="HOOK MTU SERVICE_NAME SUBNET"
25
26# Maximum Transmission Unit.
27MTU=1492
28
29# Service Name.
30SERVICE_NAME=
31
32# A subnet. Addresses from this subnet will be given to the remote hosts.
33# The net address will be the gateway address for the PPPoE server.
34SUBNET=
35
36function _check() {
37 assert isset MTU
38 assert isset SUBNET
39}
40
41function _create() {
42 local zone=${1}
43 shift
44
45 while [ $# -gt 0 ]; do
46 case "${1}" in
47 --mtu=*)
48 MTU=$(cli_get_val ${1})
49 ;;
50 --service-name=*)
51 SERVICE_NAME=$(cli_get_val ${1})
52 ;;
53 --subnet=*)
54 SUBNET=$(cli_get_val ${1})
55 ;;
56 esac
57 shift
58 done
59
60 config_write $(zone_dir ${zone})/configs/${HOOK} ${HOOK_SETTINGS}
61
62 exit ${EXIT_OK}
63}
64
65function _up() {
66 local zone=${1}
67 local config=${2}
68 shift 2
69
70 # Start the PPPoE server.
71 pppoe_server_start ${zone}
72
73 exit ${EXIT_OK}
74}
75
76function _down() {
77 local zone=${1}
78 local config=${2}
79 shift 2
80
81 if ! device_exists ${zone}; then
82 error "Zone '${zone}' doesn't exist."
83 exit ${EXIT_ERROR}
84 fi
85
86 # Stop the PPPoE server.
87 pppoe_server_stop ${zone}
88
89 exit ${EXIT_OK}
90}
91
92function _status() {
93 local zone=${1}
94 local config=${2}
95 shift 2
96
97 if ! device_exists ${zone}; then
98 error "Zone '${zone}' doesn't exist."
99 exit ${EXIT_ERROR}
100 fi
101
102 config_read $(zone_dir ${zone})/configs/${config}
103
104 local status
105 if pppoe_server_status ${zone}; then
106 status="${MSG_HOOK_UP}"
107 else
108 status="${MSG_HOOK_DOWN}"
109 fi
110 cli_statusline 3 "PPPoE server" "${status}"
111
112 exit ${EXIT_OK}
113}