{"id":28796160,"url":"https://github.com/bocaletto-luca/master-server-generator","last_synced_at":"2026-05-09T19:33:18.702Z","repository":{"id":298846543,"uuid":"1001314247","full_name":"bocaletto-luca/master-server-generator","owner":"bocaletto-luca","description":"msgen — Master Server Generator msgen is a cross-platform CLI tool written in Go that scaffolds a standalone, persistent “server” binary. The generated server:  Runs as a background service/daemon on Windows \u0026 Linux Auto-starts at boot (Windows Service / systemd unit) Automatically restarts on crash or stop... By Bocaletto Luca","archived":false,"fork":false,"pushed_at":"2025-06-13T07:14:28.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-13T08:25:25.741Z","etag":null,"topics":["admin","admin-tools","administration","information","linux","master-server-generator","send-mail","server-generator","tools","windows"],"latest_commit_sha":null,"homepage":"https://bocaletto-luca.github.io/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bocaletto-luca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-13T07:08:56.000Z","updated_at":"2025-06-13T07:15:10.000Z","dependencies_parsed_at":"2025-06-13T08:36:02.913Z","dependency_job_id":null,"html_url":"https://github.com/bocaletto-luca/master-server-generator","commit_stats":null,"previous_names":["bocaletto-luca/master-server-generator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bocaletto-luca/master-server-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bocaletto-luca%2Fmaster-server-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bocaletto-luca%2Fmaster-server-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bocaletto-luca%2Fmaster-server-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bocaletto-luca%2Fmaster-server-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bocaletto-luca","download_url":"https://codeload.github.com/bocaletto-luca/master-server-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bocaletto-luca%2Fmaster-server-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260477932,"owners_count":23015066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admin","admin-tools","administration","information","linux","master-server-generator","send-mail","server-generator","tools","windows"],"created_at":"2025-06-18T03:11:25.520Z","updated_at":"2026-05-09T19:33:18.694Z","avatar_url":"https://github.com/bocaletto-luca.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# msgen — Master Server Generator\n#### Author: Bocaletto Luca\n\n**msgen** is a cross-platform CLI tool written in Go that scaffolds a standalone, persistent “server” binary. The generated server:\n\n- Runs as a background service/daemon on Windows \u0026 Linux  \n- Auto-starts at boot (Windows Service / systemd unit)  \n- Automatically restarts on crash or stop (service recovery policy)  \n- Periodically collects machine info (IP, MAC, hostname, OS, CPU, memory, disk, users)  \n- Sends templated email reports via SMTP (STARTTLS/SMTPS)  \n- Is fully self-contained: configuration is embedded or loaded from `config.yaml`  \n\n---\n\n## 🚀 Features\n\n- Single executable (`server.exe` on Windows, `server` on Linux)  \n- Embedded or external YAML configuration  \n- Cron-style scheduling (`@every 30m`, `0 8 * * *`, etc.)  \n- System metrics via [gopsutil]  \n- Email delivery via [gomail] with TLS \u0026 retry  \n- Windows Service integration (register/unregister)  \n- systemd unit file support for Linux  \n- Structured console logging (zerolog)  \n- Dockerfile for containerized deployment  \n- GitHub Actions CI workflow  \n\n---\n\n## 📋 Prerequisites\n\n- Go 1.21+ toolchain  \n- Git  \n- On Windows: Administrative privileges to register a Service  \n- On Linux: `systemd` environment and `sudo` for unit deployment  \n\n---\n\n## 🔧 Installation\n\n1. Clone the repository and install `msgen`:\n    ```bash\n    git clone https://github.com/bocaletto-luca/msgen.git\n    cd msgen\n    go install ./cmd/msgen\n    ```\n2. Verify `msgen` is in your `$GOPATH/bin` or `$GOBIN`:\n    ```bash\n    msgen --help\n    ```\n\n---\n\n## ⚙️ Configuration\n\nCreate or edit a YAML config file (`config.yaml`). You can either keep it alongside your server binary or let it fall back to the embedded default.\n\n```yaml\n# config.yaml\nschedule: \"@every 30m\"\n\nsmtp:\n  host: \"smtp.example.com\"\n  port: 587\n  username: \"alerts@example.com\"\n  password: \"supersecret\"\n  from: \"alerts@example.com\"\n  to:\n    - \"admin1@example.com\"\n    - \"admin2@example.com\"\n\nmodules:\n  - ip\n  - mac\n  - os\n  - cpu\n  - mem\n  - disk\n  - users\n```\n\n**Environment variable overrides**  \nYou may replace any field with `${ENV_VAR}` syntax and export the corresponding environment variables before generating or running the server.\n\n---\n\n## ▶️ Generating Your Server\n\nRun `msgen` pointing at your config:\n\n```bash\nmsgen --config path/to/config.yaml --out ./dist\n```\n\nThis will create:\n\n- `dist/config.yaml` (copied)  \n- `dist/server.go` (templated Go source)  \n\n---\n\n## 🛠️ Building Executables\n\n### Windows\n\n```bash\nGOOS=windows GOARCH=amd64 go build -o dist/server.exe dist/server.go\n```\n\n### Linux\n\n```bash\nGOOS=linux   GOARCH=amd64 go build -o dist/server   dist/server.go\nchmod +x dist/server\n```\n\n---\n\n## ⚙️ Deployment\n\n### Windows Service\n\n1. Open PowerShell as Administrator.\n2. Register the service:\n   ```powershell\n   sc.exe create ms-server `\n     binPath= \"C:\\path\\to\\server.exe --config C:\\path\\to\\config.yaml\" `\n     start= auto\n   sc.exe failure ms-server reset= 0 actions= restart/5000\n   ```\n3. Start the service:\n   ```powershell\n   sc.exe start ms-server\n   ```\n4. To stop \u0026 remove:\n   ```powershell\n   sc.exe stop ms-server\n   sc.exe delete ms-server\n   ```\n\n### Linux systemd Unit\n\n1. Copy binary and config to `/opt/ms-server/`:\n   ```bash\n   sudo mkdir -p /opt/ms-server\n   sudo cp dist/server /opt/ms-server/\n   sudo cp dist/config.yaml /opt/ms-server/\n   ```\n2. Create `/etc/systemd/system/ms-server.service`:\n   ```ini\n   [Unit]\n   Description=msgen Server Daemon\n   After=network.target\n\n   [Service]\n   ExecStart=/opt/ms-server/server --config /opt/ms-server/config.yaml\n   Restart=always\n   RestartSec=5\n   User=root\n   LimitNOFILE=4096\n\n   [Install]\n   WantedBy=multi-user.target\n   ```\n3. Enable \u0026 start:\n   ```bash\n   sudo systemctl daemon-reload\n   sudo systemctl enable ms-server\n   sudo systemctl start ms-server\n   ```\n4. Check status \u0026 logs:\n   ```bash\n   sudo systemctl status ms-server\n   journalctl -u ms-server -f\n   ```\n\n---\n\n## 🐳 Docker\n\nBuild and run in a container:\n\n```bash\ndocker build -t bocaletto-luca/ms-server .\ndocker run -d \\\n  -v $(pwd)/config.yaml:/app/config.yaml:ro \\\n  -e SMTP_PASSWORD \\\n  --name ms-server \\\n  bocaletto-luca/ms-server\n```\n\n---\n\n## 🔍 Health Checks\n\nThe server binary exposes a basic HTTP health endpoint at `http://localhost:8000/healthz`. You can integrate this with load balancers or monitoring systems.\n\n---\n\n## 🧪 Testing \u0026 CI\n\n- Unit tests and linters:\n  ```bash\n  go test ./...\n  go vet ./...\n  ```\n- CI workflow on GitHub Actions builds \u0026 tests for multiple Go versions.\n\n---\n\n## 📝 License\n\nThis project is licensed under the **GPL License**. See [LICENSE](LICENSE) for details.\n\n---\n\n**Author:** Bocaletto Luca ([@bocaletto-luca](https://github.com/bocaletto-luca))  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbocaletto-luca%2Fmaster-server-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbocaletto-luca%2Fmaster-server-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbocaletto-luca%2Fmaster-server-generator/lists"}