diff --git a/net/mihomo/Makefile b/net/mihomo/Makefile index 91a9817b4e58..cc8101f3d021 100644 --- a/net/mihomo/Makefile +++ b/net/mihomo/Makefile @@ -1,27 +1,29 @@ PORTNAME= mihomo DISTVERSIONPREFIX= v DISTVERSION= 1.19.29 -CATEGORIES= net +CATEGORIES= net games DIST_SUBDIR= ${PORTNAME} MAINTAINER= yuri@FreeBSD.org -COMMENT= Simple Python Pydantic model for Honkai +COMMENT= Rule-based network routing proxy tunnel WWW= https://github.com/MetaCubeX/mihomo/tree/Alpha LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE USES= go:1.26,modules cpe CPE_VENDOR= clash_project -GO_MODULE= github.com/metacubex/mihomo +GO_MODULE= github.com/metacubex/mihomo # project is hosted in the GH acct that is Honkai game related but it has nothing to do with gaming PLIST_FILES= bin/${PORTNAME} +USE_RC_SUBR= ${PORTNAME} + PORTSCOUT= limit:^[0-9\.]*$$ pre-patch: @cd ${WRKSRC} && ${CP} listener/redir/tcp_linux.go listener/redir/tcp_freebsd.go .include diff --git a/net/mihomo/files/mihomo.in b/net/mihomo/files/mihomo.in new file mode 100644 index 000000000000..e47fe6fda41c --- /dev/null +++ b/net/mihomo/files/mihomo.in @@ -0,0 +1,60 @@ +#!/bin/sh +# +# PROVIDE: mihomo +# REQUIRE: NETWORKING SERVERS +# BEFORE: DAEMON +# KEYWORD: shutdown +# +# Add the following lines to /etc/rc.conf.local or /etc/rc.conf +# to enable this service: +# +# mihomo_enable (bool): Set to YES to enable mihomo. +# Default is NO. +# mihomo_config (path): Path to the configuration file. +# Default is %%PREFIX%%/etc/mihomo/config.yaml. +# mihomo_datadir (path): Path to the runtime data directory. +# Default is /var/db/mihomo. +# mihomo_user (user): User to run mihomo. +# Default is root. +# mihomo_group (group): Group to run mihomo. +# Default is wheel. +# mihomo_flags (str): Additional flags to pass to mihomo. +# Default is "". +# + +. /etc/rc.subr + +name=mihomo +desc="mihomo proxy server" +rcvar=mihomo_enable + +load_rc_config $name + +: ${mihomo_enable:=NO} +: ${mihomo_user:=root} +: ${mihomo_group:=wheel} +: ${mihomo_config:=%%PREFIX%%/etc/mihomo/config.yaml} +: ${mihomo_datadir:=/var/db/mihomo} +: ${mihomo_pidfile:=/var/run/mihomo.pid} +: ${mihomo_logfile:=/var/log/mihomo.log} +: ${mihomo_flags:=""} + +command=/usr/sbin/daemon +procname="%%PREFIX%%/bin/mihomo" +pidfile=${mihomo_pidfile} +command_args="-f -p ${pidfile} -o ${mihomo_logfile} -u ${mihomo_user} ${procname} -d ${mihomo_datadir} -f ${mihomo_config} ${mihomo_flags}" + +required_files=${mihomo_config} + +start_precmd=mihomo_precmd +mihomo_precmd() +{ + if [ ! -d "${mihomo_datadir}" ]; then + install -d -m 0750 -o ${mihomo_user} -g ${mihomo_group} "${mihomo_datadir}" + fi + if [ ! -e "${mihomo_logfile}" ]; then + install -m 0640 -o ${mihomo_user} -g ${mihomo_group} /dev/null "${mihomo_logfile}" + fi +} + +run_rc_command "$1"