From 62d85490de0122f143494fcf305b27d8fb449b1f Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Fri, 13 May 2022 09:26:08 -0500 Subject: [PATCH] Improve VPN setup - On Alpine Linux, update crontabs when uninstalling the VPN. These cron jobs are for restarting the ipsec service on failure. Ref: 15d8651 --- extras/vpnuninstall.sh | 12 ++++++++++++ vpnsetup_alpine.sh | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/extras/vpnuninstall.sh b/extras/vpnuninstall.sh index e1ee307..c6fdc2d 100755 --- a/extras/vpnuninstall.sh +++ b/extras/vpnuninstall.sh @@ -291,6 +291,17 @@ EOF fi } +update_crontabs() { + if [ "$os_type" = "alpine" ]; then + cron_cmd="rc-service -c ipsec zap start" + if grep -qs "$cron_cmd" /etc/crontabs/root; then + bigecho "Updating crontabs..." + sed -i "/$cron_cmd/d" /etc/crontabs/root + touch /etc/crontabs/cron.update + fi + fi +} + remove_config_files() { bigecho "Removing VPN configuration..." /bin/rm -f /etc/ipsec.conf* /etc/ipsec.secrets* /etc/ppp/chap-secrets* /etc/ppp/options.xl2tpd* \ @@ -306,6 +317,7 @@ remove_vpn() { update_sysctl update_rclocal update_iptables_rules + update_crontabs remove_config_files } diff --git a/vpnsetup_alpine.sh b/vpnsetup_alpine.sh index b9f2599..afd5b7e 100755 --- a/vpnsetup_alpine.sh +++ b/vpnsetup_alpine.sh @@ -501,15 +501,15 @@ start_services() { service xl2tpd restart >/dev/null 2>&1 mkdir -p /etc/crontabs cron_cmd="rc-service -c ipsec zap start" -if ! grep -qs "$cron_cmd" /etc/crontabs/root; then + if ! grep -qs "$cron_cmd" /etc/crontabs/root; then cat >> /etc/crontabs/root <