mirror of
https://github.com/1f349/orchid.git
synced 2024-12-22 08:04:10 +00:00
Update config and template loading
This commit is contained in:
parent
61d935e3c3
commit
f3207389a0
@ -20,6 +20,6 @@ type acmeConfig struct {
|
||||
}
|
||||
|
||||
type mailConfig struct {
|
||||
simplemail.Mail
|
||||
To simplemail.FromAddress `yaml:"to"`
|
||||
simplemail.Mail `yaml:",inline"`
|
||||
To simplemail.FromAddress `yaml:"to"`
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Failed to find</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello</h1>
|
||||
<p>World</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1 @@
|
||||
Failed to find
|
0
cmd/orchid/mail-templates/failed-to-renew.go.html
Normal file
0
cmd/orchid/mail-templates/failed-to-renew.go.html
Normal file
0
cmd/orchid/mail-templates/failed-to-renew.go.txt
Normal file
0
cmd/orchid/mail-templates/failed-to-renew.go.txt
Normal file
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"flag"
|
||||
"github.com/1f349/mjwt"
|
||||
"github.com/1f349/orchid"
|
||||
@ -10,13 +11,14 @@ import (
|
||||
"github.com/1f349/orchid/logger"
|
||||
"github.com/1f349/orchid/renewal"
|
||||
"github.com/1f349/orchid/servers"
|
||||
"github.com/1f349/overlapfs"
|
||||
"github.com/1f349/simplemail"
|
||||
"github.com/1f349/violet/utils"
|
||||
"github.com/google/subcommands"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/mrmelon54/cdfs"
|
||||
"github.com/mrmelon54/exit-reload"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
@ -75,10 +77,28 @@ func normalLoad(conf startUpConfig, wd string) {
|
||||
logger.Logger.Fatal("Failed to load MJWT verifier public key from file", "path", filepath.Join(wd, "keys"), "err", err)
|
||||
}
|
||||
|
||||
mail, err := simplemail.New(&conf.Mail.Mail, wd, cdfs.CD(mailTemplates, "mail-templates"))
|
||||
// get mail templates
|
||||
mailDir := filepath.Join(wd, "mail-templates")
|
||||
err = os.Mkdir(mailDir, os.ModePerm)
|
||||
if err != nil && !errors.Is(err, os.ErrExist) {
|
||||
return
|
||||
}
|
||||
wdFs := os.DirFS(mailDir)
|
||||
mailTemplatesSub, err := fs.Sub(mailTemplates, "mail-templates")
|
||||
if err != nil {
|
||||
logger.Logger.Fatal("Failed to load embedded mail templates", "err", err)
|
||||
}
|
||||
templatesFS := overlapfs.OverlapFS{A: mailTemplatesSub, B: wdFs}
|
||||
|
||||
// create mail sender
|
||||
mail, err := simplemail.New(&conf.Mail.Mail, templatesFS)
|
||||
if err != nil {
|
||||
logger.Logger.Fatal("Failed to load email sender", "err", err)
|
||||
}
|
||||
err = mail.Send("failed-to-find", "Test subject", conf.Mail.To.Address, map[string]any{})
|
||||
if err != nil {
|
||||
logger.Logger.Fatal("Failed to send start up mail", "err", err)
|
||||
}
|
||||
|
||||
// open sqlite database
|
||||
db, err := orchid.InitDB(filepath.Join(wd, "orchid.db.sqlite"))
|
||||
|
4
go.mod
4
go.mod
@ -4,7 +4,8 @@ go 1.23.1
|
||||
|
||||
require (
|
||||
github.com/1f349/mjwt v0.4.1
|
||||
github.com/1f349/simplemail v0.0.4
|
||||
github.com/1f349/overlapfs v0.0.1
|
||||
github.com/1f349/simplemail v0.0.5
|
||||
github.com/1f349/violet v0.0.14
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7
|
||||
github.com/charmbracelet/log v0.4.0
|
||||
@ -24,7 +25,6 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/1f349/overlapfs v0.0.1 // indirect
|
||||
github.com/1f349/rsa-helper v0.0.2 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/becheran/wildmatch-go v1.0.0 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -4,8 +4,8 @@ github.com/1f349/overlapfs v0.0.1 h1:LAxBolrXFAgU0yqZtXg/C/aaPq3eoQSPpBc49BHuTp0
|
||||
github.com/1f349/overlapfs v0.0.1/go.mod h1:I6aItQycr7nrzplmfNXp/QF9tTmKRSgY3fXmu/7Ky2o=
|
||||
github.com/1f349/rsa-helper v0.0.2 h1:N/fLQqg5wrjIzG6G4zdwa5Xcv9/jIPutCls9YekZr9U=
|
||||
github.com/1f349/rsa-helper v0.0.2/go.mod h1:VUQ++1tYYhYrXeOmVFkQ82BegR24HQEJHl5lHbjg7yg=
|
||||
github.com/1f349/simplemail v0.0.4 h1:wPL/BjqC+VkKd2+4/CAY6Srqah/jffAo8OARvgiB1bQ=
|
||||
github.com/1f349/simplemail v0.0.4/go.mod h1:ppAIqkvVkI6L99EefbR5NgOjpePNK/RKgeoehj5A+kU=
|
||||
github.com/1f349/simplemail v0.0.5 h1:cr+8pdWhFE/+XVSO7ZTjntySbmIbTqmDy2SR9cHAPLE=
|
||||
github.com/1f349/simplemail v0.0.5/go.mod h1:ppAIqkvVkI6L99EefbR5NgOjpePNK/RKgeoehj5A+kU=
|
||||
github.com/1f349/violet v0.0.14 h1:MpBZ4n1dJjdiIwYMTfh0PBIFll3kjqowxR6DLasafqE=
|
||||
github.com/1f349/violet v0.0.14/go.mod h1:iAREhm+wxnGXkmuvmBhOuhUx2T7/5w7stLYNgQGbqC8=
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
|
||||
|
Loading…
Reference in New Issue
Block a user