@@ -44,15 +44,83 @@ VBoxManage modifyvm "$MACHINENAME" --graphicscontroller vboxsvga
44
44
VBoxManage modifyvm " $MACHINENAME " --audioout on
45
45
VBoxManage modifyvm " $MACHINENAME " --clipboard bidirectional
46
46
47
+ # we plan to change the password to this random value and keep a record in the description
48
+ BBUSER_PASSWORD=" $( cat /dev/urandom | tr -dc A-Z-a-z-0-9 | head -c10) "
49
+ echo " new password is: $BBUSER_PASSWORD "
50
+ VBoxManage modifyvm " $MACHINENAME " --description " Password for user \" bbuser\" is \" $BBUSER_PASSWORD \" "
51
+
47
52
VBoxManage createhd --filename " $BASEFOLDER /VirtualBox/$MACHINENAME .vdi" --size $(( "$HDD_MB ")) --format VDI
48
53
VBoxManage storagectl " $MACHINENAME " --name " SATA Controller" --add sata --controller " IntelAhci" --hostiocache on
49
54
VBoxManage storageattach " $MACHINENAME " --storagectl " SATA Controller" --port 0 --device 0 --type hdd --medium " $BASEFOLDER /VirtualBox/$MACHINENAME .vdi"
50
55
51
- VBoxManage storageattach " $MACHINENAME " --storagectl " SATA Controller" --port 1 --device 0 --type dvddrive --medium " $ISO "
52
- # VBoxManage storageattach "$MACHINENAME" --storagectl "SATA Controller" --port 2 --device 0 --type dvddrive --medium "${GUESTISO##*/}"
56
+ VBoxManage storageattach " $MACHINENAME " --storagectl " SATA Controller" --port 1 --device 0 --type dvddrive --medium " $ISO "
53
57
VBoxManage modifyvm " $MACHINENAME " --boot1 dvd --boot2 disk --boot3 none --boot4 none
54
58
55
59
# ###############################################################################
56
60
# Run Virtualbox VM
57
61
# ###############################################################################
58
62
VBoxManage startvm " $MACHINENAME " --type gui
63
+
64
+ # wait until the netinstaller ISO is ejected
65
+ # alternatively check for this: "SATA Controller-1-0"="emptydrive"
66
+ while true ; do
67
+ sleep 1
68
+ VBoxManage showvminfo --machinereadable " $MACHINENAME " | grep " \" SATA Controller-IsEjected\" =\" on\" "
69
+
70
+ if [ $? -eq 0 ]; then
71
+ echo " CD ejected from $MACHINENAME "
72
+ break
73
+ fi
74
+ done
75
+
76
+ # ################################################################################
77
+ # Install Guest-Additions
78
+ # ################################################################################
79
+
80
+ # if guest-additions-iso are already installed to this host machine this medium works
81
+ # VBoxManage storageattach "$MACHINENAME" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium additions
82
+ # but we better be sure to have the ISO downloaded ourselves
83
+ VBoxManage storageattach " $MACHINENAME " --storagectl " SATA Controller" --port 1 --device 0 --type dvddrive --medium " ${GUESTISO##*/ } "
84
+
85
+ # ################################################################################
86
+ # Wait till firefox-esr process is active
87
+ # injecting commands into the VM only works if guest additions are working
88
+ # ################################################################################
89
+ while true ; do
90
+ VBoxManage guestcontrol " $MACHINENAME " --username " bbuser" --password " %password%" run --exe /bin/bash -- bash -c " pidof firefox-esr > /dev/null" > /dev/null 2>&1
91
+ if [ $? -eq 0 ]; then
92
+ break
93
+ fi
94
+ sleep 1
95
+ done
96
+
97
+ # ################################################################################
98
+ # set password
99
+ # ################################################################################
100
+ # change password inside VM to a random password
101
+ VBoxManage guestcontrol " $MACHINENAME " --username " bbuser" --password " %password%" run --exe /bin/bash -- bash -c " echo -e \" %password%\n$BBUSER_PASSWORD \n$BBUSER_PASSWORD \" | passwd bbuser"
102
+
103
+ # shutdown appliance
104
+ VBoxManage guestcontrol " $MACHINENAME " --username " bbuser" --password " $BBUSER_PASSWORD " run --exe /bin/bash -- bash -c " sleep 10 && sudo /sbin/shutdown -h now"
105
+
106
+ # wait until VM is powered off
107
+ while true ; do
108
+ sleep 1
109
+ VBoxManage showvminfo --machinereadable " $MACHINENAME " | grep " VMState=\" poweroff\" "
110
+
111
+ if [ $? -eq 0 ]; then
112
+ echo " $MACHINENAME powered down"
113
+ break
114
+ fi
115
+ done
116
+
117
+ # ################################################################################
118
+ # export appliance
119
+ # ################################################################################
120
+ VBoxManage export " $MACHINENAME " --output " $BASEFOLDER /Releases/$MACHINENAME .ova" --ovf10 \
121
+ --options manifest,nomacs \
122
+ --vsys 0 \
123
+ --vmname " $MACHINENAME " \
124
+ --product " BrowserBox" \
125
+ --producturl " https://github.com/Torxgewinde/BrowserBox" \
126
+ --description " Password for user \" bbuser\" is \" $BBUSER_PASSWORD \" "
0 commit comments