fix blank creation label

This commit is contained in:
finn committed 2026-09-22 11:50:39 -07:00
1 parent 5efc3b03a8
commit b8873ddb7b
1 file changed
+8 -4
+8 -4
View File
@@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
# For my use, debian for the little one, ubuntu for the big ones # Valheim dedicated server spawner
# Attaches persistent vol with saved data
# TODO look into whether crossplay is desired
# From .env, following values: # From .env, following values:
# LINODE_API_KEY (used for all Linode API calls below, via curl) # LINODE_API_KEY (used for all Linode API calls below, via curl)
@@ -60,7 +62,9 @@ if [[ "$SCRIPT_ACTION" == "" || "$SCRIPT_ACTION" == "--help" || "$SCRIPT_ACTION"
fi fi
# Create # Create
if [[ "$SCRIPT_ACTION" == "c" ]]; then # Requires a non-empty label: an empty label would send a blank label to the
# Linode API and be generally buggy and annoying in all further operations.
if [[ "$SCRIPT_ACTION" == "c" && -n "$LINODE_LABEL" ]]; then
# Creating a Linode also refreshes the valheim A record, reusing the update # Creating a Linode also refreshes the valheim A record, reusing the update
# block at the bottom of this script. # block at the bottom of this script.
@@ -144,13 +148,13 @@ if [[ "$SCRIPT_ACTION" == "d" ]]; then
# Shut the Linode down cleanly before deleting it, so systemd stops the # Shut the Linode down cleanly before deleting it, so systemd stops the
# Docker container and the Valheim server gets the chance to save the world # Docker container and the Valheim server gets the chance to save the world
# rather than being cut off mid-write. # rather than being cut off mid-write.
echo "Shutting down ID:$INSTANCE_ID..." echo "Soft Shutting down ID:$INSTANCE_ID..."
curl -s -H "Authorization: Bearer $LINODE_API_KEY" \ curl -s -H "Authorization: Bearer $LINODE_API_KEY" \
-X POST https://api.linode.com/v4/linode/instances/$INSTANCE_ID/shutdown | jq . -X POST https://api.linode.com/v4/linode/instances/$INSTANCE_ID/shutdown | jq .
# Give the shutdown time to finish before the instance is deleted. # Give the shutdown time to finish before the instance is deleted.
sleep 30 sleep 30
echo "Deleting instance."
curl -s -H "Authorization: Bearer $LINODE_API_KEY" \ curl -s -H "Authorization: Bearer $LINODE_API_KEY" \
-X DELETE https://api.linode.com/v4/linode/instances/$INSTANCE_ID -X DELETE https://api.linode.com/v4/linode/instances/$INSTANCE_ID
echo "$(date -Iminutes) --- Id:$INSTANCE_ID --- IP:$INSTANCE_IP Destroyed $LINODE_LABEL." >>$LOGFILE echo "$(date -Iminutes) --- Id:$INSTANCE_ID --- IP:$INSTANCE_IP Destroyed $LINODE_LABEL." >>$LOGFILE