#!/bin/sh
if ! [ "root" = "$(id -u -n)" ]; then
echo "ERROR: ${0} must be run as root!"; exit 1
fi
systemctl stop openvpn-server@\* --all
systemctl stop wg-quick@\* --all
rm -rf /etc/openvpn/server/*
rm -rf /etc/wireguard/*
if [ -f /etc/fedora-release ]; then
systemctl stop httpd
systemctl stop php-fpm
dnf -y --refresh update
systemctl start php-fpm
systemctl start httpd
/usr/libexec/vpn-server-node/server-config
elif [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then
systemctl stop httpd
systemctl stop php-fpm
yum clean expire-cache
yum -y update
systemctl start php-fpm
systemctl start httpd
/usr/libexec/vpn-server-node/server-config
elif [ -f /etc/debian_version ]; then
PHP_VERSION=$(/usr/sbin/phpquery -V)
systemctl stop apache2
systemctl stop "php${PHP_VERSION}-fpm"
apt update
apt -y dist-upgrade
systemctl start "php${PHP_VERSION}-fpm"
systemctl start apache2
/usr/libexec/vpn-server-node/server-config
else
echo "ERROR: OS not supported!"
exit 1
fi
systemctl start openvpn-server@\* --all
systemctl start wg-quick@\* --all
# sync with vpn-daemon, no need to wait for the cron, but *ONLY* do this when
# this is a machine with vpn-user-portal installed
if [ -d /etc/vpn-user-portal ]; then
if [ -f /etc/redhat-release ]; then
sudo -u apache /usr/libexec/vpn-user-portal/daemon-sync
fi
if [ -f /etc/debian_version ]; then
sudo -u www-data /usr/libexec/vpn-user-portal/daemon-sync
fi
fi