Skip to content

Commit

Permalink
hostname and username customization, readability fixes, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zuntrax committed Mar 27, 2018
1 parent f52fcc3 commit 937ee05
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 1,64 @@
port=22022
password="Passw0rd!"
# VirtIO driuver image download URL
driver_url=https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.141-1/virtio-win-0.1.141.iso


# Microsoft VM settings
vm_url=https://az792536.vo.msecnd.net/vms/VMBuild_20171019/VirtualBox/MSEdge/MSEdge.Win10.VirtualBox.zip
initial_pw="Passw0rd!" # default password of the VM
port=22022 # host binding port for SSH to VM


# Configuration to be applied to the VM
hostname="win10"
username="chantal"
password="Passw0rd!" # you probably want to override this...


# Shorthands
d=downloaded
t=temporary
privkey=ssh_host_ed25519_key
pubkey=$(privkey).pub


$(privkey) $(pubkey):
ssh-keygen -f $(privkey) -t ed25519 -N ''

# Test for dependencies. Not sure if this is the right way to handle them.
# TODO: 7z, wget qemu
sshpass:
@which $@ > /dev/null || bash -c 'echo "$@ not found, please install it" && false'
touch $@


# SSH hostkey generation. If not explicitly listed as target or aleady existent,
# the private key will be deleted automatically after ist is deployed to the VM.
$(privkey) $(pubkey):
ssh-keygen -f $(privkey) -t ed25519 -N ''


# Download and unpacking section
$d:
mkdir $@

$d/virtio.iso:
# Google for RedHat Windows virtio drivers
wget -c -O $@ https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.141-1/virtio-win-0.1.141.iso
wget -c -O $@ $(driver_url)

$d/win10.zip: | $d
# New URLS to be found at modern.ie
wget -c -O $@ https://az792536.vo.msecnd.net/vms/VMBuild_20171019/VirtualBox/MSEdge/MSEdge.Win10.VirtualBox.zip
wget -c -O $@ $(vm_url)

$d/win10.ova: $d/win10.zip
unzip -p $^ > $@

$d/win10.vmdk: $d/win10.ova
tar xOf $^ "MSEdge - Win10-disk001.vmdk" > $@


# converted image
win10.qcow2: $d/win10.vmdk
qemu-img convert -O qcow2 $^ $@


# helper files. cheap to create, will be automatically deleted when no longer needed
$t:
mkdir $@

Expand All @@ -42,6 68,8 @@ $t/helper.qcow2: | $t
$t/ssh_host_ecdsa_key.pub: $d/win10.vmdk | $t
7z e -so $^ 'Program Files/OpenSSH/etc/ssh_host_ecdsa_key.pub' > $@


# Initial preparations in the VM. Includes changing hostname, username, password, disabling updates and installing viostor drivers
.ONESHELL: stage1-complete
stage1-complete: | $d/virtio.iso sshpass $t/ssh_host_ecdsa_key.pub $(pubkey) $(privkey) win10.qcow2 $t/helper.qcow2
set -m
Expand All @@ -56,12 84,16 @@ stage1-complete: | $d/virtio.iso sshpass $t/ssh_host_ecdsa_key.pub $(pubkey) $(p
-vga std -display sdl &
while ! nc -z localhost $(port); do sleep 1; done
while ! sshpass -p 'Passw0rd!' ssh -p $(port) -o UserKnownHostsFile=$t/known_host -o ConnectTimeout=1 IEUser@localhost 'echo "Machine is up"' 2> /dev/null; do sleep 1; done
sshpass -p 'Passw0rd!' ssh -p $(port) -o UserKnownHostsFile=$t/known_host IEUser@localhost 'mkdir -p /cygdrive/c/stage1'
sshpass -p 'Passw0rd!' scp -P $(port) -o UserKnownHostsFile=$t/known_host stage1.ps1 $(pubkey) $(privkey) IEUser@localhost:/cygdrive/c/stage1
sshpass -p 'Passw0rd!' ssh -p $(port) -o UserKnownHostsFile=$t/known_host IEUser@localhost 'powershell C:\\stage1\\stage1.ps1 -Password $(password)'
sshpass -p '$(initial_pw)' ssh -p $(port) -o UserKnownHostsFile=$t/known_host IEUser@localhost 'mkdir -p /cygdrive/c/stage1'
sshpass -p '$(initial_pw)' scp -P $(port) -o UserKnownHostsFile=$t/known_host stage1.ps1 $(pubkey) $(privkey) IEUser@localhost:/cygdrive/c/stage1
sshpass -p '$(initial_pw)' ssh -p $(port) -o UserKnownHostsFile=$t/known_host IEUser@localhost 'powershell C:\\stage1\\stage1.ps1 -Hostname $(hostname) -Username $(username) -Password $(password)'
fg
touch $@


# This will install cmake, git, MSVC, vcpkg, python and all the other stuff.
# Since this is project specific, we should have this in a script.
# We don't touch stage2-complete to just use this as a run target right now.
.ONESHELL: stage2-complete
stage2-complete: stage1-complete | win10.qcow2 $(pubkey) $t
set -m
Expand Down

0 comments on commit 937ee05

Please sign in to comment.