Files

49 lines
2.3 KiB
Bash
Executable File

# Settings shared by the host scripts. Override any of them in `.env` next to this file (gitignored).
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
[ -f "$HERE/.env" ] && . "$HERE/.env"
export LIBVIRT_DEFAULT_URI="${LIBVIRT_DEFAULT_URI:-qemu:///system}"
VM_NAME="${VM_NAME:-sql2016}"
VM_MEMORY_MB="${VM_MEMORY_MB:-8192}"
VM_VCPUS="${VM_VCPUS:-4}"
VM_DISK_GB="${VM_DISK_GB:-80}"
POOL="${POOL:-images}"
NETWORK="${NETWORK:-default}"
DOWNLOADS="${DOWNLOADS:-$HERE/downloads}"
first_file() { local f; for f in "$@"; do [ -f "$f" ] && { echo "$f"; return 0; }; done; return 0; }
BUILD="$HERE/build"
# Windows Server 2019 evaluation ISO (English). Index 2 = Standard Evaluation (Desktop Experience).
WIN_ISO="${WIN_ISO:-$(first_file "$DOWNLOADS"/*SERVER_EVAL*.iso "$DOWNLOADS"/*17763*.iso "$DOWNLOADS"/*[Ss]erver*2019*.iso)}"
WIN_IMAGE_INDEX="${WIN_IMAGE_INDEX:-2}"
# SQL Server media, one of the two:
# SQL_ISO the Developer edition ISO (Visual Studio Dev Essentials)
# SQL_SSEI the Express web installer, SQLServer2016-SSEI-Expr.exe (the VM downloads the media itself)
# and SQL_UPDATE, a service pack applied after the install (the Express installer still online is SP2's).
SQL_ISO="${SQL_ISO:-$(first_file "$DOWNLOADS"/*sql*2016*.iso)}"
SQL_SSEI="${SQL_SSEI:-$(first_file "$DOWNLOADS"/SQLServer2016-SSEI-Expr*.exe)}"
SQL_UPDATE="${SQL_UPDATE:-$(first_file "$DOWNLOADS"/SQLServer2016SP3-*-x64-*.exe)}"
# Match these to the client's server (see README, "What to ask the client").
SQL_COLLATION="${SQL_COLLATION:-Modern_Spanish_CI_AS}"
SQL_DATABASES="${SQL_DATABASES:-cacu cama tea governance}"
SQL_COMPATIBILITY_LEVEL="${SQL_COMPATIBILITY_LEVEL:-130}"
SQL_APP_LOGIN="${SQL_APP_LOGIN:-isss_app}"
# Passwords are generated once by 02-build-setup-iso.sh and kept in `.env`.
WIN_ADMIN_PASSWORD="${WIN_ADMIN_PASSWORD:-}"
SQL_SA_PASSWORD="${SQL_SA_PASSWORD:-}"
SQL_APP_PASSWORD="${SQL_APP_PASSWORD:-}"
SSH_KEY="$HERE/.ssh/id_ed25519"
VM_IP="${VM_IP:-}"
die() { echo "error: $*" >&2; exit 1; }
vm_ssh() { ssh -i "$SSH_KEY" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR \
-o ConnectTimeout=5 "Administrator@$VM_IP" "$@"; }
# virt-install is a Python script; run it with the system Python, which has its `gi` bindings, whatever the PATH says.
virt_install() { /usr/bin/python3 /usr/bin/virt-install "$@"; }