cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
11.23k stars 1.11k forks source link

Make the terminal page support opening with a different path #21021

Open jelly opened 1 month ago

jelly commented 1 month ago

Page: terminal

Cockpit-files has a feature request to open the terminal page in the current directory of files.

Currently the terminal page will default open the users home directory with a fallback to /. We want it to open a provided path for example via uri params, for example:

https://cockpit.org/system/terminal#/?path=/home

martinpitt commented 1 month ago

This shouldn't disrupt/stop the current terminal if it is currently running something. My first idea how to do "busy?" detection: https://github.com/cockpit-project/cockpit-files/issues/464#issuecomment-2358778658

martinpitt commented 2 weeks ago

My recommendation: to unblock your work (for a few days), replace

spawn: [user.shell "/bin/bash"],

with something like

["/bin/sh", "-ec", "echo $$ > /tmp/terminal-pid; exec " + (user.shell || "/bin/bash")]

and use cockpit.file() to read the pid. This is an utter hack which we can't land, but I think there's enough unrelated work to be done here in the meantime. In the next days I'll see to teach the stream channel about exposing its pid.

martinpitt commented 2 weeks ago

@ashley-cui see #21132 for adding a proper API to get the pid.