mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-03 03:13:56 +08:00
⛅ Sync 2026-03-17 20:27:41
This commit is contained in:
1 parent
738f2b9cd8
commit
cb0fc3c571
22 files changed
+4371
-82
No files matched your search
@@ -0,0 +1,14 @@
|
||||
config openclawmgr 'main'
|
||||
option enabled '0'
|
||||
option port '18789'
|
||||
option bind 'lan'
|
||||
option base_dir '/opt/openclawmgr'
|
||||
option token ''
|
||||
option allow_insecure_auth '0'
|
||||
option disable_device_auth '0'
|
||||
option node_version '22.16.0'
|
||||
option install_accelerated '1'
|
||||
option default_agent 'anthropic'
|
||||
option default_model ''
|
||||
option provider_api_key ''
|
||||
option provider_base_url ''
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
SERVICE_NAME="openclawmgr"
|
||||
|
||||
_find_entry() {
|
||||
local global_dir="$1"
|
||||
local d="${global_dir}/lib/node_modules/openclaw"
|
||||
[ -f "${d}/openclaw.mjs" ] && { echo "${d}/openclaw.mjs"; return 0; }
|
||||
[ -f "${d}/dist/cli.js" ] && { echo "${d}/dist/cli.js"; return 0; }
|
||||
return 1
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load openclawmgr
|
||||
config_get_bool enabled main enabled 0
|
||||
config_get port main port 18789
|
||||
config_get bind main bind lan
|
||||
config_get base_dir main base_dir /opt/openclawmgr
|
||||
config_get token main token ""
|
||||
|
||||
[ "$enabled" -eq 1 ] || return 0
|
||||
|
||||
local node_bin="${base_dir}/node/bin/node"
|
||||
local global_dir="${base_dir}/global"
|
||||
local data_dir="${base_dir}/data"
|
||||
local env_file="${data_dir}/.openclaw/openclaw.env"
|
||||
local entry="$(_find_entry "$global_dir")"
|
||||
local openai_api_key=""
|
||||
local anthropic_api_key=""
|
||||
local minimax_api_key=""
|
||||
local moonshot_api_key=""
|
||||
|
||||
[ -x "$node_bin" ] || return 1
|
||||
[ -n "$entry" ] || return 1
|
||||
[ -n "$token" ] || return 1
|
||||
|
||||
mkdir -p "${data_dir}/.openclaw" 2>/dev/null
|
||||
if [ -f "$env_file" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$env_file"
|
||||
openai_api_key="${OPENAI_API_KEY:-}"
|
||||
anthropic_api_key="${ANTHROPIC_API_KEY:-}"
|
||||
minimax_api_key="${MINIMAX_API_KEY:-}"
|
||||
moonshot_api_key="${MOONSHOT_API_KEY:-}"
|
||||
fi
|
||||
|
||||
# OpenClaw uses --force to kill conflicting processes, but requires either `lsof`
|
||||
# or `fuser`. iStoreOS images may not include them by default.
|
||||
local force_opt=""
|
||||
if command -v lsof >/dev/null 2>&1 || command -v fuser >/dev/null 2>&1; then
|
||||
force_opt="--force"
|
||||
fi
|
||||
|
||||
local user_opt=""
|
||||
if id openclawmgr >/dev/null 2>&1; then
|
||||
user_opt="openclawmgr"
|
||||
fi
|
||||
|
||||
procd_open_instance "gateway"
|
||||
procd_set_param command "$node_bin" "$entry" gateway run --port "$port" --bind "$bind" --auth token --token "$token" --allow-unconfigured $force_opt
|
||||
procd_set_param env \
|
||||
HOME="$data_dir" \
|
||||
OPENCLAW_HOME="$data_dir" \
|
||||
OPENCLAW_STATE_DIR="${data_dir}/.openclaw" \
|
||||
OPENCLAW_CONFIG_PATH="${data_dir}/.openclaw/openclaw.json" \
|
||||
OPENCLAW_GATEWAY_PORT="$port" \
|
||||
OPENCLAW_GATEWAY_BIND="$bind" \
|
||||
OPENCLAW_GATEWAY_TOKEN="$token" \
|
||||
OPENAI_API_KEY="$openai_api_key" \
|
||||
ANTHROPIC_API_KEY="$anthropic_api_key" \
|
||||
MINIMAX_API_KEY="$minimax_api_key" \
|
||||
MOONSHOT_API_KEY="$moonshot_api_key" \
|
||||
PATH="${base_dir}/node/bin:${global_dir}/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
[ -n "$user_opt" ] && procd_set_param user "$user_opt"
|
||||
procd_set_param respawn 3600 10 5
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "openclawmgr"
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
conf_dir="$(uci -q get quickstart.@main[0].conf_dir 2>/dev/null || true)"
|
||||
[ -n "$conf_dir" ] && suggested_base_dir="$conf_dir/OpenClawMgr" || suggested_base_dir=""
|
||||
|
||||
# Ensure section exists
|
||||
if ! uci -q get openclawmgr.main >/dev/null 2>&1; then
|
||||
uci -q set openclawmgr.main=openclawmgr >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# Fill defaults (only if missing)
|
||||
[ -n "$(uci -q get openclawmgr.main.enabled 2>/dev/null)" ] || uci -q set openclawmgr.main.enabled='0'
|
||||
[ -n "$(uci -q get openclawmgr.main.port 2>/dev/null)" ] || uci -q set openclawmgr.main.port='18789'
|
||||
[ -n "$(uci -q get openclawmgr.main.bind 2>/dev/null)" ] || uci -q set openclawmgr.main.bind='lan'
|
||||
[ -n "$(uci -q get openclawmgr.main.node_version 2>/dev/null)" ] || uci -q set openclawmgr.main.node_version='22.16.0'
|
||||
[ -n "$(uci -q get openclawmgr.main.install_accelerated 2>/dev/null)" ] || uci -q set openclawmgr.main.install_accelerated='1'
|
||||
[ -n "$(uci -q get openclawmgr.main.token 2>/dev/null)" ] || uci -q set openclawmgr.main.token=''
|
||||
[ -n "$(uci -q get openclawmgr.main.allow_insecure_auth 2>/dev/null)" ] || uci -q set openclawmgr.main.allow_insecure_auth='0'
|
||||
[ -n "$(uci -q get openclawmgr.main.disable_device_auth 2>/dev/null)" ] || uci -q set openclawmgr.main.disable_device_auth='0'
|
||||
[ -n "$(uci -q get openclawmgr.main.default_agent 2>/dev/null)" ] || uci -q set openclawmgr.main.default_agent='anthropic'
|
||||
[ -n "$(uci -q get openclawmgr.main.default_model 2>/dev/null)" ] || uci -q set openclawmgr.main.default_model=''
|
||||
[ -n "$(uci -q get openclawmgr.main.provider_api_key 2>/dev/null)" ] || uci -q set openclawmgr.main.provider_api_key=''
|
||||
[ -n "$(uci -q get openclawmgr.main.provider_base_url 2>/dev/null)" ] || uci -q set openclawmgr.main.provider_base_url=''
|
||||
|
||||
# Improve default base_dir on iStoreOS: if still unset or using legacy /opt, prefer quickstart conf_dir.
|
||||
current_base_dir="$(uci -q get openclawmgr.main.base_dir 2>/dev/null || true)"
|
||||
if [ -z "$current_base_dir" ] || [ "$current_base_dir" = "/opt/openclawmgr" ]; then
|
||||
if [ -n "$suggested_base_dir" ]; then
|
||||
uci -q set openclawmgr.main.base_dir="$suggested_base_dir"
|
||||
else
|
||||
uci -q set openclawmgr.main.base_dir='/opt/openclawmgr'
|
||||
fi
|
||||
fi
|
||||
|
||||
uci -q commit openclawmgr >/dev/null 2>&1 || true
|
||||
|
||||
# best-effort: create an unprivileged user for procd
|
||||
if ! id openclawmgr >/dev/null 2>&1; then
|
||||
if command -v adduser >/dev/null 2>&1; then
|
||||
adduser -D -H -s /bin/false openclawmgr >/dev/null 2>&1 || true
|
||||
elif command -v useradd >/dev/null 2>&1; then
|
||||
useradd -r -M -s /bin/false openclawmgr >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
+1161
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-openclawmgr": {
|
||||
"description": "Grant UCI access for luci-app-openclawmgr",
|
||||
"read": {
|
||||
"uci": [ "openclawmgr" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "openclawmgr" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user