Serving up your shell commands fresh and hot, RESTfully!
RESTaurant is a powerful, secure, and easy-to-use server that transforms your command-line tools into RESTful APIs. Whether you're looking to remotely execute system commands, integrate shell scripts with web services, or build automation workflows, RESTaurant has you covered with a clean, intuitive interface.
- RESTful Command Execution: Turn any shell command into an API endpoint
- Custom Commands: Define your own command menu in a simple JSON configuration file
- Built-in Security: Protection against dangerous commands and rate limiting
- Metrics & Monitoring: Track usage statistics for all your endpoints
- Configurable Timeouts: Set global or per-request execution time limits
- Cross-Origin Support: Built-in CORS handling for web applications
- Graceful Shutdown: Clean termination with proper signal handling
- Comprehensive Logging: Detailed insights into all operations
# Clone the repository
git clone https://github.com/yourusername/restaurant.git
cd restaurant
# Build the project
cargo build --release
# Run the server with default settings
./target/release/restaurantRESTaurant can be configured via command-line arguments, environment variables, or a config file:
# Run with custom settings
./target/release/restaurant --host 0.0.0.0 --port 8080 --config-file my-commands.jsonCreate a config.json file with your custom commands:
{
"commands": {
"uptime": {
"command": "uptime",
"description": "System uptime information",
"methods": ["GET"]
},
"runmyscript": {
"command": "/usr/bin/myscript.sh -i ok.txt -o output.txt",
"description": "My script that does something amazing",
"methods": ["GET"]
}
}
}Access your predefined commands via simple GET requests:
# Get system uptime
curl http://localhost:55555/uptime
# Run a custom script defined in config.json
curl http://localhost:55555/runmyscriptExecute arbitrary commands (if they pass security checks):
curl -X POST http://localhost:55555/custom \
-H "Content-Type: application/json" \
-d '{"command": "ls -la", "timeout": 10}'RESTaurant serves these special endpoints:
- GET /health: Server health check
- GET /api/endpoints: List all available command endpoints
- GET /metrics: Request statistics and metrics
- POST /custom: Execute custom commands
RESTaurant takes security seriously:
- Commands are checked against a list of dangerous patterns
- Rate limiting prevents abuse
- Custom commands are sanitized
- Execution timeouts prevent resource exhaustion
- Security headers are added to all responses
| Option | Environment Variable | Default | Description |
|---|---|---|---|
| --host | COMMAND_SERVER_HOST | 127.0.0.1 | Server host address |
| --port | COMMAND_SERVER_PORT | 55555 | Server port |
| --timeout | COMMAND_TIMEOUT | 30 | Command execution timeout in seconds |
| --rate-limit-requests | RATE_LIMIT_REQUESTS | 100 | Rate limit: requests per window |
| --rate-limit-window | RATE_LIMIT_WINDOW | 60 | Rate limit window in seconds |
| --config-file | COMMAND_CONFIG_FILE | config.json | Path to command definitions file |
| --log-level | LOG_LEVEL | info | Logging level (trace, debug, info, warn, error) |
| --debug | COMMAND_SERVER_DEBUG | false | Enable debug mode |
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
RESTaurant: Where your commands are always served fresh and RESTfully!