diff --git a/README.md b/README.md index 1ce5cfe..5cecfa7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ # bunker -simple bastion system for linux hosts + +A simple bastion system for linux hosts + +## Installation + +### From Binary + +Visit [GitHub Releases](https://github.com/yankeguo/bunker/releases) and download the latest release. + +Static assets are embedded in the binary, so you don't need to download anything else. + +- Prepare a `data` directory and put `bunker.yaml` configuration file in it +- Run `bunker -data-dir data` + +### From Container Image + +Visit [DockerHub Repository](https://hub.docker.com/repository/docker/yankeguo/bunker) or [GitHub Packages](https://github.com/yankeguo?tab=packages&repo_name=bunker) for container images + +- Prepare a `data` directory and put `bunker.yaml` configuration file in it +- Run contaienr image with `/data` mounted, `docker run -p 8080:8080 -p 8022:8022 -v $PWD/data:/data yankeguo/bunker:latest` + +## Configuration File + +```yaml +server: + listen: ":8080" +ssh_server: + listen: ":8022" +``` + +## Credits + +GUO YANKE, MIT License diff --git a/main.go b/main.go index 56876cb..f525644 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,13 @@ package main import ( + "flag" "io/fs" "log" "net/http" "os" "path" + "path/filepath" "github.com/yankeguo/rg" "github.com/yankeguo/ufx" @@ -18,8 +20,13 @@ func installStatic(ur ufx.Router) { } func main() { + var optDataDir string + + flag.StringVar(&optDataDir, "data-dir", "", "data directory") + flag.Parse() + app := fx.New( - ufx.ProvideConfFromYAMLFile("bunker.yaml"), + ufx.ProvideConfFromYAMLFile(filepath.Join(optDataDir, "bunker.yaml")), ufx.Module, fx.Invoke(installStatic), )