diff --git a/README.md b/README.md index 0da4652..316eebd 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ docker-compose up | `SMTP_PASSWORD` | The SMTP user password | N/A | | `SMTP_AUTH_TYPE` | The SMTP authentication type. Possible values: `PLAIN`, `LOGIN`, `NONE` | `NONE` | | `SMTP_ENCRYPTION` | the encryption method. Possible values: `NONE`, `SSL`, `SSLTLS`, `TLS`, `STARTTLS` | `STARTTLS` | - +| `WG_DATABASE_PATH` | The path to database where stores all WG data | `/etc/wireguard/db` | ### Defaults for server configuration These environment variables are used to control the default server settings used when initializing the database. diff --git a/main.go b/main.go index 0131208..f69d0e6 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,7 @@ var ( flagSessionSecret string = util.RandomString(32) flagWgConfTemplate string flagBasePath string + flagDBPath string = "/etc/wireguard/db" ) const ( @@ -80,6 +81,7 @@ func init() { flag.StringVar(&flagSessionSecret, "session-secret", util.LookupEnvOrString("SESSION_SECRET", flagSessionSecret), "The key used to encrypt session cookies.") flag.StringVar(&flagWgConfTemplate, "wg-conf-template", util.LookupEnvOrString("WG_CONF_TEMPLATE", flagWgConfTemplate), "Path to custom wg.conf template.") flag.StringVar(&flagBasePath, "base-path", util.LookupEnvOrString("BASE_PATH", flagBasePath), "The base path of the URL") + flag.StringVar(&flagDBPath, "database-path", util.LookupEnvOrString("WG_DATABASE_PATH", flagDBPath), "The custom path to database.") flag.Parse() // update runtime config @@ -120,7 +122,7 @@ func init() { } func main() { - db, err := jsondb.New("./db") + db, err := jsondb.New(flagDBPath) if err != nil { panic(err) }