diff --git a/ai-hub/app/core/templates/provisioning/provision.sh.j2 b/ai-hub/app/core/templates/provisioning/provision.sh.j2 index 0cdff6c..a383046 100644 --- a/ai-hub/app/core/templates/provisioning/provision.sh.j2 +++ b/ai-hub/app/core/templates/provisioning/provision.sh.j2 @@ -102,6 +102,7 @@ elif [ "$HAS_SYSTEMD" = true ]; then echo "Installing Linux systemd user service..." mkdir -p ~/.config/systemd/user + mkdir -p "$INSTALL_DIR/tmp" cat > ~/.config/systemd/user/cortex-agent.service << EOF [Unit] Description=Cortex Agent Node @@ -109,6 +110,7 @@ [Service] Type=simple +Environment=TMPDIR=$INSTALL_DIR/tmp ExecStart=$INSTALL_DIR/cortex-agent WorkingDirectory=$INSTALL_DIR Restart=always @@ -126,6 +128,8 @@ echo "✅ Systemd Daemon successfully started!" else echo "Systemd not available. Falling back to background loop (nohup)..." + mkdir -p "$INSTALL_DIR/tmp" + export TMPDIR="$INSTALL_DIR/tmp" nohup ./cortex-agent >> "$HOME/.cortex/agent.out.log" 2>&1 & echo $! > agent.pid echo "✅ Background Agent started (PID $!)" diff --git a/ai-hub/app/core/templates/provisioning/start_daemon.sh.j2 b/ai-hub/app/core/templates/provisioning/start_daemon.sh.j2 index b36d14d..7cf565d 100644 --- a/ai-hub/app/core/templates/provisioning/start_daemon.sh.j2 +++ b/ai-hub/app/core/templates/provisioning/start_daemon.sh.j2 @@ -57,17 +57,20 @@ echo "✅ macOS Agent Daemon installed and started!" echo "Logs are available at: $INSTALL_DIR/agent.out.log" else - # Try systemd fallback echo "Installing Linux systemd service..." SERVICE_DIR="$HOME/.config/systemd/user" mkdir -p "$SERVICE_DIR" SERVICE_PATH="$SERVICE_DIR/cortex-agent.service" + + mkdir -p "$INSTALL_DIR/tmp" + cat > "$SERVICE_PATH" << EOF [Unit] Description=Cortex Agent Node After=network.target [Service] +Environment=TMPDIR=$INSTALL_DIR/tmp ExecStart=$INSTALL_DIR/cortex-agent WorkingDirectory=$INSTALL_DIR Restart=always