@task-handoff/server 0.0.24 → 0.0.25-alpha.2

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.
@@ -22,6 +22,7 @@ NODE_AGENT_PORT="8091"
22
22
  NODE_AGENT_IPC_PATH="/run/task-handoff/node-agent.sock"
23
23
  AUTH_MODE="password"
24
24
  STATIC_DIR=""
25
+ MATERIALIZE_ONLY="0"
25
26
 
26
27
  usage() {
27
28
  cat <<'USAGE'
@@ -47,6 +48,7 @@ Options:
47
48
  --node-agent-ipc-path <path> Local control socket, default /run/task-handoff/node-agent.sock
48
49
  --auth-mode <mode> Control-plane auth mode: password or disabled
49
50
  --static-dir <path> Built control-plane UI directory
51
+ --materialize-only Rewrite env and systemd units without starting services
50
52
  USAGE
51
53
  }
52
54
 
@@ -74,6 +76,7 @@ while [ "$#" -gt 0 ]; do
74
76
  --node-agent-ipc-path) NODE_AGENT_IPC_PATH="${2:-}"; shift 2 ;;
75
77
  --auth-mode) AUTH_MODE="${2:-}"; shift 2 ;;
76
78
  --static-dir) STATIC_DIR="${2:-}"; shift 2 ;;
79
+ --materialize-only) MATERIALIZE_ONLY="1"; shift ;;
77
80
  -h|--help) usage; exit 0 ;;
78
81
  *) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;;
79
82
  esac
@@ -181,6 +184,27 @@ assert_service_command_accessible "$NPM_COMMAND" "npm command"
181
184
  mkdir -p "$ENV_DIR" "$CONTROL_PLANE_DATA_DIR" "$NODE_AGENT_DATA_DIR"
182
185
  chown -R "$SERVICE_USER":"$SERVICE_USER" "$CONTROL_PLANE_DATA_DIR" "$NODE_AGENT_DATA_DIR" 2>/dev/null || true
183
186
 
187
+ ADMIN_USERNAME=""
188
+ ADMIN_PASSWORD=""
189
+ if [ "$AUTH_MODE" = "password" ]; then
190
+ # Compatibility for v0.0.21: an older service may still be running with a
191
+ # publicly bootstrap-able empty account store during an in-place upgrade.
192
+ # The auth store is the sole authority: file existence cannot distinguish a
193
+ # valid administrator from a corrupt record that sanitation will isolate.
194
+ systemctl stop task-handoff-control-plane.service 2>/dev/null || true
195
+ ADMIN_USERNAME="$(node -e 'process.stdout.write(`admin-${require("node:crypto").randomBytes(6).toString("hex")}`)')"
196
+ ADMIN_PASSWORD="$(node -e 'process.stdout.write(require("node:crypto").randomBytes(24).toString("base64url"))')"
197
+ if [ "$SERVICE_USER" = "root" ]; then
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
202
+ if [ "$ADMIN_INITIALIZATION_RESULT" != "created" ]; then
203
+ ADMIN_USERNAME=""
204
+ ADMIN_PASSWORD=""
205
+ fi
206
+ fi
207
+
184
208
  cat > "$ENV_DIR/node-agent.env" <<EOF
185
209
  TASK_HANDOFF_NODE_AGENT_HOST=$NODE_AGENT_HOST
186
210
  TASK_HANDOFF_NODE_AGENT_PORT=$NODE_AGENT_PORT
@@ -250,9 +274,21 @@ WantedBy=multi-user.target
250
274
  EOF
251
275
 
252
276
  systemctl daemon-reload
253
- systemctl enable --now task-handoff-node-agent.service
254
- systemctl enable --now task-handoff-control-plane.service
277
+ if [ "$MATERIALIZE_ONLY" = "0" ]; then
278
+ systemctl enable --now task-handoff-node-agent.service
279
+ systemctl enable --now task-handoff-control-plane.service
280
+ fi
255
281
 
256
- echo "TaskHandoff server services are installed."
282
+ if [ "$MATERIALIZE_ONLY" = "1" ]; then
283
+ echo "TaskHandoff server service configuration is materialized."
284
+ else
285
+ echo "TaskHandoff server services are installed."
286
+ fi
257
287
  echo "Control plane: task-handoff-control-plane.service on $CONTROL_PLANE_HOST:$CONTROL_PLANE_PORT"
258
288
  echo "Local node-agent: task-handoff-node-agent.service on $NODE_AGENT_HOST:$NODE_AGENT_PORT"
289
+ if [ -n "$ADMIN_USERNAME" ]; then
290
+ echo "Control Plane administrator credentials (shown once):"
291
+ echo " Username: $ADMIN_USERNAME"
292
+ echo " Password: $ADMIN_PASSWORD"
293
+ echo "Store these credentials securely; they are not written to the service environment."
294
+ fi
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require("../dist/node-update-worker.js");