Skip to content

Commit 45f8d99

Browse files
committed
extract: vm checks
1 parent 508f8bd commit 45f8d99

6 files changed

Lines changed: 43 additions & 43 deletions

File tree

distro_extractor/artix/inc.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ function boot_info() {
1010
echo "Set keytable and start boot from CD/DVD/ISO"
1111
echo "After boot"
1212
echo "Login as $VM_USER:$VM_PASS"
13-
}
14-
15-
function boot_info_qemu() {
1613
echo "Run 'sudo -s'"
1714
echo "Run 'ssh-keygen -A'"
1815
echo "Run '/bin/sshd'"
19-
echo "For future password prompt write $VM_PASS"
2016
}

distro_extractor/artix/install.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
mkfs.ext4 -m 0 -F /dev/sda
2+
mount /dev/sda /mnt/
13
echo "Starting installer"
24

35
# Add archlinux mirrorlist 2021-06-09 https://wiki.artixlinux.org/Main/Repositories#Arch_repositories
@@ -16,9 +18,6 @@ echo "Populating keys from archlinux"
1618
pacman-key --populate archlinux
1719

1820

19-
mkfs.ext4 -m 0 -F /dev/sda
20-
mount /dev/sda /mnt/
21-
2221
basestrap /mnt $(cat /tmp/packages.arch.txt | xargs)
2322
artix-chroot /mnt /bin/sh -c '
2423
echo "Cleaning installation"

distro_extractor/devuan/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
echo "Starting installer"
21
arch='amd64'
32
suite='chimaera'
43

54
mkfs.ext4 -m 0 -F /dev/sda
65
mount /dev/sda /mnt/
6+
echo "Starting installer"
77

88
debootstrap --variant=minbase --merged-usr --arch="$arch" "$suite" /mnt
99
cat /tmp/packages.deb.txt | xargs > /mnt/tmp/packages

presets/ghost/target/root/first_boot_install.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,26 @@ passwd daniel
155155
echo "New password for dan"
156156
passwd dan
157157

