From c5b7e1ffdc8353cd0d1071caa39b338aea709919 Mon Sep 17 00:00:00 2001 From: mercury Date: Thu, 24 Oct 2024 23:15:44 +0400 Subject: [PATCH] warp registration fix --- app/bot.php | 8 +++++--- docker-compose.yml | 2 ++ scripts/start_wp.sh | 9 ++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/bot.php b/app/bot.php index df17713..cfaff59 100644 --- a/app/bot.php +++ b/app/bot.php @@ -4661,9 +4661,11 @@ DNS-over-HTTPS with IP: } else { $this->ssh('warp-svc > /dev/null 2>&1 &', 'wp'); sleep(3); - $this->send($this->input['chat'], 'Registration: ' . $this->ssh('warp-cli --accept-tos registration new 2>&1', 'wp')); - if (!empty($p['warp'])) { - $this->send($this->input['chat'], 'License: ' . $this->ssh("warp-cli --accept-tos registration license {$p['warp']} 2>&1", 'wp')); + if (empty($this->ssh('[ -f "/var/lib/cloudflare-warp/conf.json" ] && echo 1', 'wp'))) { + $this->send($this->input['chat'], 'Registration: ' . $this->ssh('warp-cli --accept-tos registration new 2>&1', 'wp')); + if (!empty($p['warp'])) { + $this->send($this->input['chat'], 'License: ' . $this->ssh("warp-cli --accept-tos registration license {$p['warp']} 2>&1", 'wp')); + } } $this->send($this->input['chat'], 'Proxy mode: ' . $this->ssh('warp-cli --accept-tos mode proxy 2>&1', 'wp')); $this->send($this->input['chat'], 'Connect: ' . $this->ssh('warp-cli --accept-tos connect 2>&1', 'wp')); diff --git a/docker-compose.yml b/docker-compose.yml index 762075f..8a545ab 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ networks: - subnet: 10.10.1.0/24 volumes: adguard: + warp: services: up: @@ -510,6 +511,7 @@ services: - ./config:/config - ./certs:/certs - ./scripts/start_wp.sh:/start_wp.sh + - warp:/var/lib/cloudflare-warp hostname: warp container_name: warp-${VER} depends_on: diff --git a/scripts/start_wp.sh b/scripts/start_wp.sh index b4e51dd..46f374e 100755 --- a/scripts/start_wp.sh +++ b/scripts/start_wp.sh @@ -7,10 +7,13 @@ if [ "$off" == 'null' ] then warp-svc > /dev/null & sleep 3 - warp-cli --accept-tos registration new - if [ ! -z "$key" ] + if [ ! -f /var/lib/cloudflare-warp/conf.json ] then - warp-cli --accept-tos registration license $key + warp-cli --accept-tos registration new + if [ ! -z "$key" ] + then + warp-cli --accept-tos registration license $key + fi fi warp-cli --accept-tos mode proxy warp-cli --accept-tos connect