Skip to content

Commit

Permalink
feat: standard output
Browse files Browse the repository at this point in the history
  • Loading branch information
pupilcc committed Jan 9, 2024
1 parent 7c8e1e2 commit 77aff87
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions middleware/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package middleware

import (
"autossl/internal/service"
"fmt"
"go.uber.org/zap"
"os"
"os/exec"
Expand Down Expand Up @@ -47,19 +48,21 @@ func Issue(name string) {
alias := os.Getenv("ACME_ALIAS")

cmd := exec.Command(filepath.Join(usr.HomeDir, ".acme.sh/acme.sh"), "--issue", "--dns", dns, "-d", name, "--challenge-alias", alias)
_, err := cmd.CombinedOutput()
output, err := cmd.CombinedOutput()
if err != nil {
logger.Error("Running command failed with %s\n", zap.String("error", err.Error()))
logger.Error("Running command failed", zap.String("error:", err.Error()))
}
fmt.Printf(string(output))
}

func Install(name string, id string) {
logger := GetLogger()

cmd := exec.Command(filepath.Join(usr.HomeDir, ".acme.sh/acme.sh"), "--install-cert", "-d", name, "--key-file", filepath.Join(service.CertPath, id+".key"), "--fullchain-file", filepath.Join(service.CertPath, id+".crt"))
logger.Info("command", zap.String("Running command:", strings.Join(cmd.Args, " ")))
_, err := cmd.CombinedOutput()
output, err := cmd.CombinedOutput()
if err != nil {
logger.Error("Running command failed with %s\n", zap.String("error", err.Error()))
logger.Error("Running command failed", zap.String("error:", err.Error()))
}
fmt.Printf(string(output))
}

0 comments on commit 77aff87

Please sign in to comment.