mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-18 18:49:23 +08:00
fix:fix support for alpine
This commit is contained in:
63
install.sh
63
install.sh
@@ -397,27 +397,50 @@ detect_init_system() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for Alpine Linux or other OpenRC-based systems
|
# Alpine Linux MUST be checked first
|
||||||
if [ -f /etc/alpine-release ] || [ -f /sbin/openrc-run ]; then
|
# Alpine always uses OpenRC, even in containers where PID 1 might be different
|
||||||
|
if [ -f /etc/alpine-release ]; then
|
||||||
|
if command -v rc-service >/dev/null 2>&1 || [ -f /sbin/openrc-run ]; then
|
||||||
|
echo "openrc"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get PID 1 process for other detection
|
||||||
|
local pid1_process=$(ps -p 1 -o comm= 2>/dev/null | tr -d ' ')
|
||||||
|
|
||||||
|
# If PID 1 is systemd, use systemd
|
||||||
|
if [ "$pid1_process" = "systemd" ] || [ -d /run/systemd/system ]; then
|
||||||
|
if command -v systemctl >/dev/null 2>&1; then
|
||||||
|
# Additional verification that systemd is actually functioning
|
||||||
|
if systemctl list-units >/dev/null 2>&1; then
|
||||||
|
echo "systemd"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for Gentoo OpenRC (PID 1 is openrc-init)
|
||||||
|
if [ "$pid1_process" = "openrc-init" ]; then
|
||||||
if command -v rc-service >/dev/null 2>&1; then
|
if command -v rc-service >/dev/null 2>&1; then
|
||||||
echo "openrc"
|
echo "openrc"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if systemd is actually PID 1 (not just installed)
|
# Check for other OpenRC systems (not Alpine, already handled)
|
||||||
if [ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1; then
|
# Some systems use traditional init with OpenRC
|
||||||
# Additional check: verify systemd is actually running
|
if [ "$pid1_process" = "init" ] && [ ! -f /etc/alpine-release ]; then
|
||||||
if systemctl --version >/dev/null 2>&1 && [ "$(ps -p 1 -o comm=)" = "systemd" ]; then
|
# Check if OpenRC is actually managing services
|
||||||
echo "systemd"
|
if [ -d /run/openrc ] && command -v rc-service >/dev/null 2>&1; then
|
||||||
|
echo "openrc"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# Check for OpenRC files
|
||||||
|
if [ -f /sbin/openrc ] && command -v rc-service >/dev/null 2>&1; then
|
||||||
|
echo "openrc"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for OpenRC (generic check)
|
|
||||||
if command -v rc-service >/dev/null 2>&1 && [ -d /etc/init.d ]; then
|
|
||||||
echo "openrc"
|
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for OpenWrt's procd
|
# Check for OpenWrt's procd
|
||||||
@@ -432,6 +455,20 @@ detect_init_system() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Fallback: if systemctl exists and appears functional, assume systemd
|
||||||
|
if command -v systemctl >/dev/null 2>&1; then
|
||||||
|
if systemctl list-units >/dev/null 2>&1; then
|
||||||
|
echo "systemd"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Last resort: check for OpenRC without other indicators
|
||||||
|
if command -v rc-service >/dev/null 2>&1 && [ -d /etc/init.d ]; then
|
||||||
|
echo "openrc"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
echo "unknown"
|
echo "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user