diff --git a/samples/features/sql-big-data-cluster/bootstrap-sample-db.cmd b/samples/features/sql-big-data-cluster/bootstrap-sample-db.cmd index 104e0eb8..ff589d1d 100644 --- a/samples/features/sql-big-data-cluster/bootstrap-sample-db.cmd +++ b/samples/features/sql-big-data-cluster/bootstrap-sample-db.cmd @@ -4,9 +4,8 @@ setlocal enableextensions set CLUSTER_NAMESPACE=%1 set SQL_MASTER_IP=%2 set SQL_MASTER_SA_PASSWORD=%3 -set BACKUP_FILE_PATH=%~4 -set KNOX_IP=%5 -set KNOX_PASSWORD=%6 +set KNOX_IP=%3 +set KNOX_PASSWORD=%4 set STARTUP_PATH=%~dp0 if NOT DEFINED CLUSTER_NAMESPACE goto :usage @@ -19,15 +18,19 @@ if NOT DEFINED KNOX_PASSWORD set KNOX_PASSWORD=%SQL_MASTER_SA_PASSWORD% set SQL_MASTER_INSTANCE=%SQL_MASTER_IP%,31433 set KNOX_ENDPOINT=%KNOX_IP%:30443 -echo Verifying sqlcmd.exe is in path & CALL WHERE /Q sqlcmd.exe || GOTO exit -echo Verifying bcp.exe is in path & CALL WHERE /Q bcp.exe || GOTO exit -echo Verifying kubectl.exe is in path & CALL WHERE /Q kubectl.exe || echo HINT: Install the kubernetes-cli - https://kubernetes.io/docs/tasks/tools/install-kubectl && GOTO exit -echo Verifying curl.exe is in path & CALL WHERE /Q curl.exe || echo HINT: Install curl - https://curl.haxx.se/download.html && GOTO exit +for %%F in (sqlcmd.exe bcp.exe kubectl.exe curl.exe) do ( + echo Verifying %%F is in path & CALL WHERE /Q %%F || GOTO exit +) + +pushd "%tmp%" +echo Downloading sample database backup file... +curl -G "https://sqlchoice.blob.core.windows.net/sqlchoice/static/tpcxbb_1gb.bak" -o tpcxbb_1gb.bak REM Copy the backup file, restore the database, create necessary objects and data file echo Copying database backup file... -pushd "%BACKUP_FILE_PATH%" %DEBUG% kubectl cp tpcxbb_1gb.bak mssql-master-pool-0:/var/opt/mssql/data -c mssql-server -n %CLUSTER_NAMESPACE% || goto exit + +del tpcxbb_1gb.bak >NUL popd echo Configuring sample database... diff --git a/samples/features/sql-big-data-cluster/bootstrap-sample-db.sh b/samples/features/sql-big-data-cluster/bootstrap-sample-db.sh index 7ad160cc..33cf879c 100644 --- a/samples/features/sql-big-data-cluster/bootstrap-sample-db.sh +++ b/samples/features/sql-big-data-cluster/bootstrap-sample-db.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e set -o pipefail -USAGE_MESSAGE="USAGE: $0 []" +USAGE_MESSAGE="USAGE: $0 []" ERROR_MESSAGE="Bootstrap of the sample database failed." # Print usage if mandatory parameters are missing @@ -9,26 +9,34 @@ ERROR_MESSAGE="Bootstrap of the sample database failed." : "${2:?$USAGE_MESSAGE}" : "${3:?$USAGE_MESSAGE}" : "${4:?$USAGE_MESSAGE}" -: "${5:?$USAGE_MESSAGE}" : "${DEBUG=}" # Save the input parameters CLUSTER_NAMESPACE=$1 SQL_MASTER_IP=$2 SQL_MASTER_SA_PASSWORD=$3 -BACKUP_FILE_PATH=$4 -KNOX_IP=$5 -KNOX_PASSWORD=$6 +KNOX_IP=$4 +KNOX_PASSWORD=$5 # If Knox password is not supplied then default to SQL Master password KNOX_PASSWORD=${KNOX_PASSWORD:=$SQL_MASTER_SA_PASSWORD} SQL_MASTER_INSTANCE=$SQL_MASTER_IP,31433 KNOX_ENDPOINT=$KNOX_IP:30443 + +for util in sqlcmd.exe bcp.exe kubectl.exe curl.exe + do + echo Verifying $util is in path & which $util 1>NUL 2>NUL || (echo Unable to locate $util && exit 1) +done + # Copy the backup file, restore the database, create necessary objects and data file +pushd "/tmp" +echo Downloading sample database backup file... +$DEBUG curl -G "https://sqlchoice.blob.core.windows.net/sqlchoice/static/tpcxbb_1gb.bak" -o tpcxbb_1gb.bak + echo Copying database backup file... -pushd "$BACKUP_FILE_PATH" $DEBUG kubectl cp tpcxbb_1gb.bak mssql-master-pool-0:/var/opt/mssql/data -c mssql-server -n $CLUSTER_NAMESPACE || (echo $ERROR_MESSAGE && exit 1) +rm tpcxbb_1gb.bak popd echo Configuring sample database...