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.
|
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.
|
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
|
# Install
|
||||||
## Requirmentes
|
## Requirmentes
|
||||||
|
@ -26,4 +26,8 @@ ssh-keygen
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
|
|
||||||
#
|
# Usage
|
||||||
|
|
||||||
|
## Additional/Custom Domain
|
||||||
|
|
||||||
|
## PHP
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Promote struct {
|
type Promote struct {
|
||||||
|
@ -52,19 +53,21 @@ func (p Promote) reloadServer() {
|
||||||
func (p Promote) getSSL(domain, path string) (cert, key string, active bool) {
|
func (p Promote) getSSL(domain, path string) (cert, key string, active bool) {
|
||||||
if _, err := os.Stat(p.getCertPath(domain, "cer")); err == nil {
|
if _, err := os.Stat(p.getCertPath(domain, "cer")); err == nil {
|
||||||
return p.getCertPath(domain, "cer"), p.getCertPath(domain, "key"), true
|
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
|
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 {
|
func (p Promote) updateContent(domain, content string) bool {
|
||||||
fileName := fmt.Sprintf("%s/%s.conf", p.Config.Promoter.Path, domain)
|
fileName := fmt.Sprintf("%s/%s.conf", p.Config.Promoter.Path, domain)
|
||||||
log.Debug().Str("filename", fileName).Msg("Promote to File")
|
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")
|
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()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue