]> git.ipfire.org Git - people/ms/network.git/blame_incremental - src/helpers/pppd-angel
ip-tunnel: Enable support for 6in4 tunnels
[people/ms/network.git] / src / helpers / pppd-angel
... / ...
CommitLineData
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2013 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. /usr/lib/network/functions
23
24# Read network settings
25network_settings_read
26
27main() {
28 local zone="${1}"
29 assert isset zone
30
31 if ! zone_exists "${zone}"; then
32 log ERROR "Must pass valid zone: ${zone}"
33 return ${EXIT_ERROR}
34 fi
35
36 # Find the hook of the zone, we got.
37 local hook="$(zone_get_hook "${zone}")"
38 assert isset hook
39
40 # Write pppd configuration file.
41 local config_file="${RUN_DIR}/ppp/${zone}/pppd.conf"
42 hook_exec zone "${hook}" "ppp_write_config" "${zone}" "${config_file}"
43
44 # Create trap function
45 function cleanup() {
46 rm -f "${config_file}"
47 }
48 trap "cleanup" EXIT TERM KILL
49
50 # Start the angel process.
51 pppd_angel "${zone}" "${config_file}" \
52 --holdoff-time="10"
53}
54
55main "$@" || exit $?
56
57exit ${EXIT_OK}