From 7079b5d26b473a2d746cda5fd70e3b147ab6cc03 Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Wed, 3 Dec 2025 16:43:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=89=E8=A3=85=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0upstart=20init=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/install.sh b/install.sh index 77dd4a4..b74f484 100755 --- a/install.sh +++ b/install.sh @@ -157,6 +157,10 @@ uninstall_previous() { /etc/init.d/${service_name} stop /etc/init.d/${service_name} disable 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 # macOS launchd service - check both system and user locations system_plist="/Library/LaunchDaemons/com.komari.${service_name}.plist" @@ -401,6 +405,12 @@ detect_init_system() { echo "openrc" return fi + + # check for Upstart (CentOS 6) + if command -v initctl >/dev/null 2>&1 && [ -d /etc/init ]; then + echo "upstart" + return + fi echo "unknown" } @@ -597,6 +607,37 @@ EOF exit 1 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 log_error "Unsupported or unknown init system detected: $init_system" log_error "Supported init systems: systemd, openrc, procd, launchd"