Prepare V0.2

This commit is contained in:
Mario Fetka
2024-04-21 07:45:51 +02:00
parent c2744e173f
commit c2c83c2e6f
51 changed files with 671 additions and 9 deletions

0
fail2ban/config-v2.sh Normal file
View File

21
fail2ban/info-v2.sh Normal file
View File

@@ -0,0 +1,21 @@
if [ $BANUNBAN = "fail2ban" ]; then
echo "" >> ${DBP_INFO}
echo "Fail2Ban Mystic integration" >> ${DBP_INFO}
echo "" >> ${DBP_INFO}
echo "A Fail2ban Systemd service override has been installed so tha the unprivileged user mystic can add and remove " >> ${DBP_INFO}
echo "IP's to the fail2ban system" >> ${DBP_INFO}
echo "to activate the fail2ban integration you will have to enabel it in the ${MYSTIC_DIR}/dbp.ini file" >> ${DBP_INFO}
echo " for this to work correctly you wil have to change the firewall Line in the Event Editor to the suggested" >> ${DBP_INFO}
echo "" >> ${DBP_INFO}
echo "==============================================================================================================" >> ${DBP_INFO}
fi
if [ $BANUNBAN = "ipban" ]; then
echo "" >> ${DBP_INFO}
echo "" >> ${DBP_INFO}
echo "" >> ${DBP_INFO}
echo "" >> ${DBP_INFO}
echo "" >> ${DBP_INFO}
echo "" >> ${DBP_INFO}
echo "==============================================================================================================" >> ${DBP_INFO}
fi

53
fail2ban/install-v2.sh Normal file
View File

@@ -0,0 +1,53 @@
if [ $BANUNBAN = "fail2ban" ]; then
msg_info "Installing Fail2Ban Dependencies for ${APP}"
apt install -y fail2ban &>/dev/null
apt install -y iptables &>/dev/null
apt install -y ipset &>/dev/null
if [ -z "${FAIL2BAN_GROUP}" ]; then
groupadd fail2ban &>/dev/null
fi
usermod --append --groups fail2ban mystic &>/dev/null
msg_ok "Installing Fail2Ban Dependencies for ${APP}"
msg_info "Installing Fail2Ban Scripts for ${APP}"
pushd $MSTEMPDIR/mystic/fail2ban &>/dev/null
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" action.d/mysticbbs.conf > /etc/fail2ban/action.d/mysticbbs.conf
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" filter.d/mysticbbs.conf > /etc/fail2ban/filter.d/mysticbbs.conf
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" jail.d/mysticbbs.conf > /etc/fail2ban/jail.d/mysticbbs.conf
mkdir -p /etc/systemd/system/fail2ban.service.d
cp systemd/override.conf /etc/systemd/system/fail2ban.service.d/override.conf
popd &>/dev/null
msg_ok "Installing Fail2Ban Scripts for ${APP}"
fi
if [ $BANUNBAN = "ipban" ]; then
msg_info "Installing IpBan Dependencies for ${APP}"
pushd $MSTEMPDIR &>/dev/null
wget -N https://github.com/DigitalRuby/IPBan/raw/master/IPBanCore/Linux/Scripts/Install.sh -O $MSTEMPDIR/ipban-install.sh &>/dev/null
apt install -y fail2ban &>/dev/null
apt install -y iptables &>/dev/null
apt install -y ipset &>/dev/null
apt install -y xmlstarlet &>/dev/null
sed -i '/yum/d' $MSTEMPDIR/ipban-install.sh &>/dev/null
sed -i '/systemctl/d' $MSTEMPDIR/ipban-install.sh &>/dev/null
sed -e 's!sudo !!g' -i $MSTEMPDIR/ipban-install.sh &>/dev/null
sed -e 's!-qq!-qqo!g' -i $MSTEMPDIR/ipban-install.sh &>/dev/null
sed -i '/nano/d' $MSTEMPDIR/ipban-install.sh &>/dev/null
bash $MSTEMPDIR/ipban-install.sh &>/dev/null
if [ -z "${IPBAN_GROUP}" ]; then
groupadd ipban &>/dev/null
fi
usermod --append --groups ipban mystic &>/dev/null
chown -R root:ipban /opt/ipban &>/dev/null
chmod 775 /opt/ipban/ &>/dev/null
dos2unix /opt/ipban/*.{config,xml,md} &>/dev/null
popd &>/dev/null
msg_ok "Installing IpBan Dependencies for ${APP}"
fi

9
fail2ban/prompt-v2.sh Normal file
View File

@@ -0,0 +1,9 @@
BANUNBAN=$(whiptail --title "Add Ban / Unban to Mystic" --radiolist --cancel-button Exit-Script "Choose Fail2Ban IpBan No" 12 58 5 \
"fail2ban" "Add Fail2Ban" ON \
"ipban" "Add IpBan" OFF \
"No" "Don't add IP Banning" OFF \
3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo -e "${DGN}Add Fail2Ban: ${BGN}$BANUNBAN${CL}"
fi

3
fail2ban/update.sh Normal file
View File

@@ -0,0 +1,3 @@
for file in $(ls *-v1.sh) ; do
cp -- "${file}" "$(echo "${file}" | sed -e 's/v1\.sh/v2\.sh/')"
done