Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
c832ed1ef3 | ||
|
5e09834811 |
6 changed files with 77 additions and 16 deletions
36
cdist/conf/type/__fail2ban/gencode-remote
Normal file
36
cdist/conf/type/__fail2ban/gencode-remote
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2016 Simon Walter (simon at explicit dot technology)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist 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 cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
config_file="/etc/fail2ban/jail.conf"
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/enable-jails" ]; then
|
||||||
|
enable_jails="$(cat "$__object/parameter/enable-jails")"
|
||||||
|
else
|
||||||
|
enable_jails="$__object_id"
|
||||||
|
fi
|
||||||
|
jails="$(echo $enable_jails | sed -e 's/,/ /g')"
|
||||||
|
for jail in $jails
|
||||||
|
do
|
||||||
|
echo "Enabling fail2ban for $jail..." >&2
|
||||||
|
cat << EOF
|
||||||
|
perl -i -pe 'BEGIN{undef $/;} s/\[$jail\].*[\n]*enabled.*=.*\n/\[$jail\]\n\nenabled = true\n/g' $config_file
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
echo "service fail2ban restart"
|
39
cdist/conf/type/__fail2ban/manifest
Normal file
39
cdist/conf/type/__fail2ban/manifest
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2016 Simon Walter (simon at explicit dot technology)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist 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 cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
os=$(cat "$__global/explorer/os")
|
||||||
|
|
||||||
|
case "$os" in
|
||||||
|
debian|ubuntu|devuan)
|
||||||
|
__package iptables --state present
|
||||||
|
require=__package/iptables __package fail2ban --state present
|
||||||
|
;;
|
||||||
|
centos)
|
||||||
|
__package epel-release --state present
|
||||||
|
require=__package/epel-release __package iptables --state present
|
||||||
|
require=__package/epel-release __package fail2ban --state present
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
||||||
|
echo "Please contribute an implementation for it if you can." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
1
cdist/conf/type/__fail2ban/parameter/optional
Normal file
1
cdist/conf/type/__fail2ban/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
enable-jails
|
|
@ -34,12 +34,3 @@ case "$os" in
|
||||||
echo "echo \"$timezone_should\" > /etc/timezone"
|
echo "echo \"$timezone_should\" > /etc/timezone"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$os" in
|
|
||||||
openwrt)
|
|
||||||
cat <<EOF
|
|
||||||
uci set system.@system[0].timezone="$timezone_should"
|
|
||||||
uci commit
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
|
@ -53,10 +53,7 @@ case "$os" in
|
||||||
--file /etc/sysconfig/clock \
|
--file /etc/sysconfig/clock \
|
||||||
--delimiter '=' \
|
--delimiter '=' \
|
||||||
--value "\"$timezone\""
|
--value "\"$timezone\""
|
||||||
;;
|
;;
|
||||||
openwrt)
|
|
||||||
: # Uses gencode-remote
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
||||||
echo "Please contribute an implementation for it if you can." >&2
|
echo "Please contribute an implementation for it if you can." >&2
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
Changelog
|
Changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
next:
|
|
||||||
* Type __timezone: Add support for OpenWRT (Nico Schottelius)
|
|
||||||
|
|
||||||
7.0.1:
|
7.0.1:
|
||||||
* Core: Remove double definition of scan parser (Nico Schottelius)
|
* Core: Remove double definition of scan parser (Nico Schottelius)
|
||||||
* Type __apt_mark: Narrow down grep for hold packages (marcoduif)
|
* Type __apt_mark: Narrow down grep for hold packages (marcoduif)
|
||||||
|
|
Loading…
Reference in a new issue