git: a32b56478068 - main - net/mihomo: Add RC script

Yuri Victorovich <[email protected]> Sat, 01 Aug 2026 18:54:04 +0000
Newsgroups gmane.os.freebsd.devel.cvs.ports
Message-ID <[email protected]>
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a32b564780685a135e68a513cf4cf3dc66644e6b

commit a32b564780685a135e68a513cf4cf3dc66644e6b
Author:     Yuri Victorovich <[email protected]>
AuthorDate: 2026-08-01 18:52:07 +0000
Commit:     Yuri Victorovich <[email protected]>
CommitDate: 2026-08-01 18:54:02 +0000

    net/mihomo: Add RC script
    
    PR:             291295
    Submitted by:   ykla <[email protected]> (initial version)
---
 net/mihomo/Makefile        |  8 ++++---
 net/mihomo/files/mihomo.in | 60 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/net/mihomo/Makefile b/net/mihomo/Makefile
index 91a9817b4e58..cc8101f3d021 100644
--- a/net/mihomo/Makefile
+++ b/net/mihomo/Makefile
@@ -1,11 +1,11 @@
 PORTNAME=	mihomo
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1.19.29
-CATEGORIES=	net
+CATEGORIES=	net games
 DIST_SUBDIR=	${PORTNAME}
 
 MAINTAINER=	[email protected]
-COMMENT=	Simple Python Pydantic model for Honkai
+COMMENT=	Rule-based network routing proxy tunnel
 WWW=		https://github.com/MetaCubeX/mihomo/tree/Alpha
 
 LICENSE=	MIT
@@ -15,10 +15,12 @@ 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:
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"