Skip to content

Commit 9c9b5a0

Browse files
committed
Update openwrt-vm.sh
1 parent 5334c65 commit 9c9b5a0

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

‎vm/openwrt-vm.sh‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ function advanced_settings() {
341341
fi
342342
}
343343

344-
345344
vm_preflight
346345
vm_start_script "Use Default Settings?\n\nDefaults:\n• 1 CPU Core\n• 256 MB RAM\n• 1 GB Disk" 13 58
347346
post_to_api_vm
@@ -388,29 +387,24 @@ if [[ -z "$DISK_REF" ]]; then
388387
exit 226
389388
fi
390389

391-
qm set $VMID \
390+
$STD qm set $VMID \
392391
-scsi0 ${DISK_REF} \
393392
-boot order=scsi0 \
394-
-tags community-script >/dev/null
393+
-tags community-script
395394
msg_ok "Attached disk"
396395

397396
msg_info "Resizing disk to ${DISK_SIZE}"
398397
qm disk resize "$VMID" scsi0 "${DISK_SIZE}" >/dev/null
399398
msg_ok "Resized disk to ${DISK_SIZE}"
400399

401400
set_description
402-
403401
msg_ok "Created OpenWrt VM ${CL}${BL}(${HN})"
404402

405-
# Started here whatever START_VM says: the network has to be configured from
406-
# inside the guest before the VM is any use.
407403
msg_info "Booting OpenWrt to configure its network interfaces"
408404
$STD qm start $VMID
409405
sleep 15
410406
VM_STATE=""
411407
for i in {1..30}; do
412-
# A missing config means the VM is gone, not slow. Waiting out the other 29
413-
# tries only bought 29 more copies of the same error.
414408
if ! VM_STATE="$(qm status "$VMID" 2>&1)"; then
415409
msg_error "VM $VMID no longer exists: ${VM_STATE}"
416410
exit 226
@@ -427,19 +421,19 @@ sleep 5
427421
msg_ok "OpenWrt is running"
428422

429423
msg_info "Configuring network interfaces in OpenWrt"
430-
send_line_to_vm ""
431-
send_line_to_vm "uci delete network.@device[0]"
432-
send_line_to_vm "uci set network.wan=interface"
433-
send_line_to_vm "uci set network.wan.device=eth1"
434-
send_line_to_vm "uci set network.wan.proto=dhcp"
435-
send_line_to_vm "uci delete network.lan"
436-
send_line_to_vm "uci set network.lan=interface"
437-
send_line_to_vm "uci set network.lan.device=eth0"
438-
send_line_to_vm "uci set network.lan.proto=static"
439-
send_line_to_vm "uci set network.lan.ipaddr=${LAN_IP_ADDR}"
440-
send_line_to_vm "uci set network.lan.netmask=${LAN_NETMASK}"
441-
send_line_to_vm "uci commit"
442-
send_line_to_vm "poweroff"
424+
$STD send_line_to_vm ""
425+
$STD send_line_to_vm "uci delete network.@device[0]"
426+
$STD send_line_to_vm "uci set network.wan=interface"
427+
$STD send_line_to_vm "uci set network.wan.device=eth1"
428+
$STD send_line_to_vm "uci set network.wan.proto=dhcp"
429+
$STD send_line_to_vm "uci delete network.lan"
430+
$STD send_line_to_vm "uci set network.lan=interface"
431+
$STD send_line_to_vm "uci set network.lan.device=eth0"
432+
$STD send_line_to_vm "uci set network.lan.proto=static"
433+
$STD send_line_to_vm "uci set network.lan.ipaddr=${LAN_IP_ADDR}"
434+
$STD send_line_to_vm "uci set network.lan.netmask=${LAN_NETMASK}"
435+
$STD send_line_to_vm "uci commit"
436+
$STD send_line_to_vm "poweroff"
443437
msg_ok "Network interfaces configured in OpenWrt"
444438

445439
msg_info "Waiting for OpenWrt to shut down"

0 commit comments

Comments
 (0)