~fkooman/vpn-maint-scripts

ref: baf47953d26ea1e08b952479d97947594ab5c50c vpn-maint-scripts/bin/vpn-maint-reset-controller -rwxr-xr-x 1.7 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
#!/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 AND LOCALLY ADDED USERS WILL BE LOST!      *"
echo "*                                                        *"
echo "*            ALL CONFIGURATION WILL BE KEPT!             *"
echo "*                                                        *"
echo "*               THIS CAN *NOT* BE UNDONE!                *"
echo "*                                                        *"
echo "**********************************************************"
echo
printf "Continue? (y/n) [n]: "; read -r CONFIRM
if ! [ "${CONFIRM}" = "y" ] && ! [ "${CONFIRM}" = "Y" ]; then
    exit 1
fi

if [ -f /etc/redhat-release ]; then
    # Fedora, CentOS, RHEL
    systemctl stop httpd
    systemctl stop php-fpm
    rm -rf /var/lib/vpn-user-portal/*
    rm -rf /etc/vpn-user-portal/keys
    rm -rf /var/lib/php/session/*
    /usr/libexec/vpn-user-portal/generate-secrets
    systemctl start php-fpm
    systemctl start httpd
elif [ -f /etc/debian_version ]; then
    # Debian, Ubuntu
    PHP_VERSION=$(/usr/sbin/phpquery -V)
    systemctl stop apache2
    systemctl stop "php${PHP_VERSION}-fpm"
    rm -rf /var/lib/vpn-user-portal/*
    rm -rf /etc/vpn-user-portal/keys
    rm -rf /var/lib/php/sessions/*
    /usr/libexec/vpn-user-portal/generate-secrets
    systemctl start "php${PHP_VERSION}-fpm"
    systemctl start apache2
else
    echo "ERROR: OS not supported!"
    exit 1
fi