Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 71 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,77 @@
# StackRoost CLI 🐧
# StackRoost CLI

A simple and powerful terminal-based tool to manage Linux web servers. Built in Go, it supports popular stacks like **Apache**, **Nginx**, and **Caddy**, with domain and user management features.
StackRoost is a powerful command-line tool to manage Linux servers with ease. It supports domain configuration, user management, SSL setup, logs, monitoring, and more.

---
## Version

v1.0.0

## Features

- Manage Apache, Nginx, and Caddy services
- Add, remove, and update virtual hosts/domains
- Manage Linux users for deployments
- Backup and restore configurations
- SSL configuration helpers
- Interactive CLI prompts
- Easy setup with clean terminal UI
### Domain Management
- `create-domain` – Create a new domain config with Apache/Nginx/Caddy.
- `backup-domain` – Backup public_html and MySQL DB.
- `clone-domain` – Clone full domain configuration and data.
- `list-domains` – List all active domains and statuses.
- `monitor` – Interactive TUI to monitor all domains.
- `remove-domain` – Remove domain, user, database, and config.
- `restore-domain` – Restore from domain backup archive.
- `status-domain` – Inspect domain config, SSL, and user.
- `toggle-site` – Enable or disable a site's config.
- `update-domain-port` – Update the domain port and reload the web server.

### Email
- `test-email` – Check if the server can send mail (mail/sendmail/msmtp).

### Firewall
- `enable-firewall` – Enable UFW and allow common/custom ports.
- `disable-firewall` – Safely disable UFW.

### Logs
- `analyze-log-traffic` – Analyze access log traffic (IP, URL, requests).
- `logs-domain` – View domain logs (access and error).
- `purge-domain-logs` – Delete domain logs safely.

### Security
- `run-security-check` – Run a server hardening security check.
- `secure-server` – Enable UFW, SSH restrictions, and config hardening.

### Server Tools
- `check-port` – Check if a domain's port is open.
- `server-health` – View CPU, RAM, disk usage, uptime, web server status.
- `inspect-config` – View web server config file.
- `restart-server` – Restart Apache/Nginx/Caddy.
- `schedule-restart` – Schedule a restart after delay.
- `sync-time` – Sync time using systemd-timesyncd.

### SSL Certificates
- `enable` – Enable Let's Encrypt SSL for a domain.
- `disable` – Remove SSL config and certs.
- `renew` – Renew SSL certificates.
- `expiry` – Check SSL expiry date.
- `test` – Test domain SSL cert status.

### User Management
- `list-users` – List shell users (UID ≥ 1000).
- `delete-user` – Delete a system user and their home directory.

## Install

Clone and build manually:
```bash
git clone https://github.com/stackroost/stackroost-cli.git
cd stackroost-cli
go build -o stackroost main.go
```

## Usage

```bash
./stackroost --help
./stackroost create-domain --name example.com --server nginx --shelluser --pass mypass --useridr --ssl
./stackroost monitor
```

## License

---
MIT License
48 changes: 48 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
var rootCmd = &cobra.Command{
Use: "stackroost",
Short: "StackRoost CLI - manage your Linux servers with ease",
Version: "v1.0.0",
Run: func(cmd *cobra.Command, args []string) {
printWelcome()
},
Expand All @@ -32,6 +33,10 @@
Short: "Create a web server configuration for a domain",
Run: func(cmd *cobra.Command, args []string) {
logger.Info("Starting create-domain command execution")
if len(args) > 0 && (args[0] == "--help" || args[0] == "-h" || args[0] == "help") {
customHelpFunc(cmd, args)
return
}

domain, _ := cmd.Flags().GetString("name")
port, _ := cmd.Flags().GetString("port")
Expand Down Expand Up @@ -377,4 +382,47 @@
user.GetListCmd(),
user.GetDeleteCmd(),
)
}

func customHelpFunc(cmd *cobra.Command, args []string) {
fmt.Println("\nStackRoost CLI - manage your Linux servers with ease\n")

Check failure on line 388 in cmd/root.go

View workflow job for this annotation

GitHub Actions / build

fmt.Println arg list ends with redundant newline
fmt.Println("Usage:\n stackroost [command]\n")

Check failure on line 389 in cmd/root.go

View workflow job for this annotation

GitHub Actions / build

fmt.Println arg list ends with redundant newline
fmt.Println("Available Commands:")

group := map[string][]*cobra.Command{}

for _, c := range cmd.Commands() {
if !c.IsAvailableCommand() {
continue
}
switch {
case strings.Contains(c.Use, "domain") || c.Use == "create-domain" || c.Use == "monitor":
group["🔧 Domain Management"] = append(group["🔧 Domain Management"], c)
case strings.Contains(c.Use, "email") || c.Use == "test-email":
group["📧 Email Utilities"] = append(group["📧 Email Utilities"], c)
case strings.Contains(c.Use, "firewall"):
group["🛡 Firewall Control"] = append(group["🛡 Firewall Control"], c)
case strings.Contains(c.Use, "log"):
group["📜 Log Management"] = append(group["📜 Log Management"], c)
case strings.Contains(c.Use, "secure") || strings.Contains(c.Use, "security"):
group["🧰 Security"] = append(group["🧰 Security"], c)
case strings.Contains(c.Use, "server") || strings.Contains(c.Use, "inspect") || strings.Contains(c.Use, "check-port"):
group["🖥 Server Management"] = append(group["🖥 Server Management"], c)
case c.Use == "enable" || c.Use == "disable" || c.Use == "renew" || c.Use == "expiry" || c.Use == "test":
group["🔐 SSL Certificates"] = append(group["🔐 SSL Certificates"], c)
case strings.Contains(c.Use, "user"):
group["👤 User Management"] = append(group["👤 User Management"], c)
default:
group["Other Commands"] = append(group["Other Commands"], c)
}
}

for title, commands := range group {
fmt.Printf("\n%s\n", title)
for _, c := range commands {
fmt.Printf(" %-22s %s\n", c.Use, c.Short)
}
}

fmt.Println("\nUse \"stackroost [command] --help\" for more information about a command.\n")

Check failure on line 427 in cmd/root.go

View workflow job for this annotation

GitHub Actions / build

fmt.Println arg list ends with redundant newline
}
Loading