#**************************************************************************#
#**  QUADARAX DEPLOYMENT SCRIPTS                                         **#
#**  File: 000_bootstrap.ps1                                             **#
#**  Description: Defines startup properies, libraries, constants        **#
#**               to work with QDS                                       **#
#**  Version: 1.0.                                                       **#
#**  Updated: 26.7.2019                                                  **# 
#**************************************************************************#

# Console settings
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

if ($global:NonInteractive -ne $true)
{
    $a = (Get-Host).UI.RawUI
    $a.WindowTitle = "QUADARAX DEPLOYMENT CONSOLE"
}


# Startup location
$scriptpath = $MyInvocation.MyCommand.Path
$currentDir = Split-Path $scriptpath

Write-Host ("* QUADARAX DEPLOYMENT CONSOLE *") -ForegroundColor Green
Write-Host "       _____  ____   ___  " -ForegroundColor Green
Write-Host "      (  _  )(  _ \ / __) " -ForegroundColor Green
Write-Host "       )(_)(  )(_) )\__ \ " -ForegroundColor Green
Write-Host "      (___/\\(____/ (___/ " -ForegroundColor Green

# Check permissions
Write-Host "Checking permission..."  -foregroundcolor DarkGray
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
    Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!`n`n"
    Write-Host "Loading failed..." -foregroundcolor Red
    Break
}

# Set variable that bootstrap script loaded
$global:SpaceScriptLoaded = $true

# Loads prerequisities
. .\001_settings.ps1
. .\002_library.ps1

Write-Host "QDS bootstrap was set-up." -ForegroundColor DarkGray
Write-Host ("Project directory: {0}" -f $projectDir) -ForegroundColor Green
