volume checkpoint
This commit is contained in:
+28
-5
@@ -13,15 +13,22 @@ source .env
|
||||
#ROOT_PASS="StartRootPass5678"
|
||||
SCRIPT_ACTION=$1
|
||||
LINODE_LABEL=$2
|
||||
# ni7ne 1997630
|
||||
# oily 2111036
|
||||
WHICH_DOMAIN="2111036"
|
||||
LOGFILE="./linodes.log"
|
||||
|
||||
# Pre-existing Valheim volume, attached to every Linode at creation time.
|
||||
# The filesystem (mkfs.ext4) was already created; see voldirections.txt.
|
||||
VOLUME_ID="18073448"
|
||||
VOLUME_NAME="ValVol202609"
|
||||
VOLUME_DEVICE="/dev/disk/by-id/scsi-0Linode_Volume_$VOLUME_NAME"
|
||||
VOLUME_MOUNT="/mnt/$VOLUME_NAME"
|
||||
|
||||
if [[ "$SCRIPT_ACTION" == "" || "$SCRIPT_ACTION" == "--help" || "$SCRIPT_ACTION" == "-?" ]]; then
|
||||
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 " (fixed size: 8GB shared, newest Debian image;"
|
||||
echo " attaches and mounts volume $VOLUME_NAME)"
|
||||
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>"
|
||||
@@ -56,11 +63,27 @@ if [[ "$SCRIPT_ACTION" == "c" ]]; then
|
||||
echo "Instance IP: $INSTANCE_IP"
|
||||
echo "Instance ID: $INSTANCE_ID"
|
||||
|
||||
# Attach the pre-existing Valheim volume (see voldirections.txt).
|
||||
# The volume must be attached to a running Linode; the image boots on create.
|
||||
curl -s -H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $LINODE_API_KEY" \
|
||||
-X POST -d '{
|
||||
"linode_id": '$INSTANCE_ID',
|
||||
"persist_across_boots": true
|
||||
}' \
|
||||
https://api.linode.com/v4/volumes/$VOLUME_ID/attach | jq .
|
||||
|
||||
# Give the volume a moment to appear on the instance before mounting it.
|
||||
sleep 15
|
||||
|
||||
# SSH CONFIG BLOCK
|
||||
#ssh -o "StrictHostKeyChecking no" root@$INSTANCE_IP "apt update && apt install -y jq"
|
||||
ssh -o "StrictHostKeyChecking no" root@$INSTANCE_IP "mkdir -p $VOLUME_MOUNT"
|
||||
ssh -o "StrictHostKeyChecking no" root@$INSTANCE_IP "mount $VOLUME_DEVICE $VOLUME_MOUNT"
|
||||
# Mount on every boot, without duplicating the line on re-runs.
|
||||
ssh -o "StrictHostKeyChecking no" root@$INSTANCE_IP "grep -q '$VOLUME_DEVICE' /etc/fstab || echo '$VOLUME_DEVICE $VOLUME_MOUNT ext4 defaults,noatime,nofail 0 2' >> /etc/fstab"
|
||||
# END SSH CONFIG BLOCK
|
||||
|
||||
echo "$(date -Iminutes) --- Id:$INSTANCE_ID --- IP:$INSTANCE_IP Summoned $LINODE_LABEL." >>$LOGFILE
|
||||
echo "$(date -Iminutes) --- Id:$INSTANCE_ID --- IP:$INSTANCE_IP Summoned $LINODE_LABEL with volume $VOLUME_ID." >>$LOGFILE
|
||||
echo "Started with root pass $ROOT_PASS"
|
||||
|
||||
fi
|
||||
@@ -113,7 +136,7 @@ if [[ "$SCRIPT_ACTION" == "a" ]]; 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
|
||||
echo "Previous value ni7ne:"
|
||||
echo "Previous value:"
|
||||
curl -s -H "Authorization: Bearer $LINODE_API_KEY" \
|
||||
https://api.linode.com/v4/domains/$WHICH_DOMAIN/records | jq .
|
||||
|
||||
|
||||
Reference in New Issue
Block a user