From 20ad03b7bb5c619059e121b0bd8fd596aec2bd28 Mon Sep 17 00:00:00 2001 From: kekskurse Date: Mon, 5 Dec 2022 18:40:44 +0100 Subject: [PATCH] Stuff --- Readme.md | 8 ++++++-- internal/promote/promote.go | 28 +++++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Readme.md b/Readme.md index d34ff4e..212ffcc 100644 --- a/Readme.md +++ b/Readme.md @@ -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 diff --git a/internal/promote/promote.go b/internal/promote/promote.go index 466fae4..b27a5d7 100644 --- a/internal/promote/promote.go +++ b/internal/promote/promote.go @@ -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() }