@task-handoff/server 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,6 +21,7 @@ NODE_AGENT_HOST="127.0.0.1"
|
|
|
21
21
|
NODE_AGENT_PORT="8091"
|
|
22
22
|
NODE_AGENT_IPC_PATH="/run/task-handoff/node-agent.sock"
|
|
23
23
|
AUTH_MODE="password"
|
|
24
|
+
NPM_REGISTRY=""
|
|
24
25
|
STATIC_DIR=""
|
|
25
26
|
MATERIALIZE_ONLY="0"
|
|
26
27
|
|
|
@@ -47,6 +48,7 @@ Options:
|
|
|
47
48
|
--node-agent-port <port> Local node-agent port, default 8091
|
|
48
49
|
--node-agent-ipc-path <path> Local control socket, default /run/task-handoff/node-agent.sock
|
|
49
50
|
--auth-mode <mode> Control-plane auth mode: password or disabled
|
|
51
|
+
--npm-registry <url> npm registry inherited by managed updates
|
|
50
52
|
--static-dir <path> Built control-plane UI directory
|
|
51
53
|
--materialize-only Rewrite env and systemd units without starting services
|
|
52
54
|
USAGE
|
|
@@ -75,6 +77,7 @@ while [ "$#" -gt 0 ]; do
|
|
|
75
77
|
--node-agent-port) NODE_AGENT_PORT="${2:-}"; shift 2 ;;
|
|
76
78
|
--node-agent-ipc-path) NODE_AGENT_IPC_PATH="${2:-}"; shift 2 ;;
|
|
77
79
|
--auth-mode) AUTH_MODE="${2:-}"; shift 2 ;;
|
|
80
|
+
--npm-registry) NPM_REGISTRY="${2:-}"; shift 2 ;;
|
|
78
81
|
--static-dir) STATIC_DIR="${2:-}"; shift 2 ;;
|
|
79
82
|
--materialize-only) MATERIALIZE_ONLY="1"; shift ;;
|
|
80
83
|
-h|--help) usage; exit 0 ;;
|
|
@@ -184,6 +187,19 @@ assert_service_command_accessible "$NPM_COMMAND" "npm command"
|
|
|
184
187
|
mkdir -p "$ENV_DIR" "$CONTROL_PLANE_DATA_DIR" "$NODE_AGENT_DATA_DIR"
|
|
185
188
|
chown -R "$SERVICE_USER":"$SERVICE_USER" "$CONTROL_PLANE_DATA_DIR" "$NODE_AGENT_DATA_DIR" 2>/dev/null || true
|
|
186
189
|
|
|
190
|
+
initialize_control_plane_admin() {
|
|
191
|
+
username="$1"
|
|
192
|
+
if [ "$SERVICE_USER" = "root" ]; then
|
|
193
|
+
env TASK_HANDOFF_CONTROL_PLANE_DATA_DIR="$CONTROL_PLANE_DATA_DIR" \
|
|
194
|
+
$CONTROL_PLANE_COMMAND --data-dir "$CONTROL_PLANE_DATA_DIR" credentials \
|
|
195
|
+
--initialize-if-needed --username "$username" --password-stdin
|
|
196
|
+
else
|
|
197
|
+
runuser -u "$SERVICE_USER" -- env TASK_HANDOFF_CONTROL_PLANE_DATA_DIR="$CONTROL_PLANE_DATA_DIR" \
|
|
198
|
+
$CONTROL_PLANE_COMMAND --data-dir "$CONTROL_PLANE_DATA_DIR" credentials \
|
|
199
|
+
--initialize-if-needed --username "$username" --password-stdin
|
|
200
|
+
fi
|
|
201
|
+
}
|
|
202
|
+
|
|
187
203
|
ADMIN_USERNAME=""
|
|
188
204
|
ADMIN_PASSWORD=""
|
|
189
205
|
if [ "$AUTH_MODE" = "password" ]; then
|
|
@@ -194,11 +210,7 @@ if [ "$AUTH_MODE" = "password" ]; then
|
|
|
194
210
|
systemctl stop task-handoff-control-plane.service 2>/dev/null || true
|
|
195
211
|
ADMIN_USERNAME="$(node -e 'process.stdout.write(`admin-${require("node:crypto").randomBytes(6).toString("hex")}`)')"
|
|
196
212
|
ADMIN_PASSWORD="$(node -e 'process.stdout.write(require("node:crypto").randomBytes(24).toString("base64url"))')"
|
|
197
|
-
|
|
198
|
-
ADMIN_INITIALIZATION_RESULT="$(printf '%s\n' "$ADMIN_PASSWORD" | $CONTROL_PLANE_COMMAND credentials --initialize-if-needed --username "$ADMIN_USERNAME" --password-stdin --data-dir "$CONTROL_PLANE_DATA_DIR")"
|
|
199
|
-
else
|
|
200
|
-
ADMIN_INITIALIZATION_RESULT="$(printf '%s\n' "$ADMIN_PASSWORD" | runuser -u "$SERVICE_USER" -- $CONTROL_PLANE_COMMAND credentials --initialize-if-needed --username "$ADMIN_USERNAME" --password-stdin --data-dir "$CONTROL_PLANE_DATA_DIR")"
|
|
201
|
-
fi
|
|
213
|
+
ADMIN_INITIALIZATION_RESULT="$(printf '%s\n' "$ADMIN_PASSWORD" | initialize_control_plane_admin "$ADMIN_USERNAME")"
|
|
202
214
|
if [ "$ADMIN_INITIALIZATION_RESULT" != "created" ]; then
|
|
203
215
|
ADMIN_USERNAME=""
|
|
204
216
|
ADMIN_PASSWORD=""
|
|
@@ -214,6 +226,7 @@ TASK_HANDOFF_NODE_AGENT_IPC_PATH=$NODE_AGENT_IPC_PATH
|
|
|
214
226
|
TASK_HANDOFF_NODE_AGENT_CONTAINER_URL=http://host.docker.internal:$NODE_AGENT_PORT
|
|
215
227
|
TASK_HANDOFF_LOCAL_CONTROLLED_COMMAND=$CONTROLLED_INSTANCE_COMMAND
|
|
216
228
|
TASK_HANDOFF_NPM_COMMAND=$NPM_COMMAND
|
|
229
|
+
${NPM_REGISTRY:+NPM_CONFIG_REGISTRY=$NPM_REGISTRY}
|
|
217
230
|
TASK_HANDOFF_CONTROL_PLANE_HEALTH_URL=http://127.0.0.1:$CONTROL_PLANE_PORT/api/health
|
|
218
231
|
EOF
|
|
219
232
|
chmod 0640 "$ENV_DIR/node-agent.env"
|