Add --dump-bootstrap command to remaining 28 un-inception implementations
This commit is contained in:
parent
ee15bc8a5f
commit
dba8ffeedc
33 changed files with 1636 additions and 109 deletions
34
un.scm
34
un.scm
|
|
@ -279,6 +279,30 @@
|
|||
((equal? action "destroy")
|
||||
(curl-delete api-key (format #f "/services/~a" id))
|
||||
(format #t "~aService destroyed: ~a~a\n" green id reset))
|
||||
((equal? action "execute")
|
||||
(when (and id bootstrap)
|
||||
(let* ((json (format #f "{\"command\":\"~a\"}" (escape-json bootstrap)))
|
||||
(response (curl-post api-key (format #f "/services/~a/execute" id) json))
|
||||
(stdout-val (json-extract-string response "stdout")))
|
||||
(when stdout-val
|
||||
(display (format #f "~a~a~a" blue stdout-val reset))))))
|
||||
((equal? action "dump-bootstrap")
|
||||
(when id
|
||||
(format (current-error-port) "Fetching bootstrap script from ~a...\n" id)
|
||||
(let* ((json "{\"command\":\"cat /tmp/bootstrap.sh\"}")
|
||||
(response (curl-post api-key (format #f "/services/~a/execute" id) json))
|
||||
(stdout-val (json-extract-string response "stdout")))
|
||||
(if stdout-val
|
||||
(if type
|
||||
(begin
|
||||
(call-with-output-file type
|
||||
(lambda (port) (display stdout-val port)))
|
||||
(system (format #f "chmod 755 ~a" type))
|
||||
(format #t "Bootstrap saved to ~a\n" type))
|
||||
(display stdout-val))
|
||||
(begin
|
||||
(format (current-error-port) "~aError: Failed to fetch bootstrap (service not running or no bootstrap file)~a\n" red reset)
|
||||
(exit 1))))))
|
||||
((and (equal? action "create") name)
|
||||
(let* ((ports-json (if ports (format #f ",\"ports\":[~a]" ports) ""))
|
||||
(bootstrap-json (if bootstrap (format #f ",\"bootstrap\":\"~a\"" (escape-json bootstrap)) ""))
|
||||
|
|
@ -318,12 +342,18 @@
|
|||
(service-cmd "info" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--logs"))
|
||||
(service-cmd "logs" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--sleep"))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--freeze"))
|
||||
(service-cmd "sleep" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--wake"))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--unfreeze"))
|
||||
(service-cmd "wake" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--destroy"))
|
||||
(service-cmd "destroy" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 3) (equal? (cadr args) "--execute"))
|
||||
(service-cmd "execute" (caddr args) #f #f (list-ref args 3) #f))
|
||||
((and (> (length args) 3) (equal? (cadr args) "--dump-bootstrap"))
|
||||
(service-cmd "dump-bootstrap" (caddr args) #f #f #f (list-ref args 3)))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--dump-bootstrap"))
|
||||
(service-cmd "dump-bootstrap" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--name"))
|
||||
(let ((name (caddr args))
|
||||
(ports (if (and (> (length args) 4) (equal? (list-ref args 3) "--ports"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue