ssh: Cleanup permanent ssh patch

This commit is contained in:
remittor
2025-03-03 10:02:18 +03:00
parent c868bb410c
commit f428bc449e
4 changed files with 77 additions and 72 deletions
+18 -11
View File
@@ -2,14 +2,8 @@
DIR_PATCH=/etc/crontabs/patches
if [ "$( grep 'ssh_patch.sh' /etc/crontabs/root )" != "" ]; then
if [ -e "/tmp/ssh_uninstall.sh" ]; then
sh /tmp/ssh_uninstall.sh
fi
fi
if [ ! -d $DIR_PATCH ]; then
mkdir $DIR_PATCH
mkdir -p $DIR_PATCH
chown root $DIR_PATCH
chmod 0755 $DIR_PATCH
fi
@@ -20,7 +14,20 @@ chmod +x $DIR_PATCH/ssh_patch.sh
nvram set ssh_en=1
nvram commit
grep -v "/ssh_patch.sh" /etc/crontabs/root > /etc/crontabs/root.new
echo "*/1 * * * * /etc/crontabs/patches/ssh_patch.sh >/dev/null 2>&1" >> /etc/crontabs/root.new
mv /etc/crontabs/root.new /etc/crontabs/root
/etc/init.d/cron restart
INSTALL_METHOD=2
if [ $INSTALL_METHOD = 1 ]; then
FILE_FOR_EDIT=/etc/crontabs/root
grep -v "/ssh_patch.sh" $FILE_FOR_EDIT > $FILE_FOR_EDIT.new
echo "*/1 * * * * /etc/crontabs/patches/ssh_patch.sh >/dev/null 2>&1" >> $FILE_FOR_EDIT.new
mv $FILE_FOR_EDIT.new $FILE_FOR_EDIT
/etc/init.d/cron restart
fi
if [ $INSTALL_METHOD = 2 ]; then
uci set firewall.auto_ssh_patch=include
uci set firewall.auto_ssh_patch.type='script'
uci set firewall.auto_ssh_patch.path="$DIR_PATCH/ssh_patch.sh"
uci set firewall.auto_ssh_patch.enabled='1'
uci commit firewall
fi