Harden kill script and DNS config

This commit is contained in:
Thales Maciel 2026-01-29 16:49:54 -03:00
parent 68cf5f2cbb
commit e10a51558e
No known key found for this signature in database
GPG key ID: 33112E6833C34679
3 changed files with 13 additions and 7 deletions

9
run.sh
View file

@ -42,7 +42,7 @@ MAX_VCPU=16
MIN_RAM=256
MAX_RAM=32768
MAX_DISK_BYTES=$((128 * 1024 * 1024 * 1024))
DNS_SERVERS="${DNS_SERVERS:-1.1.1.1}"
DNS_SERVER="1.1.1.1"
VCPU_COUNT="$DEFAULT_VCPU"
RAM_MIB="$DEFAULT_RAM"
@ -266,10 +266,7 @@ if ! command -v debugfs >/dev/null 2>&1; then
exit 1
fi
RESOLV_TMP="$VM_DIR/resolv.conf"
printf '' >"$RESOLV_TMP"
for ns in ${DNS_SERVERS//,/ }; do
printf 'nameserver %s\n' "$ns" >>"$RESOLV_TMP"
done
printf 'nameserver %s\n' "$DNS_SERVER" >"$RESOLV_TMP"
debugfs -w -R "write $RESOLV_TMP /etc/resolv.conf" "$DISK_PATH" >/dev/null 2>&1 || {
log "failed to write /etc/resolv.conf into rootfs"
exit 1
@ -340,7 +337,7 @@ log "configuring machine"
# Boot source
log "configuring boot source"
KCMD="console=ttyS0 reboot=k panic=1 pci=off root=/dev/vda rw ip=${GUEST_IP}::${BR_IP}:255.255.255.0::eth0:off hostname=${VM_NAME}"
KCMD="console=ttyS0 reboot=k panic=1 pci=off root=/dev/vda rw ip=${GUEST_IP}::${BR_IP}:${DNS_SERVER}:255.255.255.0::eth0:off hostname=${VM_NAME}"
"${CURL_CMD[@]}" --unix-socket "$API_SOCK" -X PUT http://localhost/boot-source \
-H "Content-Type: application/json" \