mirror of
https://github.com/fankes/komari-agent.git
synced 2026-02-04 12:17:30 +08:00
feat: 安装脚本增加upstart init支持
This commit is contained in:
41
install.sh
41
install.sh
@@ -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"
|
||||||
@@ -402,6 +406,12 @@ detect_init_system() {
|
|||||||
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user