feat: 安装脚本增加upstart init支持

This commit is contained in:
boypt
2025-12-03 16:43:54 +08:00
parent 5c12b5c570
commit 7079b5d26b

View File

@@ -157,6 +157,10 @@ uninstall_previous() {
/etc/init.d/${service_name} stop /etc/init.d/${service_name} stop
/etc/init.d/${service_name} disable /etc/init.d/${service_name} disable
rm -f "/etc/init.d/${service_name}" rm -f "/etc/init.d/${service_name}"
elif command -v initctl >/dev/null 2>&1 && [ -f "/etc/init/${service_name}.conf" ]; then
log_info "Stopping and removing existing upstart service..."
initctl stop ${service_name}
rm -f "/etc/init/${service_name}.conf"
elif [ "$os_name" = "darwin" ] && command -v launchctl >/dev/null 2>&1; then elif [ "$os_name" = "darwin" ] && command -v launchctl >/dev/null 2>&1; then
# macOS launchd service - check both system and user locations # macOS launchd service - check both system and user locations
system_plist="/Library/LaunchDaemons/com.komari.${service_name}.plist" system_plist="/Library/LaunchDaemons/com.komari.${service_name}.plist"
@@ -401,6 +405,12 @@ detect_init_system() {
echo "openrc" echo "openrc"
return return
fi fi
# check for Upstart (CentOS 6)
if command -v initctl >/dev/null 2>&1 && [ -d /etc/init ]; then
echo "upstart"
return
fi
echo "unknown" echo "unknown"
} }
@@ -597,6 +607,37 @@ EOF
exit 1 exit 1
fi fi
fi fi
elif [ "$init_system" = "upstart" ]; then
# Upstart service configuration
log_info "Using upstart for service management"
service_file="/etc/init/${service_name}.conf"
cat > "$service_file" << EOF
# KOMARI Agent
description "Komari Agent Service"
chdir ${target_dir}
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
umask 022
console none
pre-start script
test -x ${komari_agent_path} || { stop; exit 0; }
end script
# Start
script
exec ${komari_agent_path} ${komari_args}
end script
EOF
# enable Upstart unit
initctl reload-configuration
initctl start ${service_name}
log_success "Upstart service configured and started"
else else
log_error "Unsupported or unknown init system detected: $init_system" log_error "Unsupported or unknown init system detected: $init_system"
log_error "Supported init systems: systemd, openrc, procd, launchd" log_error "Supported init systems: systemd, openrc, procd, launchd"