1
0
forked from Eeveid/lightOps

实现 LightOps 运维面板基础功能

This commit is contained in:
2026-05-25 01:13:03 +08:00
commit d3bb9f45a6
84 changed files with 23505 additions and 0 deletions

59
scripts/install-server.sh Executable file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/env sh
set -eu
if [ "$(id -u)" -ne 0 ]; then
echo "请使用 root 用户运行" >&2
exit 1
fi
install -d /opt/lightops /etc/lightops
chmod 0755 /opt/lightops
if [ ! -x /opt/lightops/lightops-server ]; then
echo "运行此脚本前,请先将 lightops-server 放到 /opt/lightops/lightops-server" >&2
exit 1
fi
if [ ! -f /etc/lightops/server.toml ]; then
cat >/etc/lightops/server.toml <<'EOF'
bind = "0.0.0.0:8080"
database_url = "sqlite:///opt/lightops/lightops.db?mode=rwc"
jwt_secret = "请替换为足够长的随机密钥"
public_url = "https://panel.example.com"
static_dir = "/opt/lightops/web"
registration_token_ttl_minutes = 30
task_timeout_secs = 20
EOF
fi
cat >/etc/systemd/system/lightops-server.service <<'EOF'
[Unit]
Description=LightOps Server
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=300
StartLimitBurst=10
[Service]
Type=simple
WorkingDirectory=/opt/lightops
ExecStart=/opt/lightops/lightops-server --config /etc/lightops/server.toml
Restart=always
RestartSec=5
KillSignal=SIGINT
TimeoutStopSec=20
User=root
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now lightops-server
sleep 2
if ! systemctl is-active --quiet lightops-server; then
echo "Server 启动失败,最近日志如下:" >&2
journalctl -u lightops-server -n 80 --no-pager >&2 || true
exit 1
fi
echo "LightOps Server 已安装并运行"