0.3.1 • Published 7 years ago

shebang-server v0.3.1

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
7 years ago

shebang: Unix shell as a service.

GitHub license npm Docker Build Status Travis

Usage

With npm

# Install
npm i shebang-server -g

# run it
shebang

With Docker

docker run  -p 8080:8080 --rm --read-only --tmpfs /tmp:rw,nosuid,exec,size=65536k bashrocks/shebang

Environment Flags

  • SHEBANG_PORT: HTTP listening port, default 8080
  • SHEBANG_SUBPROCESS_TIMEOUT: Maximum running time for script in ms, default 1000
  • SHEBANG_LOGGING_TYPE: Logging type for morgan middleware, default common

HTTP Service

shebang use multipart/form-data for both request and response. URL query parameters became environment variables, script and stdin are passed as file uploading.

echo 'tee; >&2 echo $content' > ./script
echo 'from stdin' > ./stdin

curl \
--request POST \
--url 'localhost:8080/?content=from%20url' \ 
--form 'script=@./script' \
--form 'stdin=@./stdin'

Request body

--------------------------3da5c8a3e4e906d6
Content-Disposition: form-data; name="script"; filename="script"
Content-Type: application/octet-stream

tee; >&2 echo $content

--------------------------3da5c8a3e4e906d6
Content-Disposition: form-data; name="stdin"; filename="stdin"
Content-Type: application/octet-stream

from stdin

--------------------------3da5c8a3e4e906d6--

Response body

----------------------------519869792495086289945952
Content-Disposition: form-data; name="stdout"; filename="stdout"
Content-Type: text/plain

from stdin

----------------------------519869792495086289945952
Content-Disposition: form-data; name="stderr"; filename="stderr"
Content-Type: text/plain

from url

----------------------------519869792495086289945952
Content-Disposition: form-data; name="code"
Content-Type: text/plain

0
----------------------------519869792495086289945952--

Deploy to Kubernetes

If you're interested to run shebang as internal container cluster, you could reuse the deployment config for bash.rocks here