A lightweight Go server to serve and run Bash scripts via HTTP.
Supports piping scripts directly with curl/wget and passing arguments.
Configurable script directory and port via environment variables. Ideal as a base Docker image or Go module for script distribution.
- Serve Bash scripts over HTTP.
- Pass arguments to scripts:
curl | bash -s -- arg1 arg2. - Configurable
SCRIPT_DIRandPORT. - Can be used as a base Docker image or Go module.
- Optional Kubernetes deployment.
go install github.com/mrofi/bashscript-server@latestdocker build -t bashscript-server .
docker run -p 8080:8080 bashscript-serverFROM ghcr.io/mrofi/bashscript-server:latest
COPY scripts /app/scriptsdocker run -p 8080:8080 \
-e SCRIPT_DIR=/scripts \
-v $(pwd)/scripts:/scripts \
ghcr.io/mrofi/bashscript-serverPlace your .sh scripts in the scripts directory.
Example structure:
scripts/
├── foo.sh
└── bar.sh
Start the server (default port 8080):
docker run -p 8080:8080 -v $(pwd)/scripts:/app/scripts bashscript-serverRun a script with arguments:
curl -sL http://localhost:8080/foo.sh | bash -s -- arg1 arg2Inside foo.sh:
#!/bin/bash
echo "Foo script running with args: $@"Output:
Foo script running with args: arg1 arg2
| Variable | Default | Description |
|---|---|---|
| SCRIPT_DIR | /app/scripts |
Directory where scripts are stored. |
| PORT | 8080 |
Port to serve HTTP requests. |
apiVersion: apps/v1
kind: Deployment
metadata:
name: bashscript-server
spec:
replicas: 1
selector:
matchLabels:
app: bashscript-server
template:
metadata:
labels:
app: bashscript-server
spec:
containers:
- name: server
image: your-dockerhub/bashscript-server:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: bashscript-server
spec:
selector:
app: bashscript-server
ports:
- port: 80
targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: bashscript-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: myscripts.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: bashscript-server
port:
number: 80MIT License. See LICENSE for details.