From 3d942cf5c21ea8f9b5ef75d553fdf8d4841ffcb0 Mon Sep 17 00:00:00 2001 From: 233boy <31657650+233boy@users.noreply.github.com> Date: Sun, 2 Jun 2024 17:09:40 +0800 Subject: [PATCH] fix caddy run --- sing-box.sh | 2 +- src/init.sh | 28 +++++++++++++++++----------- src/systemd.sh | 4 ++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/sing-box.sh b/sing-box.sh index 555dc37..252b01d 100644 --- a/sing-box.sh +++ b/sing-box.sh @@ -1,6 +1,6 @@ #!/bin/bash args=$@ -is_sh_ver=v1.01 +is_sh_ver=v1.02 . /etc/sing-box/sh/src/init.sh \ No newline at end of file diff --git a/src/init.sh b/src/init.sh index 901f6df..9111e98 100644 --- a/src/init.sh +++ b/src/init.sh @@ -47,6 +47,17 @@ warn() { echo -e "\n$is_warn $@\n" } +# load bash script. +load() { + . $is_sh_dir/src/$1 +} + +# wget add --no-check-certificate +_wget() { + # [[ $proxy ]] && export https_proxy=$proxy + wget --no-check-certificate "$@" +} + # yum or apt-get cmd=$(type -P apt-get || type -P yum) @@ -106,6 +117,12 @@ else fi if [[ -f $is_caddy_bin && -d $is_caddy_dir && $is_caddy_service ]]; then is_caddy=1 + # fix caddy run; ver >= 2.8.2 + [[ ! $(grep '\-\-adapter caddyfile' /lib/systemd/system/caddy.service) ]] && { + load systemd.sh + install_service caddy + systemctl restart caddy & + } is_caddy_ver=$($is_caddy_bin version | head -n1 | cut -d " " -f1) is_tmp_http_port=$(egrep '^ {2,}http_port|^http_port' $is_caddyfile | egrep -o [0-9]+) is_tmp_https_port=$(egrep '^ {2,}https_port|^https_port' $is_caddyfile | egrep -o [0-9]+) @@ -119,17 +136,6 @@ if [[ -f $is_caddy_bin && -d $is_caddy_dir && $is_caddy_service ]]; then fi fi -# load bash script. -load() { - . $is_sh_dir/src/$1 -} - -# wget add --no-check-certificate -_wget() { - # [[ $proxy ]] && export https_proxy=$proxy - wget --no-check-certificate "$@" -} - load core.sh [[ ! $args ]] && args=main main $args diff --git a/src/systemd.sh b/src/systemd.sh index d883b41..eda63c1 100644 --- a/src/systemd.sh +++ b/src/systemd.sh @@ -38,8 +38,8 @@ Requires=network-online.target Type=notify User=root Group=root -ExecStart=$is_caddy_bin run --environ --config $is_caddyfile -ExecReload=$is_caddy_bin reload --config $is_caddyfile +ExecStart=$is_caddy_bin run --environ --config $is_caddyfile --adapter caddyfile +ExecReload=$is_caddy_bin reload --config $is_caddyfile --adapter caddyfile TimeoutStopSec=5s LimitNPROC=10000 LimitNOFILE=1048576