parent
fadcfe93c2
commit
42da951219
@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=mihomo
|
PKG_NAME:=mihomo
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
|
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo.git
|
PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo.git
|
||||||
|
@ -3,6 +3,7 @@ config status 'status'
|
|||||||
config config 'config'
|
config config 'config'
|
||||||
option 'init' '1'
|
option 'init' '1'
|
||||||
option 'enabled' '0'
|
option 'enabled' '0'
|
||||||
|
option 'start_delay' '0'
|
||||||
option 'scheduled_restart' '0'
|
option 'scheduled_restart' '0'
|
||||||
option 'cron_expression' '0 3 * * *'
|
option 'cron_expression' '0 3 * * *'
|
||||||
option 'profile' 'subscription:subscription'
|
option 'profile' 'subscription:subscription'
|
||||||
|
@ -7,6 +7,23 @@ USE_PROCD=1
|
|||||||
. "$IPKG_INSTROOT/lib/functions/network.sh"
|
. "$IPKG_INSTROOT/lib/functions/network.sh"
|
||||||
. "$IPKG_INSTROOT/etc/mihomo/scripts/constants.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() {
|
start_service() {
|
||||||
# clear log
|
# clear log
|
||||||
clear_log
|
clear_log
|
||||||
@ -20,6 +37,7 @@ start_service() {
|
|||||||
log "Exiting..."
|
log "Exiting..."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
# start
|
||||||
log "App is enabled."
|
log "App is enabled."
|
||||||
log "Starting..."
|
log "Starting..."
|
||||||
# get config
|
# get config
|
||||||
@ -462,18 +480,21 @@ cleanup() {
|
|||||||
/etc/init.d/cron restart
|
/etc/init.d/cron restart
|
||||||
}
|
}
|
||||||
|
|
||||||
log() {
|
init_log() {
|
||||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$APP_LOG_PATH"
|
mkdir "$LOG_DIR"
|
||||||
|
touch "$APP_LOG_PATH"
|
||||||
|
touch "$CORE_LOG_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_log() {
|
clear_log() {
|
||||||
if [ ! -d "$LOG_DIR" ]; then
|
|
||||||
mkdir "$LOG_DIR"
|
|
||||||
fi
|
|
||||||
echo -n > "$APP_LOG_PATH"
|
echo -n > "$APP_LOG_PATH"
|
||||||
echo -n > "$CORE_LOG_PATH"
|
echo -n > "$CORE_LOG_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$APP_LOG_PATH"
|
||||||
|
}
|
||||||
|
|
||||||
mixin_authentications() {
|
mixin_authentications() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
|
|
||||||
|
@ -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)
|
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
|
# commit
|
||||||
uci commit mihomo
|
uci commit mihomo
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user