~fkooman/vpn-maint-scripts

ref: baf47953d26ea1e08b952479d97947594ab5c50c vpn-maint-scripts/bin/vpn-maint-update-system -rwxr-xr-x 1.5 KiB
baf47953François Kooman update paths for new Debian packages 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/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