@atriumchat/install 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Atrium 0.7.0
1
+ # Atrium 0.7.2
2
2
 
3
3
  Установщик Atrium и архив релиза, который он распаковывает.
4
4
 
@@ -13,7 +13,7 @@ npx @atriumchat/install
13
13
  Без Node:
14
14
 
15
15
  ```sh
16
- curl -fsSL https://cdn.jsdelivr.net/npm/@atriumchat/install@0.7.0/install.sh | sh
16
+ curl -fsSL https://cdn.jsdelivr.net/npm/@atriumchat/install@0.7.2/install.sh | sh
17
17
  ```
18
18
 
19
19
  Основной адрес и исходники: https://github.com/atriumchat/atrium
Binary file
package/install.sh CHANGED
@@ -52,13 +52,13 @@ shopt -u patsub_replacement 2>/dev/null || true
52
52
  umask 022
53
53
 
54
54
  # == The release this installer puts on the server. deploy/release.sh rewrites these lines.
55
- RELEASE_VERSION=0.7.0
56
- RELEASE_SHA256=bdcf551ad4a4bef983bc8892a5016469514a9d31c5e9b5d69d7e4faf811384b2
55
+ RELEASE_VERSION=0.7.2
56
+ RELEASE_SHA256=36f0ee977dc5bc784b541d270830179e924eefe691a5164463a302f896d04907
57
57
  RELEASE_REPO=atriumchat/atrium
58
58
  # The npm package that mirrors each release's install.sh and tarball (deploy/release.sh publishes it).
59
59
  RELEASE_NPM=@atriumchat/install
60
60
  RELEASE_REGISTRY=ghcr.io/atriumchat
61
- RELEASE_APP_DIGEST=sha256:1d4e6b5773fdbe7594487528c73b12feb8919caf86265bdfa8f330b55beeae0f
61
+ RELEASE_APP_DIGEST=sha256:7e0aa37b22725f7cd1ce91b882a0c0611fdc214cb2c2b1937363ea398c9b15e1
62
62
  RELEASE_CADDY_DIGEST=sha256:cd2cf5a7985bb21afa94786e9779dcf972b89e7e281a0a9b616acc659ce30bbf
63
63
 
64
64
  # == gum, for this run only.
@@ -411,12 +411,26 @@ add_app_key() {
411
411
  chmod 700 /root/.ssh
412
412
  touch /root/.ssh/authorized_keys
413
413
  chmod 600 /root/.ssh/authorized_keys
414
- grep -qxF "$key" /root/.ssh/authorized_keys || printf '%s\n' "$key" >>/root/.ssh/authorized_keys
414
+ # Already there (a run again from the app), maybe already pinned to the agent: once is enough.
415
+ grep -qF "${key#ssh-ed25519 }" /root/.ssh/authorized_keys || printf '%s\n' "$key" >>/root/.ssh/authorized_keys
415
416
  log "desktop app key added for root"
416
417
  }
417
418
 
419
+ # Once Atrium runs, the desktop app's key (the line with the comment atrium-app) stops being root: it is pinned to
420
+ # deploy/atrium-agent, which only understands status, update, backup and logs, and loses forwarding and a terminal.
421
+ # The install itself still had the full key (it may need running again); an update pins servers installed before.
422
+ lock_app_key() {
423
+ local f=/root/.ssh/authorized_keys agent=$ATRIUM_DIR/deploy/atrium-agent
424
+ [[ -f $f && -x $agent ]] || return 0
425
+ grep -Eq '^ssh-ed25519 [^ ]+ atrium-app[[:space:]]*$' "$f" || return 0
426
+ sed -i -E "s|^(ssh-ed25519 [^ ]+ atrium-app)[[:space:]]*\$|restrict,command=\"$agent\" \\1|" "$f"
427
+ log "desktop app key pinned to $agent"
428
+ }
429
+
418
430
  # The desktop app sets the address up just before it installs (a free name on dedyn.io, or the person's own
419
- # records), so the installer waits for the names to answer here: the certificates can then come at once.
431
+ # records), and a new name can take minutes to reach every resolver. Only the start and the certificates need it, so
432
+ # the installer waits here after everything else is done (install_all): the wait mostly hides behind Docker and the
433
+ # images instead of holding the install up from its second step.
420
434
  wait_dns() {
421
435
  [[ ${ATRIUM_PROGRESS:-} == 1 ]] || return 0
422
436
  local i
@@ -424,12 +438,27 @@ wait_dns() {
424
438
  for i in $(seq 1 60); do
425
439
  check_dns
426
440
  progress sub "Записей на месте: $DNS_HITS из 3"
427
- (( DNS_OK )) && break
441
+ (( DNS_OK )) && dns_everywhere && break
442
+ (( DNS_OK )) && progress sub "Адрес расходится по интернету"
428
443
  sleep 3
429
444
  done
430
445
  progress "done" address
431
446
  }
432
447
 
448
+ # Every name answers from both Cloudflare and Google with this server's address. Let's Encrypt asks from its own
449
+ # resolvers, and a name one big resolver has while another still fails it (dedyn.io's delegation shows up a little
450
+ # later in some) can fail the certificate; Caddy then waits longer and longer before it tries again (step_https).
451
+ dns_everywhere() {
452
+ local host url out
453
+ for host in "$DOMAIN" "app.$DOMAIN" "$TURN_HOST.$DOMAIN"; do
454
+ for url in "https://cloudflare-dns.com/dns-query?name=$host&type=A" "https://dns.google/resolve?name=$host&type=A"; do
455
+ out=$(curl -fsS --max-time 5 -H 'accept: application/dns-json' "$url" 2>/dev/null) || return 1
456
+ [[ $out == *'"Status":0'* || $out == *'"Status": 0'* ]] || return 1
457
+ [[ -z ${SERVER_IP:-} || $out == *"\"$SERVER_IP\""* ]] || return 1
458
+ done
459
+ done
460
+ }
461
+
433
462
  print_checks() {
434
463
  local item
435
464
  for item in "${CHECK_LINES[@]}"; do
@@ -810,7 +839,7 @@ step_files() {
810
839
  progress sub "Раскладываем файлы"
811
840
  mkdir -p "$stage" || return
812
841
  tar -xzf "$tgz" -C "$stage" --strip-components=1 --no-same-owner || return
813
- for f in deploy/docker-compose.yml deploy/Caddyfile deploy/backup.sh deploy/livekit.yaml.tmpl; do
842
+ for f in deploy/docker-compose.yml deploy/Caddyfile deploy/backup.sh deploy/atrium-agent deploy/livekit.yaml.tmpl; do
814
843
  [[ -f $stage/$f ]] || { echo "Release has no $f"; return 1; }
815
844
  done
816
845
  mkdir -p "$ATRIUM_DIR/deploy" "$ATRIUM_DIR/landing" || return
@@ -819,7 +848,7 @@ step_files() {
819
848
  touch "$ATRIUM_TMP/caddyfile-changed" || return
820
849
  fi
821
850
  install -m 644 "$stage/deploy/docker-compose.yml" "$stage/deploy/Caddyfile" "$stage/deploy/livekit.yaml.tmpl" "$ATRIUM_DIR/deploy/" || return
822
- install -m 755 "$stage/deploy/backup.sh" "$ATRIUM_DIR/deploy/" || return
851
+ install -m 755 "$stage/deploy/backup.sh" "$stage/deploy/atrium-agent" "$ATRIUM_DIR/deploy/" || return
823
852
  return 0
824
853
  }
825
854
 
@@ -1062,11 +1091,20 @@ step_up() {
1062
1091
  docker image prune -f
1063
1092
  }
1064
1093
 
1094
+ # The certificate. Caddy asks for it as it starts; when that first try fails (the name not seen everywhere yet), it
1095
+ # waits a minute, then two, four… before the next. A minute without one, Caddy is started again, which asks at once:
1096
+ # the certificate comes within a minute of the name being everywhere instead of after Caddy's next turn. Four minutes
1097
+ # in all; past that it's left to Caddy and the install still ends (screen_done says so).
1065
1098
  step_https() {
1066
1099
  local i
1100
+ cd "$ATRIUM_DIR/deploy" || return
1067
1101
  progress sub "Ждём сертификат от Let's Encrypt"
1068
- for i in $(seq 1 30); do
1102
+ for i in $(seq 1 80); do
1069
1103
  curl -fsS --max-time 5 -o /dev/null --resolve "app.$DOMAIN:443:127.0.0.1" "https://app.$DOMAIN/api/setup" && return 0
1104
+ if (( i % 20 == 0 )); then
1105
+ progress sub "Просим сертификат ещё раз"
1106
+ docker compose restart caddy >/dev/null 2>&1 || true
1107
+ fi
1070
1108
  sleep 3
1071
1109
  done
1072
1110
  return 1
@@ -1120,6 +1158,10 @@ install_all() {
1120
1158
  run "Настройки и ключи" step_config
1121
1159
  if [[ -d /run/systemd/system ]]; then run "Ночные бэкапы" step_backups; fi
1122
1160
  run "Скачиваем образы" step_pull
1161
+ if [[ ${ATRIUM_PROGRESS:-} == 1 ]]; then
1162
+ wait_dns
1163
+ check_dns
1164
+ fi
1123
1165
  run "Запуск" step_up
1124
1166
  HTTPS_OK=0
1125
1167
  if (( DNS_OK )); then
@@ -1387,14 +1429,15 @@ run_quiet() {
1387
1429
  die "Сервер не готов."
1388
1430
  fi
1389
1431
  progress "done" check
1390
- wait_dns
1432
+ # From the desktop app the address is waited for later, right before the start (install_all).
1391
1433
  check_dns
1392
- if (( ! DNS_OK )); then
1434
+ if (( ! DNS_OK )) && [[ ${ATRIUM_PROGRESS:-} != 1 ]]; then
1393
1435
  say
1394
1436
  warn "DNS ещё не готов:"
1395
1437
  print_dns
1396
1438
  fi
1397
1439
  install_all
1440
+ lock_app_key
1398
1441
  screen_done
1399
1442
  }
1400
1443
 
@@ -1432,6 +1475,7 @@ wizard() {
1432
1475
  header 4
1433
1476
  title "Установка"
1434
1477
  install_all
1478
+ lock_app_key
1435
1479
  screen_done
1436
1480
  return
1437
1481
  ;;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@atriumchat/install",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Atrium installer and release files: npx @atriumchat/install, or curl -fsSL https://cdn.jsdelivr.net/npm/@atriumchat/install/install.sh | sh",
5
5
  "homepage": "https://github.com/atriumchat/atrium",
6
6
  "repository": { "type": "git", "url": "git+https://github.com/atriumchat/atrium.git" },
7
7
  "license": "AGPL-3.0-only",
8
8
  "bin": { "atrium-install": "install.sh" },
9
- "files": ["install.sh", "atrium-0.7.0.tar.gz", "LICENSE"]
9
+ "files": ["install.sh", "atrium-0.7.2.tar.gz", "LICENSE"]
10
10
  }
Binary file