updated on Thu Jan 19 16:10:29 UTC 2012
[aur-mirror.git] / pgl-nogui / if-up
blob1e367129cc75e0e048e10a774f46b1d0ec53120f
1 #!/bin/sh
2 # if-up - insert pglcmd iptables whitelisting rules for newly brought up
3 # interfaces.
4 # Copyright (C) 2008 - 2010 jre <jre-phoenix@users.sourceforge.net>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 # If used with NetworkManager, then only continue if an interface is brought up
21 # (not down). Ignored if this file is used otherwise (e.g. /etc/network/if-up.d
22 # in Debian).
23 if [ "$(dirname $0)" = /etc/NetworkManager/dispatcher.d ] ; then
24 [ "$2" = up ] || [ "$2" = vpn-up ] || exit 0
27 ################################################################################
28 # The following code is common between pglcmd, pglcmd.wd,
29 # cron.daily, init and debian/postinst.
31 # if-up is similar, but exits successfully if CONTROL_MAIN is not there, yet.
32 # This can happen in early boot stages before local file systems are mounted.
34 # CONTROL_MAIN has to be set correctly in all just mentioned files.
35 CONTROL_MAIN="/usr/lib/pgl/pglcmd.main"
37 # Configure pglcmd and load functions.
38 if [ -f "$CONTROL_MAIN" ] ; then
39 . $CONTROL_MAIN || { echo "$0 Error: Failed to source $CONTROL_MAIN although this file exists."; exit 1; }
40 else
41 exit 0
44 # End of the common code between pglcmd, pglcmd.wd,
45 # cron.daily, (if-up), init and debian/postinst.
46 ################################################################################
48 test_root
49 # If the daemon is not running, just exit gracefully:
50 status_of_proc $DAEMON $NAME > /dev/null 2>&1 || exit 0
51 test_IPTABLES_VARS
52 # Exit if user doesn't want automatic whitelisting:
53 [ "$IPTABLES_SETTINGS" -eq 0 ] && exit 0
54 [ "$WHITE_LOCAL" -eq 0 ] && exit 0
55 test_DAEMON
56 test_CMD_PATHNAME
57 test_external iptables || exit $?
59 # Automatically whitelist LAN of all up interfaces, loopback interface
60 # and DNS server(s) (if configured)
61 date +%F" "%X" "%Z" Begin: $0 whitelisting LAN" >> $CMD_LOG 2>&1
62 white_local >> $CMD_LOG 2>&1
63 date +%F" "%X" "%Z" End: $0 whitelisting LAN" >> $CMD_LOG 2>&1
65 exit 0