158+
chmod o+rx bin/*
159+
cp -a bin/* /usr/bin/
160+
158161
# Install php
159-
echo "Installing php"
160-
mkdir /tmp/php_install
161-
/etc/internet.sh allow builder
162-
cp build_php.sh /tmp/php_install/
163-
cd /tmp/php_install
164-
chown -R builder:bin /tmp/php_install/
165-
su -c "/bin/bash build_php.sh" builder || exit 1
166-
cd src
167-
cp -a target_root/usr/include/php/ /usr/include/
168-
chown -R 0:0 /usr/include/php/
169-
cp target_root/usr/bin/php /usr/bin/php7
170-
chmod o+x /usr/bin/php7
171-
/etc/internet.sh deny builder
172-
rm -rf /tmp/php_install
162+
if [ -z "$1" ]; then
163+
echo "Installing php"
164+
mkdir /tmp/php_install
165+
/etc/internet.sh allow builder
166+
cp build_php.sh /tmp/php_install/
167+
cd /tmp/php_install
168+
chown -R builder:bin /tmp/php_install/
169+
su -c "/bin/bash build_php.sh" builder || exit 1
170+
cd src
171+
cp -a target_root/usr/include/php/ /usr/include/
172+
chown -R 0:0 /usr/include/php/
173+
cp target_root/usr/bin/php /usr/bin/php7
174+
chmod o+x /usr/bin/php7
175+
/etc/internet.sh deny builder
176+
rm -rf /tmp/php_install
177+
fi
173178

174179
cd
175-
chmod o+rx bin/*
176-
cp -a bin/* /usr/bin/
177180
sh reload_iptables.sh

scripts/extract_from_vm.sh

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
source ./.config.sh || exit 1
44

5-
function boot_info_qemu() {
6-
echo "For future password prompt write $VM_PASS"
5+
function boot_info() {
6+
echo -n ""
77
}
88
source "$BASE/distro_extractor/$DISTRO/inc.sh" || dd "File '$BASE/distro_extractor/$DISTRO/inc.sh' cannot be sourced"
99

1010
function ssh_install() {
1111
[ -r "$NICE_PRESET_PATH/packages.${PM}.txt" ] || dd "No packages list for your preset and $DISTRO found ($NICE_PRESET_PATH/packages.${PM}.txt)"
12+
echo "For password prompt write $VM_PASS"
1213
scp -o LogLevel=Error -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P "$2" "$BASE/distro_extractor/$DISTRO/install.sh" "$NICE_PRESET_PATH/packages.${PM}.txt" "$VM_USER@$1:/tmp/"
1314
echo "${VM_PASS:-''}" | ssh -o LogLevel=Error -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$VM_USER@$1" -p "$2" 'sudo --stdin bash /tmp/install.sh'
1415
}
1516

1617
function host_shell_wait() {
1718
echo "Welcome back to user host shell"
1819
echo "Waiting for virtual machine to shutdown for max 60sec"
19-
for i in {1..20}
20+
for i in {1..10}
2021
do
21-
sleep 3
22-
echo "Waiting..."
22+
sleep 6
2323
ps auxf | grep -- "$1" | grep -v grep > /dev/null || break
24+
echo "Waiting..."
2425
done
2526
}
2627

@@ -31,8 +32,6 @@ function from_qemu() {
3132
-net user,hostfwd=tcp::2201-:22 -net nic -enable-kvm -cpu host -smp "$QEMU_PROCESSOR_CORES" &
3233

3334
boot_info
34-
boot_info_qemu
35-
3635
echo "Press enter here"
3736
read
3837

@@ -41,10 +40,11 @@ function from_qemu() {
4140
}
4241

4342
function from_virtualbox() {
44-
VIRTUAL_BOX_VM_ROOT="$VIRTUAL_BOX_VMS_ROOT/$DISTRO"
45-
echo "Startup virtual machine named '$DISTRO' saved at $VIRTUAL_BOX_VM_ROOT"
43+
VIRTUAL_BOX_VM_ROOT="$VIRTUAL_BOX_VMS_ROOT/nice_$DISTRO"
44+
echo "Startup virtual machine named 'nice_$DISTRO' ideally saved at '$VIRTUAL_BOX_VMS_ROOT'"
45+
echo "with one VDI hard disk connected (${DISK_SIZE_GB}GB) called 'nice_$DISTRO.vdi' at path '$VIRTUAL_BOX_VM_ROOT/nice_$DISTRO.vdi'"
4646
echo "with distribution installation CD connected"
47-
echo "one VDI hard disk connected (${DISK_SIZE_GB}GB), one bridged adapter network enabled"
47+
echo "with one bridged adapter network enabled"
4848
boot_info
4949

5050
echo "Run ip addr | grep eth0 | grep inet"
@@ -53,16 +53,19 @@ function from_virtualbox() {
5353
echo "$IP_ADDRESS"
5454

5555
ssh_install "$IP_ADDRESS" 22
56-
host_shell_wait "comment $DISTRO"
56+
host_shell_wait "comment nice_$DISTRO"
5757

58-
[ -r "$VIRTUAL_BOX_VM_ROOT/$DISTRO.vdi" ] || dd "Cannot find VDI '$VIRTUAL_BOX_VM_ROOT/$DISTRO.vdi'"
58+
[ -r "$VIRTUAL_BOX_VM_ROOT/nice_$DISTRO.vdi" ] || dd "Cannot find VDI '$VIRTUAL_BOX_VM_ROOT/nice_$DISTRO.vdi'"
5959
echo "Extracting virtual disk image"
60-
VBoxManage clonehd --format RAW "$VIRTUAL_BOX_VM_ROOT/$DISTRO.vdi" "$NICE_EXTRACT_DISTRO_HDD_IMAGE_PATH"
60+
VBoxManage clonehd --format RAW "$VIRTUAL_BOX_VM_ROOT/nice_$DISTRO.vdi" "$NICE_EXTRACT_DISTRO_HDD_IMAGE_PATH"
6161
}
6262

6363
rm -f "$NICE_EXTRACT_DISTRO_HDD_IMAGE_PATH"
64-
if [[ "$HYPERVISOR" == "virtualbox" ]]; then
64+
if [[ "$HYPERVISOR" == "qemu" ]]; then
65+
from_qemu
66+
elif [[ "$HYPERVISOR" == "virtualbox" ]]; then
6567
from_virtualbox
6668
else
67-
from_qemu
69+
echo "No valid HYPERVISOR found. Expecting QEMU or VirtualBox (VBoxManage at least) providers"
70+
dd "Make sure you have at least one HYPERVISOR installed in PATH"
6871
fi

scripts/vbox_disk_generate.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
source ./.config.sh || exit 1
44

5-
IMAGE_PATH="$VIRTUAL_BOX_VMS_ROOT/nice/nice.vdi"
6-
echo "Using virtual disk $IMAGE_PATH with UUID $VIRTUAL_BOX_NICE_VIRTUAL_HDD_UUID"
5+
IMAGE_PATH="$VIRTUAL_BOX_VMS_ROOT/niceOS.vdi"
6+
echo "Using virtual disk '$IMAGE_PATH' with UUID '$VIRTUAL_BOX_NICE_VIRTUAL_HDD_UUID'"
77
sleep 2
88

9-
./scripts/sync.sh
10-
rm "$IMAGE_PATH"
9+
rm -f "$IMAGE_PATH"
1110
VBoxManage convertfromraw "$STORAGE/sda.img" "$IMAGE_PATH" --uuid "$VIRTUAL_BOX_NICE_VIRTUAL_HDD_UUID"

0 commit comments

Comments
 (0)