добавил лостфильм и кнопочку овпн
This commit is contained in:
parent
2e27ad81f2
commit
43dacf7f87
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"description": "lostfilm",
|
||||
"domains": [],
|
||||
"networks": [
|
||||
"104.21.0.0/17"
|
||||
]
|
||||
}
|
||||
|
|
@ -5,9 +5,24 @@ class Openvpn implements IPluggable
|
|||
{
|
||||
private PluginContext $context;
|
||||
|
||||
public function init(PluginContext $context)
|
||||
public function restart()
|
||||
{
|
||||
//restart ovpn
|
||||
return shell_exec($this->context->getConfig()["ovpn"]["restart_cmd"]);
|
||||
}
|
||||
|
||||
public function init(PluginContext $context): void
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->checkConfig();
|
||||
}
|
||||
|
||||
private function checkConfig(): void
|
||||
{
|
||||
$config = $this->context->getConfig();
|
||||
if (!isset($config["ovpn"])) {
|
||||
$config["ovpn"] = $this->context->getMetadata()["config"];
|
||||
}
|
||||
}
|
||||
|
||||
public function getRoutingConfig(): array
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"class": "Openvpn",
|
||||
"config": {
|
||||
|
||||
"restart_cmd": "/etc/init.d/zebra restart"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import {App} from "/assets/App.js";
|
||||
(async function () {
|
||||
$("#buttons").append(`<button id="restart-ovpn">Restart openvpn server</button>`);
|
||||
$("#restart-ovpn").click(function () {
|
||||
if (confirm("Are you sure?")) {
|
||||
const self = $(this);
|
||||
self.prop("disabled", true);
|
||||
(async function () {
|
||||
try {
|
||||
alert(await App.RPC.__invoke("openvpn::restart"));
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
self.prop("disabled", false);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
})();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
$memory = trim(shell_exec("free -b | grep Mem:"));
|
||||
$memory = str_replace(" ", " ", $memory);
|
||||
while (str_contains($memory, " ")) $memory = str_replace(" ", " ", $memory);
|
||||
$items = explode(" ", $memory);
|
||||
$available = intval($items[count($items) - 1]) / 1024 / 1024;
|
||||
|
||||
if ($available < 25) {
|
||||
shell_exec("systemctl restart grass");
|
||||
}
|
||||
Loading…
Reference in New Issue