~fkooman/vpn-maint-scripts

ref: 1.2.0 vpn-maint-scripts/bin/vpn-maint-reset-controller -rwxr-xr-x 2.1 KiB
ed277a5eFrançois Kooman update CHANGES 2 years 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
55
56
57
58
59
60
61
62
#!/bin/sh

if ! [ "root" = "$(id -u -n)" ]; then
    echo "ERROR: ${0} must be run as root!"; exit 1
fi

echo "**********************************************************"
echo "*                                                        *"
echo "*    Are you sure you want to RESET your VPN server?     *"
echo "*                                                        *"
echo "* ALL DATA WILL BE LOST! ALL CONFIGURATION WILL BE KEPT! *"
echo "*                                                        *"
echo "*               THIS CAN *NOT* BE UNDONE!                *"
echo "*                                                        *"
echo "**********************************************************"
echo
printf "Continue? [n]: "; read -r CONFIRM
if ! [ "${CONFIRM}" = "y" ]; then
    exit 1
fi

if [ -f /etc/fedora-release ]; then
    systemctl stop httpd
    systemctl stop php-fpm
    rm -rf /var/lib/vpn-server-api/*
    rm -rf /var/lib/vpn-user-portal/*
    rm -f /etc/vpn-user-portal/oauth.key
    rm -rf /var/lib/php/session/*
    sudo -u apache vpn-user-portal-init
    vpn-user-portal-generate-oauth-key
    sudo -u apache vpn-server-api-init
    systemctl start php-fpm
    systemctl start httpd
elif [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then
    systemctl stop httpd
    systemctl stop php-fpm
    rm -rf /var/lib/vpn-server-api/*
    rm -rf /var/lib/vpn-user-portal/*
    rm -f /etc/vpn-user-portal/oauth.key
    rm -rf /var/lib/php/session/*
    sudo -u apache vpn-user-portal-init
    vpn-user-portal-generate-oauth-key
    sudo -u apache vpn-server-api-init
    systemctl start php-fpm
    systemctl start httpd
elif [ -f /etc/debian_version ]; then
    PHP_VERSION=$(/usr/sbin/phpquery -V)
    systemctl stop apache2
    systemctl stop "php${PHP_VERSION}-fpm"
    rm -rf /var/lib/vpn-server-api/*
    rm -rf /var/lib/vpn-user-portal/*
    rm -f /etc/vpn-user-portal/oauth.key
    rm -rf /var/lib/php/sessions/*
    sudo -u www-data vpn-user-portal-init
    vpn-user-portal-generate-oauth-key
    sudo -u www-data vpn-server-api-init
    systemctl start "php${PHP_VERSION}-fpm"
    systemctl start apache2
else
    echo "ERROR: OS not supported!"
    exit 1
fi