Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into Abhijay007/newPrerequisite
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzlamateen committed Aug 20, 2023
2 parents aabb43a + caa1736 commit d3a733f
Show file tree
Hide file tree
Showing 44 changed files with 1,578 additions and 243 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/test-microk8s-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: test-microk8s-ubuntu

on:
pull_request:
branches: [master]
push:
branches: [master]

jobs:
test-linux:
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Get all script files that have changed
id: changed-files
uses: tj-actions/changed-files@v37
with:
files: |
assets/scripts/**.sh
.github/workflows/test-microk8s-ubuntu.yml
files_ignore: assets/scripts/configure-minikube-linux.sh
since_last_remote_commit: true

- name: Configure MicroK8s Cluster
if: ${{ steps.changed-files.outputs.any_modified == 'true' }}
run: |
ASSETS_PATH="$GITHUB_WORKSPACE/assets"
CONFIGS_PATH="/home/runner/opt/config"
FORCE_DB_REFRESH=true
ENGINE_PATH="/home/runner/opt/etherealengine"
CLUSTER_ID=test
OPS_PATH="/home/runner/opt/ethereal-engine-ops"
PASSWORD= # Github actions run in password-less sudo mode.
ENABLE_RIPPLE_STACK=false
mkdir -p "$CONFIGS_PATH"
curl https://raw.githubusercontent.com/EtherealEngine/ethereal-engine-ops/master/configs/local.microk8s.template.values.yaml -o "$CONFIGS_PATH/test-engine.values.yaml"
sed -i "s,^\([[:space:]]*hostUploadFolder:\).*,\1 '/home/runner/opt/etherealengine/packages/server/upload'," "$CONFIGS_PATH/test-engine.values.yaml"
bash "$ASSETS_PATH/scripts/configure-microk8s-linux.sh" \
-a "$ASSETS_PATH" \
-c "$CONFIGS_PATH" \
-d "$FORCE_DB_REFRESH" \
-f "$ENGINE_PATH" \
-i "$CLUSTER_ID" \
-o "$OPS_PATH" \
-p "$PASSWORD" \
-r "$ENABLE_RIPPLE_STACK"
shell: bash
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ https://user-images.githubusercontent.com/10975502/168554732-86a202b6-053c-4588-

## Getting Started

You can find complete getting started guide [here](https://etherealengine.github.io/etherealengine-docs/docs/tutorials/ethereal_control_center/getting_started).
You can find complete getting started guide [here](https://etherealengine.github.io/etherealengine-docs/docs/host/devops_deployment/tutorials/ethereal_control_center/getting_started/).

Additionally, there are Control Center video tutorials which you can find [here](./TUTORIALS.md). Although some of them might be outdated.

Expand Down Expand Up @@ -94,7 +94,16 @@ cd "C:\Users\%USERNAME%\Downloads"
"Docker Desktop Installer.exe" install --accept-license --installation-dir=C:\Docker
```

### 4. Reporting an Issue
### 4. Git status unavailable on Windows

On Windows, if you are unable to see Git status after cluster configuration and getting following error in logs:

```bash
git configs - "fatal: detected dubious ownership in repository at <path to engine directory>\nTo add an exception for this directory, call:\n\n\tgit config --global --add safe.directory <path to engine directory>\n"
```
This is due to the app not having permissions to read the Git config file. To fix this, run Ethereal Engine Control Center as administrator.

### 5. Reporting an Issue

If you face an issue please report it to [Issues](https://github.com/canonical/microk8s/issues) or reach out to us on [Discord](https://discord.gg/xrf). Also please share following log files:

Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/check-agones-redis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if helm status agones >/dev/null; then
else
echo "agones is not deployed"

helm install -f "$OPS_FOLDER/configs/agones-default-values.yaml" agones agones/agones --version "1.31.0"
helm install -f "$OPS_FOLDER/configs/agones-default-values.yaml" agones agones/agones
sleep 20
fi

Expand Down
20 changes: 15 additions & 5 deletions assets/scripts/check-engine-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ TAG=$7

cd "$ENGINE_FOLDER" || exit

RE_INIT=false

export MYSQL_HOST=localhost
export MYSQL_PORT=3304
DB_STATUS=$(npx cross-env ts-node --swc scripts/check-db-exists-only.ts)
Expand All @@ -38,11 +40,19 @@ if [[ -d $PROJECTS_PATH ]]; then
else
echo "ethereal engine projects does not exists at $PROJECTS_PATH"

RE_INIT=true
fi

if [[ $RE_INIT == true || $FORCE_DB_REFRESH == 'true' ]]; then
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_PORT=3305

# Resetting test db and doing dev reinit to ensure project folders are seeded.
docker container stop etherealengine_test_db
docker container rm etherealengine_test_db
docker container prune --force
npm run dev-docker
npm run dev-reinit
npx ts-node --swc scripts/install-projects.js
fi

export MYSQL_HOST=localhost
Expand Down Expand Up @@ -134,11 +144,11 @@ if [[ $ENGINE_INSTALLED == true ]] && [[ $DB_EXISTS == false || $FORCE_DB_REFRES
echo "Waiting for API pod to be ready. API ready count: $apiCount"
done

helm upgrade --reuse-values -f "$OPS_FOLDER/configs/db-refresh-false.values.yaml" --set taskserver.image.tag="$TAG",api.image.tag="$TAG",instanceserver.image.tag="$TAG",testbot.image.tag="$TAG",client.image.tag="$TAG",testbot.image.tag="$TAG" local etherealengine/etherealengine
helm upgrade --reuse-values -f "$CONFIGS_FOLDER/$CLUSTER_ID-engine.values.yaml" -f "$OPS_FOLDER/configs/db-refresh-false.values.yaml" --set taskserver.image.tag="$TAG",api.image.tag="$TAG",instanceserver.image.tag="$TAG",testbot.image.tag="$TAG",client.image.tag="$TAG",testbot.image.tag="$TAG" local etherealengine/etherealengine
elif [[ $ENGINE_INSTALLED == true ]] && [[ $DB_EXISTS == true ]]; then
echo "Updating Ethereal Engine deployment without populating database"

helm upgrade --reuse-values --set taskserver.image.tag="$TAG",api.image.tag="$TAG",instanceserver.image.tag="$TAG",testbot.image.tag="$TAG",client.image.tag="$TAG",testbot.image.tag="$TAG" local etherealengine/etherealengine
helm upgrade --reuse-values -f "$CONFIGS_FOLDER/$CLUSTER_ID-engine.values.yaml" --set taskserver.image.tag="$TAG",api.image.tag="$TAG",instanceserver.image.tag="$TAG",testbot.image.tag="$TAG",client.image.tag="$TAG",testbot.image.tag="$TAG" local etherealengine/etherealengine
elif [[ $ENGINE_INSTALLED == false ]] && [[ $DB_EXISTS == false || $FORCE_DB_REFRESH == 'true' ]]; then
echo "Installing Ethereal Engine deployment with populating database"

Expand All @@ -160,7 +170,7 @@ elif [[ $ENGINE_INSTALLED == false ]] && [[ $DB_EXISTS == false || $FORCE_DB_REF
fi
echo "Waiting for API pod to be ready. API ready count: $apiCount"
done

sleep 5

helm upgrade --reuse-values -f "$OPS_FOLDER/configs/db-refresh-false.values.yaml" --set taskserver.image.tag="$TAG",api.image.tag="$TAG",instanceserver.image.tag="$TAG",testbot.image.tag="$TAG",client.image.tag="$TAG",testbot.image.tag="$TAG" local etherealengine/etherealengine
Expand Down
49 changes: 49 additions & 0 deletions assets/scripts/check-git-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

#==========
# Ref: https://stackoverflow.com/a/73285729
#==========

#========================
# Verify Git installation
#========================

$IS_GIT_INSTALLED = $false;

$gitVersion = Invoke-Expression "& git --version"

if ($gitVersion) {
Write-Host "git for windows is installed";
$IS_GIT_INSTALLED = $true;
}
else {
Write-Host "git for windows is not installed";
$IS_GIT_INSTALLED = $false;
}

#============
# Install Git
#============

if ($IS_GIT_INSTALLED -eq $false) {
$exePath = "$env:TEMP\git.exe"

# Reference: https://copdips.com/2019/12/Using-Powershell-to-retrieve-latest-package-url-from-github-releases.html
$url = 'https://github.com/git-for-windows/git/releases/latest'
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse()
$realTagUrl = $response.ResponseUri.OriginalString
$version = $realTagUrl.split('/')[-1].Trim('v')
$downloadUrl = $realTagUrl.Replace('tag', 'download') + '/Git-' + $version.Replace('.windows', '') + '-64-bit.exe'

# Download git installer
Write-Host "downloading git for windows using url: $downloadUrl"
Invoke-WebRequest -Uri $downloadUrl -UseBasicParsing -OutFile $exePath

Start-Process powershell -PassThru -WindowStyle hidden -Wait -verb runas -ArgumentList " -file $PSScriptRoot\setup-git-windows.ps1 '$exePath'"

$gitVersion = Invoke-Expression "& git --version"
}

Write-Host "git for windows version is $gitVersion";

exit 0;
50 changes: 50 additions & 0 deletions assets/scripts/check-mok.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

set -e

#===========
# Parameters
#===========

while getopts o:p: flag; do
case "${flag}" in
p) PASSWORD=${OPTARG} ;;
*)
echo "Invalid argument passed" >&2
exit 1
;;
esac
done

if [[ -z $PASSWORD ]]; then
echo "Missing arguments"
exit 1
fi

#===========
# Verify MOK
#===========

if mokutil --version 2>/dev/null | grep -q 'command not found'; then
echo "mokutil is not installed"
echo $(mokutil --version)

echo "$PASSWORD" | sudo -S apt-get update -y
echo "$PASSWORD" | sudo -S apt-get install -y mokutil
else
echo "mokutil is installed"
fi

if echo "$PASSWORD" | sudo -S mokutil --sb-state | grep -q 'SecureBoot enabled'; then
echo "Secureboot is enabled"
if echo "$PASSWORD" | sudo -S mokutil --list-enrolled | grep -q 'Secure Boot Module Signature key'; then
echo "mok is enrolled"
exit 0
else
echo "mok is not enrolled"
#Exit code 2 indicates permission is needed
exit 2
fi
else
echo "SecureBoot is disabled"
fi
3 changes: 2 additions & 1 deletion assets/scripts/configure-microk8s-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ while getopts a:c:d:f:i:o:p:r: flag; do
esac
done

if [[ -z $ASSETS_FOLDER || -z $CONFIGS_FOLDER || -z $FORCE_DB_REFRESH || -z $ENGINE_FOLDER || -z $CLUSTER_ID || -z $OPS_FOLDER || -z $PASSWORD || -z $ENABLE_RIPPLE_STACK ]]; then
if [[ -z $ASSETS_FOLDER || -z $CONFIGS_FOLDER || -z $FORCE_DB_REFRESH || -z $ENGINE_FOLDER || -z $CLUSTER_ID || -z $OPS_FOLDER || -z $ENABLE_RIPPLE_STACK ]]; then
# Allow empty passwords
echo "Missing arguments"
exit 1
fi
Expand Down
43 changes: 41 additions & 2 deletions assets/scripts/configure-microk8s-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function checkExitCode() {
exit $LastExitCode;
}
}

function cleanseString($inputSt) {
$finalString = ''
$inputString = $inputSt -join "`n" | Out-String
Expand Down Expand Up @@ -86,7 +87,7 @@ $wslStatus = cleanseString(wsl --status);
Write-Host "WSL Status: `n$wslStatus";

if ([string]::IsNullOrEmpty($wslStatus) -or $wslStatus -notlike '*: Ubuntu*') {
throw "Make sure WSL is installed and Ubuntu is selected as default distribution.`nhttps://etherealengine.github.io/etherealengine-docs/docs/devops_deployment/microk8s_windows/#install-windows-subsystem-for-linux-wsl";
throw "Make sure WSL is installed and Ubuntu is selected as default distribution.`nhttps://etherealengine.github.io/etherealengine-docs/docs/host/devops_deployment/microk8s_windows/#install-windows-subsystem-for-linux-wsl";
exit 1;
}

Expand All @@ -96,7 +97,7 @@ $wslDockerVersion = cleanseString(wsl docker version);
Write-Host "WSL Docker version: `n$wslDockerVersion";

if ($dockerVersion -notlike '*Server: Docker Desktop*' -or $wslDockerVersion -notlike '*Server: Docker Desktop*') {
throw "Make sure Docker Desktop is installed and Ubuntu WSL Integration is enabled.`nhttps://etherealengine.github.io/etherealengine-docs/docs/devops_deployment/microk8s_windows/#install-docker-desktop";
throw "Make sure Docker Desktop is installed and Ubuntu WSL Integration is enabled.`nhttps://etherealengine.github.io/etherealengine-docs/docs/host/devops_deployment/microk8s_windows/#install-docker-desktop";
exit 1;
}

Expand All @@ -111,6 +112,12 @@ else {
exit 1;
}

#=======================
# Verify Git for Windows
#=======================

& "$PSScriptRoot\check-git-windows.ps1";

#==========
# WSL Login
#==========
Expand Down Expand Up @@ -317,6 +324,38 @@ wsl bash -ic "`"$SCRIPTS_FOLDER/check-engine-repo.sh`" `"$ENGINE_FOLDER`" `"$OPS

checkExitCode;

#=========================
# Ensure directory is safe
#=========================

Write-Host "Checking if repositories are marked as safe directories"

$distro = cleanseString(wsl bash -ic 'echo $WSL_DISTRO_NAME');
$distro = $distro.ToString().Trim();
$isEngineSafe = $true
$isOpsSafe = $true

$engineStatusCommand = 'git -C "\\wsl.localhost\$distro$ENGINE_FOLDER" status';
$opsStatusCommand = 'git -C "\\wsl.localhost\$distro$OPS_FOLDER" status';

$engineOutput = Invoke-Expression "& $engineStatusCommand 2>&1";
$opsOutput = Invoke-Expression "& $opsStatusCommand 2>&1";

if ([String]$engineOutput -match "dubious ownership") {
$isEngineSafe = $false
}

if ([String]$opsOutput -match "dubious ownership") {
$isOpsSafe = $false
}

if (($isEngineSafe -eq $false) -or ($isOpsSafe -eq $false)) {
Write-Host "Marking repositories as safe directories"
Start-Process powershell -PassThru -Wait -verb runas -ArgumentList "-file $PSScriptRoot\set-git-safe-directory.ps1 -e '$ENGINE_FOLDER' -o '$OPS_FOLDER' -d '$distro' -es $isEngineSafe -os $isOpsSafe"
}

Write-Host "Repositories are marked as safe directories"

#============================
# Ensure DB and Redis Running
#============================
Expand Down
13 changes: 13 additions & 0 deletions assets/scripts/configure-minikube-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ bash "$SCRIPTS_FOLDER/check-mysql.sh" "$PASSWORD" "$ENGINE_FOLDER"

checkExitCode

#=======================
# Verify VirtualBox dkms
#=======================

if virtualbox-dkms --version >/dev/null; then
echo "virtualbox-dkms is installed"
else
echo "virtualbox-dkms is not installed"

echo "$PASSWORD" | sudo -S apt update -y
echo "$PASSWORD" | sudo -S sudo apt-get install -y virtualbox-dkms
fi

#==================
# Verify VirtualBox
#==================
Expand Down
Loading

0 comments on commit d3a733f

Please sign in to comment.