1
0
mirror of synced 2024-11-22 04:56:03 +03:00

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
This commit is contained in:
hwdsl2 2022-05-13 09:26:08 -05:00
parent f409512d28
commit 62d85490de
2 changed files with 15 additions and 3 deletions

View File

@ -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
}

View File

@ -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 <<EOF
* * * * * $cron_cmd
* * * * * sleep 15; $cron_cmd
* * * * * sleep 30; $cron_cmd
* * * * * sleep 45; $cron_cmd
EOF
touch /etc/crontabs/cron.update
fi
touch /etc/crontabs/cron.update
fi
}
show_vpn_info() {