update dns on spawn
This commit is contained in:
1 parent
3e72ea7e0a
commit
3edf1e4379
1 file changed
+17
-5
+17
-5
@@ -15,6 +15,11 @@ SCRIPT_ACTION=$1
|
||||
LINODE_LABEL=$2
|
||||
LOGFILE="./linodes.log"
|
||||
|
||||
# Set to "true" by any action that should also refresh the valheim A record.
|
||||
# The create action sets this so it reuses the DNS update block below instead
|
||||
# of duplicating the record-updating logic.
|
||||
UPDATE_A_RECORD="false"
|
||||
|
||||
# Pre-existing Valheim volume, attached to every Linode at creation time.
|
||||
# The filesystem (mkfs.ext4) was already created; see voldirections.txt.
|
||||
VOLUME_ID="18073448"
|
||||
@@ -40,12 +45,13 @@ if [[ "$SCRIPT_ACTION" == "" || "$SCRIPT_ACTION" == "--help" || "$SCRIPT_ACTION"
|
||||
echo "Linode helper script: create-linode.sh <action> <label> [args]"
|
||||
echo "Create: create-linode.sh c <new label>"
|
||||
echo " (fixed size: 8GB shared, newest Debian image;"
|
||||
echo " attaches and mounts volume $VOLUME_NAME)"
|
||||
echo " attaches and mounts volume $VOLUME_NAME;"
|
||||
echo " also refreshes the valheim A record)"
|
||||
echo "Destroy: create-linode.sh d <label>"
|
||||
echo "Connect: create-linode.sh x <label>"
|
||||
echo " create-linode.sh x <label> get <remote source> <local dest>"
|
||||
echo " create-linode.sh x <label> put <local source> <remote dest>"
|
||||
echo "Update record: create-linode.sh a <label> <subdomain>"
|
||||
echo "Update record: create-linode.sh a <label>"
|
||||
echo " (updates the existing A record, creates one if missing)"
|
||||
echo "List: create-linode.sh l"
|
||||
echo " (lists all Linodes, no label needed)"
|
||||
@@ -54,6 +60,10 @@ fi
|
||||
# Create
|
||||
if [[ "$SCRIPT_ACTION" == "c" ]]; then
|
||||
|
||||
# Creating a Linode also refreshes the valheim A record, reusing the update
|
||||
# block at the bottom of this script.
|
||||
UPDATE_A_RECORD="true"
|
||||
|
||||
# Fixed size: 8GB shared, newest Debian image
|
||||
INSTANCE_SIZE="g6-standard-4"
|
||||
INSTANCE_IMAGE="linode/debian13"
|
||||
@@ -170,11 +180,13 @@ if [[ "$SCRIPT_ACTION" == "x" ]]; then
|
||||
fi
|
||||
|
||||
# Update record
|
||||
if [[ "$SCRIPT_ACTION" == "a" ]]; then
|
||||
# Runs for the explicit "a" action, and also after a create because the create
|
||||
# block above sets UPDATE_A_RECORD="true".
|
||||
if [[ "$SCRIPT_ACTION" == "a" || "$UPDATE_A_RECORD" == "true" ]]; then
|
||||
|
||||
INSTANCE_IP=$(curl -s -H "Authorization: Bearer $LINODE_API_KEY" https://api.linode.com/v4/linode/instances | jq '.data[] | select(.label == "'$LINODE_LABEL'") | .ipv4[]' | sed -e "s/\"//g")
|
||||
|
||||
NI_SUBDOMAIN=$3
|
||||
NI_SUBDOMAIN="valheim"
|
||||
DOMAIN_RECORDS=$(curl -s -H "Authorization: Bearer $LINODE_API_KEY" \
|
||||
https://api.linode.com/v4/domains/$WHICH_DOMAIN/records)
|
||||
|
||||
@@ -195,7 +207,7 @@ if [[ "$SCRIPT_ACTION" == "a" ]]; then
|
||||
|
||||
echo "Updating records with ip $INSTANCE_IP..."
|
||||
|
||||
#ni7ne:
|
||||
#update record:
|
||||
if [[ -n "$RECORD_ID" ]]; then
|
||||
curl -s -H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $LINODE_API_KEY" \
|
||||
|
||||
Reference in new issue
Block a user