Skip to content

Commit eb41bc8

Browse files
allow installer to get cert without email
1 parent 0f68e3f commit eb41bc8

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

cmd/install.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ var installCmd = &cobra.Command{
1919
ui.Greet()
2020

2121
relayDomain, _ := pterm.DefaultInteractiveTextInput.Show("Relay domain name")
22-
email, _ := pterm.DefaultInteractiveTextInput.Show("Email address")
22+
pterm.Println()
23+
pterm.Println(pterm.Yellow("Leave email empty if you don't want to receive notifications from Let's Encrypt about your SSL cert."))
24+
pterm.Println()
25+
ssl_email, _ := pterm.DefaultInteractiveTextInput.Show("Email address")
2326
pubkey, _ := pterm.DefaultInteractiveTextInput.Show("Public key (hex not npub)")
2427

2528
pterm.Println()
@@ -36,7 +39,7 @@ var installCmd = &cobra.Command{
3639
network.ConfigureNginxHttp(relayDomain)
3740

3841
// Step 4: Get SSL certificates
39-
var shouldContinue = network.GetCertificates(relayDomain, email)
42+
var shouldContinue = network.GetCertificates(relayDomain, ssl_email)
4043

4144
if !shouldContinue {
4245
return
@@ -55,6 +58,7 @@ var installCmd = &cobra.Command{
5558
pterm.Println(pterm.Magenta("The installation is complete."))
5659
pterm.Println(pterm.Magenta("You can access your relay at wss://" + relayDomain))
5760
pterm.Println()
61+
pterm.Println(pterm.Magenta("You can re-run this installer with `relaywiz install`."))
5862
},
5963
}
6064

pkg/network/certbot.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func GetCertificates(domainName, email string) bool {
1717

1818
prompt := pterm.DefaultInteractiveContinue.WithOptions(options)
1919

20-
pterm.Println()
20+
pterm.Println()
2121
pterm.Println(pterm.Cyan("Do you want to obtain SSL certificates using Certbot?"))
2222
pterm.Println(pterm.Cyan("This step requires that you already have a configured domain name."))
2323
pterm.Println(pterm.Cyan("You can always re-run this installer after you have configured your domain name."))
24-
pterm.Println()
24+
pterm.Println()
2525

2626
result, _ := prompt.Show()
2727

@@ -48,10 +48,18 @@ func GetCertificates(domainName, email string) bool {
4848
}
4949

5050
spinner.UpdateText("Obtaining SSL certificates...")
51-
cmd := exec.Command("certbot", "certonly", "--webroot", "-w", fmt.Sprintf("/var/www/%s", dirName), "-d", domainName, "--email", email, "--agree-tos", "--no-eff-email", "-q")
52-
err = cmd.Run()
53-
if err != nil {
54-
log.Fatalf("Certbot failed to obtain the certificate for %s: %v", domainName, err)
51+
if email == "" {
52+
cmd := exec.Command("certbot", "certonly", "--webroot", "-w", fmt.Sprintf("/var/www/%s", dirName), "-d", domainName, "--agree-tos", "--no-eff-email", "-q", "--register-unsafely-without-email")
53+
err = cmd.Run()
54+
if err != nil {
55+
log.Fatalf("Certbot failed to obtain the certificate for %s: %v", domainName, err)
56+
}
57+
} else {
58+
cmd := exec.Command("certbot", "certonly", "--webroot", "-w", fmt.Sprintf("/var/www/%s", dirName), "-d", domainName, "--email", email, "--agree-tos", "--no-eff-email", "-q")
59+
err = cmd.Run()
60+
if err != nil {
61+
log.Fatalf("Certbot failed to obtain the certificate for %s: %v", domainName, err)
62+
}
5563
}
5664

5765
spinner.Success("SSL certificates obtained successfully.")

0 commit comments

Comments
 (0)