2021-02-07 12:59:02 +01:00
|
|
|
<?php
|
|
|
|
|
2023-02-16 23:25:43 +01:00
|
|
|
require '../../includes/csrf.php';
|
2021-02-07 12:59:02 +01:00
|
|
|
require_once '../../includes/config.php';
|
|
|
|
require_once '../../includes/functions.php';
|
|
|
|
|
|
|
|
if (isset($_POST['cfg_id'])) {
|
|
|
|
$ovpncfg_id = $_POST['cfg_id'];
|
2021-06-06 21:55:43 +02:00
|
|
|
$ovpncfg_client = RASPI_OPENVPN_CLIENT_PATH.$ovpncfg_id.'_client.conf';
|
|
|
|
$ovpncfg_login = RASPI_OPENVPN_CLIENT_PATH.$ovpncfg_id.'_login.conf';
|
2021-02-07 14:04:04 +01:00
|
|
|
|
2021-06-06 21:55:43 +02:00
|
|
|
// remove existing client config +login and symbolically link the selected one
|
|
|
|
system("sudo rm ".RASPI_OPENVPN_CLIENT_CONFIG, $return);
|
|
|
|
system("sudo ln -s $ovpncfg_client ".RASPI_OPENVPN_CLIENT_CONFIG, $return);
|
|
|
|
system("sudo rm ".RASPI_OPENVPN_CLIENT_LOGIN, $return);
|
|
|
|
system("sudo ln -s $ovpncfg_login ".RASPI_OPENVPN_CLIENT_LOGIN, $return);
|
2021-02-07 14:04:04 +01:00
|
|
|
|
|
|
|
// restart service
|
2021-02-07 14:50:55 +01:00
|
|
|
exec("sudo /bin/systemctl stop openvpn-client@client", $return);
|
|
|
|
sleep(1);
|
|
|
|
exec("sudo /bin/systemctl enable openvpn-client@client", $return);
|
|
|
|
sleep(1);
|
|
|
|
exec("sudo /bin/systemctl start openvpn-client@client", $return);
|
2021-02-07 14:04:04 +01:00
|
|
|
|
2021-02-07 14:50:55 +01:00
|
|
|
echo json_encode($return);
|
2021-02-07 12:59:02 +01:00
|
|
|
}
|
|
|
|
|