versioning

This commit is contained in:
mercury
2023-06-05 13:39:24 +04:00
parent 0e9991a846
commit a8054d3e68
3 changed files with 37 additions and 10 deletions
+35 -10
View File
@@ -541,20 +541,45 @@ class Bot
public function cron()
{
while (true) {
try {
$clients = $this->readClients();
if ($clients) {
foreach ($clients as $k => $v) {
if (!empty($v['interface']['## time'])) {
if (strtotime($v['interface']['## time']) < time()) {
$this->switchClient($k);
}
$this->shutdownClient();
$this->checkVersion();
sleep(10);
}
}
public function checkVersion()
{
try {
require __DIR__ . '/config.php';
if (!empty($c['admin'])) {
$current = file_get_contents('/version');
$last = file_get_contents('https://raw.githubusercontent.com/mercurykd/vpnbot/master/version');
if (!empty($last) && $last != $this->last && $last != $current) {
$this->last = $last;
$diff = implode("\n", array_diff(explode("\n", $last), explode("\n", $current)));
foreach ($c['admin'] as $k => $v) {
$this->send($v, "update:\n$diff");
}
}
}
} catch (Exception $e) {
}
}
public function shutdownClient()
{
try {
$clients = $this->readClients();
if ($clients) {
foreach ($clients as $k => $v) {
if (!empty($v['interface']['## time'])) {
if (strtotime($v['interface']['## time']) < time()) {
$this->switchClient($k);
}
}
}
} catch (Exception $e) {
}
sleep(10);
} catch (Exception $e) {
}
}
+1
View File
@@ -72,6 +72,7 @@ services:
- ./logs/:/logs/
- ./scripts/start_unit.sh:/start_unit.sh
- ./scripts/check_file.sh:/check_file.sh
- ./version:/version
environment:
TZ: ${TZ}
IP: ${IP}
+1
View File
@@ -0,0 +1 @@
05.06.2023 версионирование