Browse Source

Add: SMTP configuration

master
Siroco 8 months ago
parent
commit
33f8d1c176
Signed by: siroco
GPG Key ID: 1324098302A514B0
  1. 3
      .env.sample
  2. 49
      installer/main.go

3
.env.sample

@ -1,3 +1,6 @@
GANCIO_DATA_PATH="./data"
GANCIO_PORT=13120
GANCIO_USER_GROUP="1000:1000"
SMTP_HOST="smtp.sindominio.net"
SMTP_USER="gancio@sindominio.net"
SMTP_PASS="secret"

49
installer/main.go

@ -20,6 +20,7 @@ type InstallerConfig struct {
LogLevel string `json:"log_level"`
LogPath string `json:"log_path"`
DB DBConfig `json:"db"`
SMTP SMTPConfig `json:"smtp"`
AdminEmail string `json:"admin_email"`
}
@ -34,6 +35,17 @@ type DBConfig struct {
Logging bool `json:"logging"`
}
type SMTPConfig struct {
Auth AuthSMTPConfig `json:"auth"`
Secure bool `json:"secure"`
Host string `json:"host"`
}
type AuthSMTPConfig struct {
User string `json:"user"`
Pass string `json:"pass"`
}
type Message struct {
Success bool
Title string
@ -49,12 +61,34 @@ var DB_PATH = "/data/db.sqlite"
var UPLOADS_PATH = "/data/uploads"
var LOGS_PATH = "/data/logs"
var LISTEN_PORT = ":13120"
var SMTP_USER = "gancio@sindominio.net"
var SMTP_PASS = "secret"
var SMTP_SECURE = true
var SMTP_HOST = "smtp.sindominio.net"
var TEMPLATE_PATH = "."
func main() {
// Environment
// Template
if os.Getenv("TEMPLATE") != "" {
TEMPLATE_PATH = os.Getenv("TEMPLATE")
}
// SMTP host
if os.Getenv("SMTP_HOST") != "" {
TEMPLATE_PATH = os.Getenv("SMTP_HOST")
}
// SMTP user
if os.Getenv("SMTP_USER") != "" {
TEMPLATE_PATH = os.Getenv("SMTP_USER")
}
// SMTP pass
if os.Getenv("SMTP_PASS") != "" {
TEMPLATE_PATH = os.Getenv("SMTP_PASS")
}
// SMTP TLS
if os.Getenv("SMTP_SECURE") != "" {
TEMPLATE_PATH = os.Getenv("SMTP_SECURE")
}
fmt.Println("Gancio Installer")
tmpl := template.Must(template.ParseFiles(TEMPLATE_PATH+"/templates/_base.html",TEMPLATE_PATH+"/templates/install.html"))
@ -102,17 +136,27 @@ func main() {
}
// Gancio Config
// Server
serverConfig := ServerConfig{
Host: "0.0.0.0",
Port: 13120,
}
// Database
dbConfig := DBConfig{
Dialec: "sqlite",
Storage: DB_PATH,
Logging: false,
}
// SMTP
smtpConfig := SMTPConfig{
Auth: AuthSMTPConfig{
User: SMTP_USER,
Pass: SMTP_PASS,
},
Secure: SMTP_SECURE,
Host: SMTP_HOST,
}
// Gancio
gancioConfig := InstallerConfig{
Title: r.FormValue("title"),
BaseUrl: r.FormValue("url"),
@ -121,6 +165,7 @@ func main() {
LogLevel: "debug",
LogPath: LOGS_PATH,
DB: dbConfig,
SMTP: smtpConfig,
AdminEmail: msg.Email,
}

Loading…
Cancel
Save