1
0
mirror of synced 2024-11-22 13:06:02 +03:00

Improve services on boot

This commit is contained in:
hwdsl2 2017-01-04 01:50:41 -06:00
parent e41cf78b53
commit ca84aa7a13
2 changed files with 23 additions and 12 deletions

View File

@ -387,16 +387,22 @@ exit 0
EOF EOF
# Start services at boot # Start services at boot
update-rc.d fail2ban enable >/dev/null 2>&1 for svc in fail2ban ipsec xl2tpd; do
systemctl enable fail2ban >/dev/null 2>&1 update-rc.d "$svc" enable >/dev/null 2>&1
systemctl enable "$svc" >/dev/null 2>&1
done
if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then
if [ -f /etc/rc.local ]; then
conf_bk "/etc/rc.local" conf_bk "/etc/rc.local"
sed --follow-symlinks -i '/^exit 0/d' /etc/rc.local sed --follow-symlinks -i '/^exit 0/d' /etc/rc.local
else
echo '#!/bin/sh' > /etc/rc.local
fi
cat >> /etc/rc.local <<'EOF' cat >> /etc/rc.local <<'EOF'
# Added by hwdsl2 VPN script # Added by hwdsl2 VPN script
service ipsec start service ipsec restart
service xl2tpd start service xl2tpd restart
echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_forward
exit 0 exit 0
EOF EOF

View File

@ -371,21 +371,26 @@ fi
# Start services at boot # Start services at boot
if grep -qs "release 6" /etc/redhat-release; then if grep -qs "release 6" /etc/redhat-release; then
chkconfig iptables on for svc in iptables fail2ban ipsec xl2tpd; do
chkconfig fail2ban on chkconfig "$svc" on
done
else else
systemctl --now mask firewalld systemctl --now mask firewalld
yum -y install iptables-services || exiterr2 yum -y install iptables-services || exiterr2
systemctl enable iptables fail2ban >/dev/null 2>&1 systemctl enable iptables fail2ban ipsec xl2tpd >/dev/null 2>&1
fi fi
if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then if ! grep -qs "hwdsl2 VPN script" /etc/rc.local; then
if [ -f /etc/rc.local ]; then
conf_bk "/etc/rc.local" conf_bk "/etc/rc.local"
else
echo '#!/bin/sh' > /etc/rc.local
fi
cat >> /etc/rc.local <<'EOF' cat >> /etc/rc.local <<'EOF'
# Added by hwdsl2 VPN script # Added by hwdsl2 VPN script
modprobe -q pppol2tp modprobe -q pppol2tp
service ipsec start service ipsec restart
service xl2tpd start service xl2tpd restart
echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_forward
EOF EOF
fi fi