Start service on remote host
This commit is contained in:
parent
286ef9ddae
commit
b623c7e1f9
1 changed files with 21 additions and 0 deletions
|
@ -192,3 +192,24 @@ Takes OPTION as an argument and prints its description."
|
|||
(if command
|
||||
(message "Command for %s: %s" use-case command)
|
||||
(message "Use case not found"))))
|
||||
|
||||
(defvar mk/remote/*host-aliases*
|
||||
'(("website" . "marcus@u1.marcuskammer.dev")
|
||||
("playground" . "marcus@u1.metaebene.dev"))
|
||||
"Alist mapping friendly host names to actual SSH-compatible host strings.")
|
||||
|
||||
(defun mk/remote/--get-real-host (alias)
|
||||
"Lookup the real host name based on a given ALIAS."
|
||||
(or (cdr (assoc alias mk/remote/*host-aliases*)) alias))
|
||||
|
||||
(defun mk/remote/start-service (alias service)
|
||||
"Start a systemd SERVICE on a remote HOST."
|
||||
(interactive "sEnter the host alias or name: \nsEnter the service name: ")
|
||||
(let ((host (mk/remote/--get-real-host alias))
|
||||
(buffer (generate-new-buffer (format "*%s-systemd-%s*" alias service)))
|
||||
(process-name (format "systemctl-start-%s" service)))
|
||||
(set-process-sentinel
|
||||
(start-process process-name buffer "ssh" host "sudo" "systemctl" "start" service)
|
||||
(lambda (process signal)
|
||||
(when (memq (process-status process) '(exit signal))
|
||||
(message "Process: %s %s" process signal))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue