Skip to content

Commit 071c699

Browse files
committed
Update
1 parent 396bf87 commit 071c699

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

_do.cr

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ OPUS_BITRATE_KBPS = 256
5454
BANDWIDTH_MB_PER_SEC = 20
5555
IGNORE_HOSTS = ["personal.tracker.com", "tracker.novage.com.ua", "www.googletagmanager.com"]
5656

57+
CERTBOT_DOMAINS = ["media.codonaft.com", "nostr.codonaft.com", "test.codonaft.com"]
58+
5759
MAIN_SITE_CONFIG = Path["_config.yml"]
5860

5961
HOSTS_DIR = Path["_hosts"]
@@ -235,6 +237,8 @@ def build
235237
version: RNOSTR_VERSION,
236238
dependencies: ["g++", "openssl-dev", "openssl-libs-static"],
237239
)
240+
241+
generate_certbot_script(MEDIA_HOST)
238242
end
239243

240244
def configure(config)
@@ -660,6 +664,27 @@ def configure_rnostr(host, config)
660664
ssh(host, add_user_commands("rnostr"))
661665
end
662666

667+
def generate_certbot_script(host)
668+
domains = CERTBOT_DOMAINS.join(',')
669+
user = ssh(host, ["echo -n ${USER}"])
670+
home_dir = BUILD_DIR.join(host).join("home").join(user)
671+
cron_dir = home_dir.join(".periodic/weekly")
672+
output = cron_dir.join("certbot-prod.sh")
673+
674+
Dir.mkdir_p(cron_dir)
675+
File.write(
676+
output,
677+
<<-STRING
678+
#!/usr/bin/env bash
679+
680+
logger 'certbot PROD'
681+
PROD=1 certbot-renew-or-create.sh '#{domains}' 'alopatindev@codonaft.com' /etc/nginx/ssl/codonaft.com/ 2>>/dev/stdout | logger
682+
683+
STRING
684+
)
685+
File.chmod(output, 0o755)
686+
end
687+
663688
def check_icmp(host)
664689
output = `ping -c1 #{host} 2>&1 | grep --extended-regexp '(^ping:|100%|time=[0-9\\.]*)' | sed 's!.*time=!!;s!.*transmitted, !!'`.strip
665690
if output.starts_with?("ping:") || output.includes?("100%")
@@ -1191,8 +1216,7 @@ def filtered_sync(host : String, local_dir : Path, *,
11911216
end
11921217

11931218
def synchronizable(path : Path)
1194-
dir = path.parts[0]
1195-
dir != "home" && path != Path["etc/conf.d/nginx"]
1219+
!path.parts.includes?("USERNAME_WILL_BE_AUTOMATICALLY_REPLACED") && path != Path["etc/conf.d/nginx"]
11961220
end
11971221

11981222
def rsync(source_dir : Path, files : Enumerable(Path), args : Enumerable(String))

0 commit comments

Comments
 (0)