1## This Source Code Form is subject to the terms of the Mozilla Public 2## License, v. 2.0. If a copy of the MPL was not distributed with this 3## file, You can obtain one at https://mozilla.org/MPL/2.0/. 4## 5## Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved. 6 7defmodule RabbitMQ.CLI.Diagnostics.Commands.RemoteShellCommand do 8 @behaviour RabbitMQ.CLI.CommandBehaviour 9 10 use RabbitMQ.CLI.Core.MergesNoDefaults 11 use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments 12 13 def run([], %{node: node_name}) do 14 _ = Supervisor.terminate_child(:kernel_sup, :user) 15 Process.flag(:trap_exit, true) 16 user_drv = :user_drv.start(['tty_sl -c -e', {node_name, :shell, :start, []}]) 17 Process.link(user_drv) 18 receive do 19 {'EXIT', _user_drv, _} -> 20 {:ok, "Disconnected from #{node_name}."} 21 end 22 end 23 24 use RabbitMQ.CLI.DefaultOutput 25 26 def help_section(), do: :observability_and_health_checks 27 28 def description(), do: "Starts an interactive Erlang shell on the target node" 29 30 def usage, do: "remote_shell" 31 32 def banner(_, %{node: node_name}) do 33 "Starting an interactive Erlang shell on node #{node_name}... Press 'Ctrl+G' then 'q' to exit." 34 end 35end 36