From fce294c7b06d5d0797848c0bfda883681217b110 Mon Sep 17 00:00:00 2001 From: Chris Long Date: Thu, 29 Oct 2020 23:28:51 -0700 Subject: [PATCH] Fixing CircleCI Build Steps --- Vagrant/Vagrantfile | 3 +++ Vagrant/bootstrap.sh | 1 + ci/build_machine_bootstrap.sh | 23 ++++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Vagrant/Vagrantfile b/Vagrant/Vagrantfile index 74c12e2..056eeb8 100644 --- a/Vagrant/Vagrantfile +++ b/Vagrant/Vagrantfile @@ -79,6 +79,7 @@ Vagrant.configure("2") do |config| cfg.vm.provision "shell", inline: 'wevtutil el | Select-String -notmatch "Microsoft-Windows-LiveId" | Foreach-Object {wevtutil cl "$_"}', privileged: false cfg.vm.provision "shell", inline: "Set-SmbServerConfiguration -AuditSmb1Access $true -Force", privileged: false cfg.vm.provision "shell", inline: 'cscript c:\windows\system32\slmgr.vbs /dlv', privileged: false + cfg.vm.provision "shell", inline: 'Write-Host "DC Provisioning Complete!"', privileged: false cfg.vm.provider "vmware_desktop" do |v, override| v.vmx["displayname"] = "dc.windomain.local" @@ -146,6 +147,7 @@ Vagrant.configure("2") do |config| cfg.vm.provision "shell", inline: "Set-SmbServerConfiguration -AuditSmb1Access $true -Force", privileged: false cfg.vm.provision "shell", path: "scripts/install-microsoft-ata.ps1", privileged: false cfg.vm.provision "shell", inline: 'cscript c:\windows\system32\slmgr.vbs /dlv', privileged: false + cfg.vm.provision "shell", inline: 'Write-Host "WEF Provisioning Complete!"', privileged: false cfg.vm.provider "vmware_desktop" do |v, override| v.vmx["displayname"] = "wef.windomain.local" @@ -204,6 +206,7 @@ Vagrant.configure("2") do |config| cfg.vm.provision "shell", path: "scripts/install-velociraptor.ps1", privileged: false cfg.vm.provision "shell", path: "scripts/install-autorunstowineventlog.ps1", privileged: false cfg.vm.provision "shell", inline: 'cscript c:\windows\system32\slmgr.vbs /dlv', privileged: false + cfg.vm.provision "shell", inline: 'Write-Host "WIN10 Provisioning Complete!"', privileged: false cfg.vm.provider "vmware_desktop" do |v, override| v.vmx["displayname"] = "win10.windomain.local" diff --git a/Vagrant/bootstrap.sh b/Vagrant/bootstrap.sh index 24bf7f5..6b3b32d 100644 --- a/Vagrant/bootstrap.sh +++ b/Vagrant/bootstrap.sh @@ -550,6 +550,7 @@ main() { install_zeek install_guacamole postinstall_tasks + echo "Logger Provisioning Complete!" } main diff --git a/ci/build_machine_bootstrap.sh b/ci/build_machine_bootstrap.sh index 3369c4e..bf786f3 100755 --- a/ci/build_machine_bootstrap.sh +++ b/ci/build_machine_bootstrap.sh @@ -113,4 +113,25 @@ fi # Start the build in a tmux session sn=tmuxsession tmux new-session -s "$sn" -d -tmux send-keys -t "$sn:0" 'cd /opt/DetectionLab/Vagrant && vagrant up | tee -a vagrant_up_all.log && echo "success" > /var/www/html/index.html || echo "failed" > /var/www/html/index.html; umount /mnt && /usr/local/bin/packet-block-storage-detach' Enter +tmux send-keys -t "$sn:0" 'for host in logger dc wef win10; do vagrant up $host | tee -a vagrant_up_$host.log; COMPLETE="$(grep -ci "$host Provisioning Complete" vagrant_up_$host.log)"; echo "Complete is $COMPLETE for $host" ; if [ "$COMPLETE" -lt 1 ]; then echo "failed" > /var/www/html/index.html; break; fi; done; ALL_SUCCESS="$(grep -ci "Provisioning Complete" vagrant_up_*.log | cut -d : -f 2 | awk '"'"'{ sum += $1 } END { print sum }'"'"')"; echo "All success is $ALL_SUCCESS"; if [ "$ALL_SUCCESS" -eq 4 ]; then echo "success" > /var/www/html/index.html; else echo "failed" > /var/www/html/index.html; fi' Enter + + +# Expanding the send-keys command +# Vagrant isn't great about return codes, so we'll hack this up for now +# for host in logger dc wef win10; +# do +# vagrant up $host | tee -a vagrant_up_$host.log +# COMPLETE="$(grep -ci "$host Provisioning Complete" vagrant_up_$host.log)" +# echo "Complete is $COMPLETE for $host" +# if [ "$COMPLETE" -lt 1 ]; then +# echo "failed" > /var/www/html/index.html +# break +# fi +# done +# ALL_SUCCESS="$(grep -ci "Provisioning Complete" vagrant_up_*.log | cut -d : -f 2 | awk '"'"'{ sum += $1 } END { print sum }'"'"')" +# echo "All success is $ALL_SUCCESS" +# if [ "$ALL_SUCCESS" -eq 4 ]; then +# echo "success" > /var/www/html/index.html +# else +# echo "failed" > /var/www/html/index.html +# fi \ No newline at end of file