forked from poddmo/ufw-blocklist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
after.init_run-parts
64 lines (61 loc) · 1.92 KB
/
after.init_run-parts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
#
# after.init: if executable, called by ufw-init. See 'man ufw-framework' for
# details. Note that output from these scripts is not seen via the
# the ufw command, but instead via ufw-init.
#
# Copyright 2013 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ufw-blocklist dynamic edition: IP blocklist extension for Ubuntu ufw
# https://github.com/poddmo/ufw-blocklist
#
# Install this script executable as /etc/ufw/after.init
# Install user scripts to be run after ufw has initialised into /etc/ufw/after.init.d/
# ** Scripts will run with ufw privilege, ie root **
# Script names must match the filename format: numbernumber-*.ufw
# Order of execution is critical. Lower (00) numbered scripts will execute first
# Higher numbered scripts have higher precedence
# Example filenames: 10-ipblocklist-ipsum.ufw, 20-subnetblocklist.ufw
#
set -e
afterinitdir='/etc/ufw/after.init.d'
if [ ! -d "$afterinitdir" ];
then
echo "$afterinitdir does not exist. nothing to do"
exit 0
fi
runpartsfunc ()
{
run-parts --report --regex='^[0-9]{2}-.*.ufw$' --arg="$1" "${afterinitdir}"
exit $?
}
case "$1" in
start)
runpartsfunc start
;;
stop)
runpartsfunc stop
;;
status)
runpartsfunc status
;;
flush-all)
runpartsfunc flush-all
;;
*)
echo "'$1' not supported"
echo "Usage: after.init {start|stop|flush-all|status}"
;;
esac