From 42da95121926df356d70ae6a2b6fff7e745ab081 Mon Sep 17 00:00:00 2001 From: gitea-action Date: Mon, 4 Nov 2024 16:30:23 +0800 Subject: [PATCH] mihomo: sync upstream last commit: https://github.com/morytyann/OpenWrt-mihomo/commit/71f9a40db13efe96a8afc56851004e0c65d99f74 --- mihomo/Makefile | 2 +- mihomo/files/mihomo.conf | 1 + mihomo/files/mihomo.init | 31 +++++++++++++++++++++++----- mihomo/files/uci-defaults/migrate.sh | 4 ++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/mihomo/Makefile b/mihomo/Makefile index a540896dc..0d361e73e 100644 --- a/mihomo/Makefile +++ b/mihomo/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mihomo -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo.git diff --git a/mihomo/files/mihomo.conf b/mihomo/files/mihomo.conf index 1128dc942..ef265ccc7 100644 --- a/mihomo/files/mihomo.conf +++ b/mihomo/files/mihomo.conf @@ -3,6 +3,7 @@ config status 'status' config config 'config' option 'init' '1' option 'enabled' '0' + option 'start_delay' '0' option 'scheduled_restart' '0' option 'cron_expression' '0 3 * * *' option 'profile' 'subscription:subscription' diff --git a/mihomo/files/mihomo.init b/mihomo/files/mihomo.init index e06f72e40..01c2790b1 100644 --- a/mihomo/files/mihomo.init +++ b/mihomo/files/mihomo.init @@ -7,6 +7,23 @@ USE_PROCD=1 . "$IPKG_INSTROOT/lib/functions/network.sh" . "$IPKG_INSTROOT/etc/mihomo/scripts/constants.sh" +boot() { + # init log + init_log + # load config + config_load mihomo + # start delay + local enabled start_delay + config_get_bool enabled "config" "enabled" 0 + config_get start_delay "config" "start_delay" 0 + if [[ "$enabled" == 1 && "$start_delay" > 0 ]]; then + log "App will start after $start_delay seconds." + sleep "$start_delay" + fi + # start + start +} + start_service() { # clear log clear_log @@ -20,6 +37,7 @@ start_service() { log "Exiting..." return fi + # start log "App is enabled." log "Starting..." # get config @@ -462,18 +480,21 @@ cleanup() { /etc/init.d/cron restart } -log() { - echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$APP_LOG_PATH" +init_log() { + mkdir "$LOG_DIR" + touch "$APP_LOG_PATH" + touch "$CORE_LOG_PATH" } clear_log() { - if [ ! -d "$LOG_DIR" ]; then - mkdir "$LOG_DIR" - fi echo -n > "$APP_LOG_PATH" echo -n > "$CORE_LOG_PATH" } +log() { + echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$APP_LOG_PATH" +} + mixin_authentications() { local section="$1" diff --git a/mihomo/files/uci-defaults/migrate.sh b/mihomo/files/uci-defaults/migrate.sh index 9a566cf94..a993228b4 100644 --- a/mihomo/files/uci-defaults/migrate.sh +++ b/mihomo/files/uci-defaults/migrate.sh @@ -10,6 +10,10 @@ dns_doh_prefer_http3=$(uci -q get mihomo.mixin.dns_doh_prefer_http3); [ -z "$dns mixin_file_content=$(uci -q get mihomo.mixin.mixin_file_content); [ -z "$mixin_file_content" ] && uci set mihomo.mixin.mixin_file_content=$(uci -q get mihomo.config.mixin) +# since v1.9.3 + +start_delay=$(uci -q get mihomo.config.start_delay); [ -z "$start_delay" ] && uci set mihomo.config.start_delay=0 + # commit uci commit mihomo