Migrate Mihomo and IPtables scripts from systemd to OpenRC and update service configurations
This commit is contained in:
@@ -33,8 +33,9 @@ MIHOMO_URL="https://github.com/vernesong/mihomo/releases/download/Prerelease-Alp
|
||||
# Remote Resources
|
||||
REPO_BASE="https://gitea.shamanlanding.org/DaTekShaman/clash-rules/raw/branch/main"
|
||||
URL_CONFIG_MIHOMO="${REPO_BASE}/config-clash/cadian/cadian.current.yaml"
|
||||
# Init-скрипты генерируем локально, так как в репо лежат systemd юниты
|
||||
URL_SCRIPT_IPTABLES="${REPO_BASE}/scripts/iptables-mihomo-setup.sh"
|
||||
URL_INIT_MIHOMO="${REPO_BASE}/init-scripts/openrc/mihomo"
|
||||
URL_INIT_IPTABLES="${REPO_BASE}/init-scripts/openrc/mihomo-iptables"
|
||||
|
||||
# Paths
|
||||
BIN_DIR="/usr/local/bin"
|
||||
@@ -139,7 +140,7 @@ chown -R mihomo:mihomo "$CONF_DIR" /var/log/mihomo
|
||||
# ==========================================
|
||||
# 6. CONFIGURATION & OPENRC SERVICES
|
||||
# ==========================================
|
||||
echo ">>> [6/8] Downloading Configs and Generating Services..."
|
||||
echo ">>> [6/8] Downloading Configs and Services..."
|
||||
|
||||
# 6.1 Mihomo Config
|
||||
if [ ! -f "${CONF_DIR}/config.yaml" ]; then
|
||||
@@ -165,45 +166,32 @@ else
|
||||
echo "✅ Configuration test passed."
|
||||
fi
|
||||
|
||||
# 6.4 Generate OpenRC Services (Вместо скачивания systemd units)
|
||||
# 6.4 Download OpenRC Services
|
||||
echo "Fetching OpenRC Init Scripts..."
|
||||
|
||||
# Service: Mihomo
|
||||
cat <<EOF > /etc/init.d/mihomo
|
||||
#!/sbin/openrc-run
|
||||
name="mihomo"
|
||||
description="Mihomo Daemon"
|
||||
command="${BIN_DIR}/mihomo"
|
||||
command_args="-d ${CONF_DIR}"
|
||||
command_background=true
|
||||
pidfile="/run/mihomo.pid"
|
||||
# Запускаем от юзера mihomo
|
||||
command_user="mihomo:mihomo"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
use dns
|
||||
after firewall
|
||||
}
|
||||
EOF
|
||||
chmod +x /etc/init.d/mihomo
|
||||
if [ ! -f "${INIT_DIR}/mihomo" ]; then
|
||||
echo "Downloading Service: $URL_INIT_MIHOMO"
|
||||
wget -qO "${INIT_DIR}/mihomo" "$URL_INIT_MIHOMO"
|
||||
chmod +x "${INIT_DIR}/mihomo"
|
||||
else
|
||||
echo "Service 'mihomo' already exists."
|
||||
fi
|
||||
|
||||
# Service: IPtables Helper
|
||||
cat <<EOF > /etc/init.d/mihomo-iptables
|
||||
#!/sbin/openrc-run
|
||||
description="Mihomo IPtables Setup"
|
||||
if [ ! -f "${INIT_DIR}/mihomo-iptables" ]; then
|
||||
echo "Downloading Service: $URL_INIT_IPTABLES"
|
||||
wget -qO "${INIT_DIR}/mihomo-iptables" "$URL_INIT_IPTABLES"
|
||||
chmod +x "${INIT_DIR}/mihomo-iptables"
|
||||
else
|
||||
echo "Service 'mihomo-iptables' already exists."
|
||||
fi
|
||||
|
||||
depend() {
|
||||
need net
|
||||
before mihomo
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Applying Mihomo IPtables rules"
|
||||
${BIN_DIR}/iptables-mihomo-setup.sh
|
||||
eend \$?
|
||||
}
|
||||
EOF
|
||||
chmod +x /etc/init.d/mihomo-iptables
|
||||
# 6.5 Enable Services (rc-update)
|
||||
# Добавляем в автозагрузку (default runlevel)
|
||||
echo "Enabling services..."
|
||||
rc-update add mihomo-iptables default
|
||||
rc-update add mihomo default
|
||||
|
||||
# ==========================================
|
||||
# 7. USER & SSH SETUP
|
||||
|
||||
@@ -27,12 +27,10 @@ NETBIRD_SETUP_KEY="7369BE4D-C485-4339-A7CA-C245FD95E857"
|
||||
MIHOMO_URL="https://github.com/vernesong/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-amd64-v3-alpha-smart-06249f8.gz"
|
||||
|
||||
# Remote Resources (URLs)
|
||||
# Укажи здесь ссылки на raw-файлы из твоего Gitea/GitHub
|
||||
REPO_BASE="https://gitea.shamanlanding.org/DaTekShaman/clash-rules/raw/branch/main"
|
||||
|
||||
URL_CONFIG_MIHOMO="${REPO_BASE}/config-clash/cadian/cadian.current.yaml"
|
||||
URL_UNIT_MIHOMO="${REPO_BASE}/systemd-units/mihomo.service"
|
||||
URL_UNIT_IPTABLES="${REPO_BASE}/systemd-units/mihomo-iptables.service"
|
||||
URL_UNIT_MIHOMO="${REPO_BASE}/init-scripts/systemd/mihomo.service"
|
||||
URL_UNIT_IPTABLES="${REPO_BASE}/init-scripts/systemd/mihomo-iptables.service"
|
||||
URL_SCRIPT_IPTABLES="${REPO_BASE}/scripts/iptables-mihomo-setup.sh"
|
||||
|
||||
# Paths
|
||||
|
||||
Reference in New Issue
Block a user