This commit is contained in:
parent
e2be635e56
commit
20ad03b7bb
2 changed files with 25 additions and 11 deletions
|
@ -7,7 +7,7 @@ gitea-pages can be installed on any server, it get triggerd via (global) webhook
|
|||
It should be possible to have a static page generator (hugo, vuepress ....) which can generate the static files in a ci pipeline like drone.io and push it in the "webpage" branch.
|
||||
Than this service could pull it, setup the nginx for the domain and provide an ssl certificate.
|
||||
|
||||
|
||||
If the nginx is configured correct it also should be possible to execute php files.
|
||||
|
||||
# Install
|
||||
## Requirmentes
|
||||
|
@ -26,4 +26,8 @@ ssh-keygen
|
|||
|
||||
# Config
|
||||
|
||||
#
|
||||
# Usage
|
||||
|
||||
## Additional/Custom Domain
|
||||
|
||||
## PHP
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"html/template"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Promote struct {
|
||||
|
@ -52,19 +53,21 @@ func (p Promote) reloadServer() {
|
|||
func (p Promote) getSSL(domain, path string) (cert, key string, active bool) {
|
||||
if _, err := os.Stat(p.getCertPath(domain, "cer")); err == nil {
|
||||
return p.getCertPath(domain, "cer"), p.getCertPath(domain, "key"), true
|
||||
} else {
|
||||
log.Debug().Msg("Try to get SSL Zertifikat")
|
||||
output, err := exec.Command("/root/.acme.sh/acme.sh", "--issue", "-d", domain, "-w", path).Output()
|
||||
if err != nil {
|
||||
log.Error().Str("output", string(output)).Err(err).Msg("Cant issue ssl certificat")
|
||||
} else {
|
||||
log.Info().Str("output", string(output)).Msg("Got SSL zertifikat")
|
||||
return p.getCertPath(domain, "cer"), p.getCertPath(domain, "key"), true
|
||||
}
|
||||
}
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
func (p Promote) requestSSL(domain, path, name, owner string) {
|
||||
log.Debug().Msg("Try to get SSL Zertifikat")
|
||||
output, err := exec.Command("/root/.acme.sh/acme.sh", "--issue", "-d", domain, "-w", path).Output()
|
||||
if err != nil {
|
||||
log.Error().Str("output", string(output)).Err(err).Msg("Cant issue ssl certificat")
|
||||
} else {
|
||||
log.Info().Str("output", string(output)).Msg("Got SSL zertifikat")
|
||||
p.PromoteRepo(name, owner)
|
||||
}
|
||||
}
|
||||
|
||||
func (p Promote) updateContent(domain, content string) bool {
|
||||
fileName := fmt.Sprintf("%s/%s.conf", p.Config.Promoter.Path, domain)
|
||||
log.Debug().Str("filename", fileName).Msg("Promote to File")
|
||||
|
@ -109,6 +112,13 @@ func (p Promote) getContent(name, owner, domain string) string {
|
|||
log.Panic().Err(err).Msg("Cant parse Promoter Template")
|
||||
}
|
||||
|
||||
if active == false {
|
||||
go func() {
|
||||
time.Sleep(10*time.Second)
|
||||
p.requestSSL(domain, path, name, owner)
|
||||
}()
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue