Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.

2 downloads

network-computer/infra/dns-point.sh
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/demo/network-computer.git
HTTPS
https://gitstable.com/git/demo/network-computer.git
SSH
ssh://git@gitstable.com:2222/demo/network-computer.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

GitStable demo README: say this is a copy and where the original is cde82c2 13 hours, 36 minutes ago History
dns-point.sh · 1.4 KB · 27 lines
1#!/bin/sh
2# Point <fqdn> at <ip> with an A record in DigitalOcean DNS (create or update).
3# Needs the domain's DNS hosted on DigitalOcean and a doctl token with write
4# access to domains. TTL is 60s because a droplet's IP changes on every rebuild.
5#
6# infra/dns-point.sh nc.example.com 203.0.113.5
7set -e
8FQDN=${1:?usage: dns-point.sh <fqdn> <ip>}; IP=${2:?usage: dns-point.sh <fqdn> <ip>}
9# the longest DigitalOcean zone that is a suffix of the name
10ZONE=$(doctl compute domain list --format Domain --no-header | awk -v f="$FQDN" '
11 { z=$1; n=length(z)
12 if (length(f) > n && substr(f, length(f)-n) == "." z && n > best) { best=n; zone=z } }
13 END { print zone }')
14[ -n "$ZONE" ] || {
15 echo "no DigitalOcean DNS zone covers $FQDN."
16 echo "Either host the domain's DNS on DigitalOcean (see docs/DOMAIN.md), or create the"
17 echo "A record $FQDN -> $IP at your DNS provider yourself and re-run with NC_DOMAIN set."
18 exit 1
19}
20REC=${FQDN%."$ZONE"}
21ID=$(doctl compute domain records list "$ZONE" --format ID,Type,Name --no-header | awk -v n="$REC" '$2=="A" && $3==n{print $1; exit}')
22if [ -n "$ID" ]; then
23 doctl compute domain records update "$ZONE" --record-id "$ID" --record-data "$IP" --record-ttl 60 >/dev/null
24else
25 doctl compute domain records create "$ZONE" --record-type A --record-name "$REC" --record-data "$IP" --record-ttl 60 >/dev/null
26fi
27echo "$FQDN -> $IP (A record in $ZONE, ttl 60)"