]>
Commit | Line | Data |
---|---|---|
5b20e43a MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
1848564d | 5 | # Copyright (C) 2010 Michael Tremer & Christian Schmidt # |
5b20e43a MT |
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 | ||
c7ad7801 MT |
22 | function ppp_common_ip_pre_up() { |
23 | local zone=${1} | |
24 | shift | |
25 | ||
26 | if ! zone_exists ${zone}; then | |
27 | error "Zone '${zone}' does not exist." | |
28 | return ${EXIT_ERROR} | |
29 | fi | |
30 | ||
ff8ec5ef MT |
31 | red_db_from_ppp ${zone} |
32 | ||
c7ad7801 MT |
33 | # Request firewall reload |
34 | event_firewall_reload | |
35 | ||
36 | return ${EXIT_OK} | |
37 | } | |
38 | ||
39 | function ppp_common_ip_up() { | |
40 | local zone=${1} | |
41 | shift | |
42 | ||
43 | if ! zone_exists ${zone}; then | |
44 | error "Zone '${zone}' does not exist." | |
45 | return ${EXIT_ERROR} | |
46 | fi | |
47 | ||
ff8ec5ef MT |
48 | red_db_set ${zone} active 1 |
49 | red_routing_update ${zone} | |
50 | ||
c7ad7801 MT |
51 | # Emit interface-up event |
52 | event_interface_up ${zone} | |
53 | ||
54 | return ${EXIT_OK} | |
55 | } | |
56 | ||
57 | function ppp_common_ip_down() { | |
58 | local zone=${1} | |
59 | shift | |
60 | ||
61 | if ! zone_exists ${zone}; then | |
62 | error "Zone '${zone}' does not exist." | |
63 | return ${EXIT_ERROR} | |
64 | fi | |
65 | ||
059469a8 MT |
66 | # Save accounting information |
67 | ppp_accounting ${zone} | |
68 | ||
c7ad7801 MT |
69 | # Emit interface-up event |
70 | event_interface_down ${zone} | |
71 | ||
72 | return ${EXIT_OK} | |
73 | } | |
74 | ||
5b20e43a MT |
75 | function ppp_secret() { |
76 | local USER=${1} | |
77 | local SECRET=${2} | |
78 | local a | |
79 | local secret | |
80 | local user | |
81 | ||
82 | # Updateing secret file | |
83 | > ${PPP_SECRETS}.tmp | |
84 | while read user a secret; do | |
85 | if [ "'${USER}'" != "${user}" ]; then | |
86 | echo "${user} ${a} ${secret}" >> ${PPP_SECRETS}.tmp | |
87 | fi | |
88 | done < ${PPP_SECRETS} | |
89 | echo "'${USER}' * '${SECRET}'" >> ${PPP_SECRETS}.tmp | |
90 | cat ${PPP_SECRETS}.tmp > ${PPP_SECRETS} | |
91 | rm -f ${PPP_SECRETS}.tmp | |
92 | } | |
93 | ||
059469a8 MT |
94 | function ppp_accounting() { |
95 | local zone=${1} | |
96 | shift | |
5b20e43a | 97 | |
059469a8 MT |
98 | db_ppp_update ${zone} --duration="${CONNECT_TIME}" \ |
99 | --rcvd="${BYTES_RCVD}" --sent="${BYTES_SENT}" | |
5b20e43a | 100 | } |