diff --git a/scripts/docker-setup.sh b/scripts/docker-setup.sh index 3c1a018b735..1de0e89b873 100755 --- a/scripts/docker-setup.sh +++ b/scripts/docker-setup.sh @@ -1,15 +1,129 @@ +# #!/bin/bash + +# # Initialize default values +# VERSION="" +# NODE_NAME="" +# NODE_SIDE_TYPE="high" +# NODE_TYPE="" +# PORT="" + +# # Function to display usage +# usage() { +# echo "Usage: $0 [-v|--version ] [-n|--name ] [-s|--side ] [-t|--type ] [-p|--port ]" +# exit 1 +# } + +# # Parse command line options +# while [[ "$#" -gt 0 ]]; do +# case "$1" in +# -v|--version) +# VERSION="$2" +# shift 2 +# ;; +# -n|--name) +# NODE_NAME="$2" +# shift 2 +# ;; +# -s|--side) +# NODE_SIDE_TYPE="$2" +# shift 2 +# ;; +# -t|--type) +# NODE_TYPE="$2" +# shift 2 +# ;; +# -p|--port) +# PORT="$2" +# shift 2 +# ;; +# *) +# usage +# ;; +# esac +# done + +# # Check if all required options are set +# if [[ -z "$VERSION" || -z "$NODE_NAME" || -z "$NODE_TYPE" || -z "$PORT" ]]; then +# echo "All options are required." +# usage +# fi + + +# [ -f "$TGZ_FILE" ] && rm -f "$TGZ_FILE" +# [ -f "$COMPOSE_FILE" ] && rm -f "$COMPOSE_FILE" + + +# #Use curl to download the fille from azure blob storage +# curl -L -o syft-file.tgz "https://openminedblob.blob.core.windows.net/syft-files/syft-compose-file.tar.gz" + + +# # Unzip the .tgz file +# tar -xzf syft-file.tgz + +# #Change directory to the unzipped folder +# cd syft-compose-files + + +# # Detect OS +# OS="linux" +# case "$(uname)" in +# Darwin) +# OS="mac" +# ;; +# esac + +# # Assuming the .env file is in the current directory after unzipping +# # Update the VERSION, NODE_NAME, NODE_SIDE_TYPE, NODE_TYPE, and PORT values based on the OS +# if [[ "$OS" == "mac" ]]; then +# sed -i '' "s/^VERSION=.*$/VERSION=$VERSION/" .env +# sed -i '' "s/^NODE_NAME=.*$/NODE_NAME=$NODE_NAME/" .env +# sed -i '' "s/^NODE_SIDE_TYPE=.*$/NODE_SIDE_TYPE=$NODE_SIDE_TYPE/" .env +# sed -i '' "s/^NODE_TYPE=.*$/NODE_TYPE=$NODE_TYPE/" .env +# sed -i '' "s/^PORT=.*$/PORT=$PORT/" .env +# else +# sed -i "s/^VERSION=.*$/VERSION=$VERSION/" .env +# sed -i "s/^NODE_NAME=.*$/NODE_NAME=$NODE_NAME/" .env +# sed -i "s/^NODE_SIDE_TYPE=.*$/NODE_SIDE_TYPE=$NODE_SIDE_TYPE/" .env +# sed -i "s/^NODE_TYPE=.*$/NODE_TYPE=$NODE_TYPE/" .env +# sed -i "s/^PORT=.*$/PORT=$PORT/" .env +# fi + + + +# # Modify docker-compose.yml if the version is not 0.8.2-beta.6 +# if [[ "$VERSION" != "0.8.2-beta.6" ]]; then +# if [[ "$OS" == "mac" ]]; then +# sed -i '' '/command: "\/app\/grid\/start.sh"/s/^/#/' docker-compose.yml +# else +# sed -i '/command: "\/app\/grid\/start.sh"/s/^/#/' docker-compose.yml +# fi +# fi + + + +# # Run the docker compose command +# docker compose --env-file ./.env -p "$NODE_NAME" --profile blob-storage --profile frontend --file docker-compose.yml up -d + +# # Change directory out and clean up the downloaded file.tgz +# cd .. && rm -f syft-file.tgz + +#!/bin/bash + +# Initialize default values #!/bin/bash # Initialize default values VERSION="" NODE_NAME="" -NODE_SIDE_TYPE="high" +NODE_SIDE_TYPE="high" # Default value for NODE_SIDE_TYPE NODE_TYPE="" PORT="" +DEFAULT_ROOT_EMAIL="info@openmined.org" +DEFAULT_ROOT_PASSWORD="changethis" # Function to display usage usage() { - echo "Usage: $0 [-v|--version ] [-n|--name ] [-s|--side ] [-t|--type ] [-p|--port ]" + echo "Usage: $0 -v|--version -n|--name -t|--type -p|--port [-s|--side ] [-email|--root-email ] [--password|--root-password ]" exit 1 } @@ -36,6 +150,14 @@ while [[ "$#" -gt 0 ]]; do PORT="$2" shift 2 ;; + -email|--root-email) + DEFAULT_ROOT_EMAIL="$2" + shift 2 + ;; + -password|--root-password) + DEFAULT_ROOT_PASSWORD="$2" + shift 2 + ;; *) usage ;; @@ -48,61 +170,27 @@ if [[ -z "$VERSION" || -z "$NODE_NAME" || -z "$NODE_TYPE" || -z "$PORT" ]]; then usage fi - -[ -f "$TGZ_FILE" ] && rm -f "$TGZ_FILE" -[ -f "$COMPOSE_FILE" ] && rm -f "$COMPOSE_FILE" - - -#Use curl to download the fille from azure blob storage -curl -L -o syft-file.tgz "https://openminedblob.blob.core.windows.net/syft-files/syft-compose-file.tar.gz" - - -# Unzip the .tgz file -tar -xzf syft-file.tgz - -#Change directory to the unzipped folder -cd syft-compose-files - - -# Detect OS -OS="linux" -case "$(uname)" in - Darwin) - OS="mac" - ;; -esac - -# Assuming the .env file is in the current directory after unzipping -# Update the VERSION, NODE_NAME, NODE_SIDE_TYPE, NODE_TYPE, and PORT values based on the OS -if [[ "$OS" == "mac" ]]; then - sed -i '' "s/^VERSION=.*$/VERSION=$VERSION/" .env - sed -i '' "s/^NODE_NAME=.*$/NODE_NAME=$NODE_NAME/" .env - sed -i '' "s/^NODE_SIDE_TYPE=.*$/NODE_SIDE_TYPE=$NODE_SIDE_TYPE/" .env - sed -i '' "s/^NODE_TYPE=.*$/NODE_TYPE=$NODE_TYPE/" .env - sed -i '' "s/^PORT=.*$/PORT=$PORT/" .env -else - sed -i "s/^VERSION=.*$/VERSION=$VERSION/" .env - sed -i "s/^NODE_NAME=.*$/NODE_NAME=$NODE_NAME/" .env - sed -i "s/^NODE_SIDE_TYPE=.*$/NODE_SIDE_TYPE=$NODE_SIDE_TYPE/" .env - sed -i "s/^NODE_TYPE=.*$/NODE_TYPE=$NODE_TYPE/" .env - sed -i "s/^PORT=.*$/PORT=$PORT/" .env +# Build the Docker run command +DOCKER_RUN_CMD="docker run --rm -d \ + --name \"$NODE_NAME\" \ + -e VERSION=\"$VERSION\" \ + -e NODE_NAME=\"$NODE_NAME\" \ + -e NODE_SIDE_TYPE=\"$NODE_SIDE_TYPE\" \ + -e NODE_TYPE=\"$NODE_TYPE\" \ + -e PORT=\"$PORT\" \ + -p \"$PORT:$PORT\"" + +# Add optional environment variables if provided +if [[ -n "$DEFAULT_ROOT_EMAIL" ]]; then + DOCKER_RUN_CMD="$DOCKER_RUN_CMD -e DEFAULT_ROOT_EMAIL=\"$DEFAULT_ROOT_EMAIL\"" fi - - -# Modify docker-compose.yml if the version is not 0.8.2-beta.6 -if [[ "$VERSION" != "0.8.2-beta.6" ]]; then - if [[ "$OS" == "mac" ]]; then - sed -i '' '/command: "\/app\/grid\/start.sh"/s/^/#/' docker-compose.yml - else - sed -i '/command: "\/app\/grid\/start.sh"/s/^/#/' docker-compose.yml - fi +if [[ -n "$DEFAULT_ROOT_PASSWORD" ]]; then + DOCKER_RUN_CMD="$DOCKER_RUN_CMD -e DEFAULT_ROOT_PASSWORD=\"$DEFAULT_ROOT_PASSWORD\"" fi +# Add the Docker image +DOCKER_RUN_CMD="$DOCKER_RUN_CMD \"openmined/grid-backend:$VERSION\"" - -# Run the docker compose command -docker compose --env-file ./.env -p "$NODE_NAME" --profile blob-storage --profile frontend --file docker-compose.yml up -d - -# Change directory out and clean up the downloaded file.tgz -cd .. && rm -f syft-file.tgz \ No newline at end of file +# Execute the Docker run command +eval $DOCKER_RUN_CMD diff --git a/scripts/k8s/delete_stack 2.sh b/scripts/k8s/delete_stack 2.sh new file mode 100755 index 00000000000..86d0a1ce176 --- /dev/null +++ b/scripts/k8s/delete_stack 2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Deleting gateway node +bash -c "CLUSTER_NAME=testgateway1 tox -e dev.k8s.destroy || true" + +# Deleting domain node +bash -c "CLUSTER_NAME=testdomain1 tox -e dev.k8s.destroy || true" \ No newline at end of file diff --git a/scripts/k8s/launch_domain 2.sh b/scripts/k8s/launch_domain 2.sh new file mode 100755 index 00000000000..d39f45744d3 --- /dev/null +++ b/scripts/k8s/launch_domain 2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Domain Node +bash -c '\ + export CLUSTER_NAME=testdomain1 CLUSTER_HTTP_PORT=9082 && \ + tox -e dev.k8s.start && \ + tox -e dev.k8s.hotreload' \ No newline at end of file diff --git a/scripts/k8s/launch_gateway 2.sh b/scripts/k8s/launch_gateway 2.sh new file mode 100755 index 00000000000..792a0885ae4 --- /dev/null +++ b/scripts/k8s/launch_gateway 2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Gateway Node +bash -c '\ + export CLUSTER_NAME=testgateway1 CLUSTER_HTTP_PORT=9081 DEVSPACE_PROFILE=gateway && \ + tox -e dev.k8s.start && \ + tox -e dev.k8s.hotreload' \ No newline at end of file diff --git a/scripts/testaaaa.sh b/scripts/testaaaa.sh new file mode 100644 index 00000000000..3c1a018b735 --- /dev/null +++ b/scripts/testaaaa.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +# Initialize default values +VERSION="" +NODE_NAME="" +NODE_SIDE_TYPE="high" +NODE_TYPE="" +PORT="" + +# Function to display usage +usage() { + echo "Usage: $0 [-v|--version ] [-n|--name ] [-s|--side ] [-t|--type ] [-p|--port ]" + exit 1 +} + +# Parse command line options +while [[ "$#" -gt 0 ]]; do + case "$1" in + -v|--version) + VERSION="$2" + shift 2 + ;; + -n|--name) + NODE_NAME="$2" + shift 2 + ;; + -s|--side) + NODE_SIDE_TYPE="$2" + shift 2 + ;; + -t|--type) + NODE_TYPE="$2" + shift 2 + ;; + -p|--port) + PORT="$2" + shift 2 + ;; + *) + usage + ;; + esac +done + +# Check if all required options are set +if [[ -z "$VERSION" || -z "$NODE_NAME" || -z "$NODE_TYPE" || -z "$PORT" ]]; then + echo "All options are required." + usage +fi + + +[ -f "$TGZ_FILE" ] && rm -f "$TGZ_FILE" +[ -f "$COMPOSE_FILE" ] && rm -f "$COMPOSE_FILE" + + +#Use curl to download the fille from azure blob storage +curl -L -o syft-file.tgz "https://openminedblob.blob.core.windows.net/syft-files/syft-compose-file.tar.gz" + + +# Unzip the .tgz file +tar -xzf syft-file.tgz + +#Change directory to the unzipped folder +cd syft-compose-files + + +# Detect OS +OS="linux" +case "$(uname)" in + Darwin) + OS="mac" + ;; +esac + +# Assuming the .env file is in the current directory after unzipping +# Update the VERSION, NODE_NAME, NODE_SIDE_TYPE, NODE_TYPE, and PORT values based on the OS +if [[ "$OS" == "mac" ]]; then + sed -i '' "s/^VERSION=.*$/VERSION=$VERSION/" .env + sed -i '' "s/^NODE_NAME=.*$/NODE_NAME=$NODE_NAME/" .env + sed -i '' "s/^NODE_SIDE_TYPE=.*$/NODE_SIDE_TYPE=$NODE_SIDE_TYPE/" .env + sed -i '' "s/^NODE_TYPE=.*$/NODE_TYPE=$NODE_TYPE/" .env + sed -i '' "s/^PORT=.*$/PORT=$PORT/" .env +else + sed -i "s/^VERSION=.*$/VERSION=$VERSION/" .env + sed -i "s/^NODE_NAME=.*$/NODE_NAME=$NODE_NAME/" .env + sed -i "s/^NODE_SIDE_TYPE=.*$/NODE_SIDE_TYPE=$NODE_SIDE_TYPE/" .env + sed -i "s/^NODE_TYPE=.*$/NODE_TYPE=$NODE_TYPE/" .env + sed -i "s/^PORT=.*$/PORT=$PORT/" .env +fi + + + +# Modify docker-compose.yml if the version is not 0.8.2-beta.6 +if [[ "$VERSION" != "0.8.2-beta.6" ]]; then + if [[ "$OS" == "mac" ]]; then + sed -i '' '/command: "\/app\/grid\/start.sh"/s/^/#/' docker-compose.yml + else + sed -i '/command: "\/app\/grid\/start.sh"/s/^/#/' docker-compose.yml + fi +fi + + + +# Run the docker compose command +docker compose --env-file ./.env -p "$NODE_NAME" --profile blob-storage --profile frontend --file docker-compose.yml up -d + +# Change directory out and clean up the downloaded file.tgz +cd .. && rm -f syft-file.tgz \ No newline at end of file