protected-resources-list/bin/ovpn-connect

29 lines
689 B
PHP
Executable File

#!/usr/bin/php
<?php
require_once dirname(__DIR__) . "/loader.php";
require_once dirname(__DIR__) . "/plugins/openvpn/Openvpn.php";
try {
if (!isset($argv[1])) {
throw new RuntimeException("Output config is not set");
}
$rpc = new StaticRPC();
$instance = $rpc->getPlugins()["openvpn"] ?? null;
if ($instance === null) {
throw new RuntimeException("Plugin is not enabled");
}
/**
* @var Openvpn $instance
*/
$config = $instance->getRoutingConfig();
$outfile = $argv[1];
file_put_contents($outfile, implode("\n", $config));
} catch (Exception $e) {
echo "\nError:" . $e->getMessage() . "\n";
exit(1);
}
exit(0);