From c97fbd96951c18755eb34aca6bcb6123922b766f Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Tue, 7 Jan 2025 20:14:26 -0300 Subject: [PATCH 1/2] Changes to start.sh --- configs/core/.env | 1 + configs/core/composer.json | 4 ++-- start.sh | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/configs/core/.env b/configs/core/.env index 393a4dc..29a5fb2 100644 --- a/configs/core/.env +++ b/configs/core/.env @@ -14,6 +14,7 @@ ASSET_URL="${APP_URL}" BCRYPT_ROUNDS=12 CORS_PATHS="graphql,graphql/beam,graphql/fuel-tanks,graphql/marketplace" +UPGRADE_NOTIFICATION_EMAIL= NETWORK=canary-matrixchain DECODER_CONTAINER=decoder:8090 DAEMON_ACCOUNT= diff --git a/configs/core/composer.json b/configs/core/composer.json index a63455a..e334aae 100644 --- a/configs/core/composer.json +++ b/configs/core/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "php": "^8.3", + "php": "^8.3|^8.4", "enjin/platform-core": "^2.0", "enjin/platform-beam": "^2.0", "enjin/platform-fuel-tanks": "^2.0", @@ -29,7 +29,7 @@ "guzzlehttp/guzzle": "^7.0", "laravel/framework": "^11.0", "laravel/horizon": "^5.0", - "laravel/reverb": "@beta", + "laravel/reverb": "^1.0", "laravel/sanctum": "^4.0", "laravel/tinker": "^2.0", "fakerphp/faker": "^1.0" diff --git a/start.sh b/start.sh index b0cfaa0..08e7f61 100755 --- a/start.sh +++ b/start.sh @@ -44,6 +44,43 @@ generate_basic_token() { fi } +read_email() { + # Read the email address from the user + echo "Please input the email address: (e.g. user@example.com)" + read NOTIFICATION_EMAIL + + # Check if the email address is empty + if [ -z "$NOTIFICATION_EMAIL" ]; then + return + fi + + # Check if the email address is valid + if ! [[ $NOTIFICATION_EMAIL =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then + echo "The email address you provided is not valid. Please try again." + read_email + fi +} + +check_has_upgrade_notification_email() { + # Check if user already has UPGRADE_NOTIFICATION_EMAIL set + NOTIFICATION_EMAIL=$(awk '$1 ~ /^UPGRADE_NOTIFICATION_EMAIL/' configs/core/.env | cut -d "=" -f 2) + if [ -z "$NOTIFICATION_EMAIL" ]; then + echo "If you want to receive notifications with major updates or security notices, please provide an email address, otherwise leave it blank" + read_email + + # Check if the email address is empty + if [ -z "$NOTIFICATION_EMAIL" ]; then + return + fi + + if [ "$PLATFORM_OS" = "macOS" ]; then + sed -i '' -e "s/^UPGRADE_NOTIFICATION_EMAIL=/UPGRADE_NOTIFICATION_EMAIL=$NOTIFICATION_EMAIL/g" configs/core/.env + else + sed -i "s/^UPGRADE_NOTIFICATION_EMAIL=/UPGRADE_NOTIFICATION_EMAIL=\"$NOTIFICATION_EMAIL\"/g" configs/core/.env + fi + fi +} + check_has_basic_token() { # Check if user already has BASIC_AUTH_TOKEN set AUTH_TOKEN=$(awk '$1 ~ /^BASIC_AUTH_TOKEN/' configs/core/.env | cut -d "=" -f 2) @@ -176,6 +213,7 @@ check_has_app_url check_has_basic_token check_has_daemon_password check_and_generate_app_key +check_has_upgrade_notification_email get_daemon_address echo "Do you want to start all platform services? (y/n)" From 9ca290d314c6a153bdaa40c499ccae90c53669d3 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Tue, 7 Jan 2025 20:19:03 -0300 Subject: [PATCH 2/2] Tweak bat script --- start.bat | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/start.bat b/start.bat index 1ee7ec7..4b9e5a9 100644 --- a/start.bat +++ b/start.bat @@ -21,6 +21,41 @@ if "%APP_URL%"=="" ( ) goto :EOF +:: Function to read the email address from the user +:read_email +:: Read the email address from the user +echo Please input the email address: (e.g. user@example.com) +set /p NOTIFICATION_EMAIL= +:: Check if the email address is empty +if "%NOTIFICATION_EMAIL%"=="" ( + goto :EOF +) +:: Check if the email address is valid +if not "%NOTIFICATION_EMAIL%"=="%NOTIFICATION_EMAIL: =%" ( + echo The email address you provided is not valid. Please try again. + call :read_email +) +goto :EOF + +:: Function to check if user already has UPGRADE_NOTIFICATION_EMAIL set +:check_has_upgrade_notification_email +:: Check if user already has UPGRADE_NOTIFICATION_EMAIL set +set "NOTIFICATION_EMAIL=" +for /f "tokens=2 delims==" %%i in ('findstr /r /c:"UPGRADE_NOTIFICATION_EMAIL=" configs\core\.env') do ( + set "NOTIFICATION_EMAIL=%%i" +) +:: If not set, prompt the user +if "%NOTIFICATION_EMAIL%"=="" ( + echo If you want to receive notifications with major updates or security notices, please provide an email address, otherwise leave it blank + call :read_email + :: Check if the email address is empty + if "%NOTIFICATION_EMAIL%"=="" ( + goto :EOF + ) + powershell -Command "(Get-Content 'configs\core\.env') | ForEach-Object {$_ -replace '\bUPGRADE_NOTIFICATION_EMAIL=.*', 'UPGRADE_NOTIFICATION_EMAIL=!NOTIFICATION_EMAIL!'} | Set-Content 'configs\core\.env'" +) +goto :EOF + :: Function to generate a new basic auth token and set it in the .env file :generate_basic_token :: Generate a new basic auth token @@ -191,6 +226,7 @@ call :check_has_app_url call :check_has_basic_token call :check_has_daemon_password call :check_and_generate_app_key +call :check_has_upgrade_notification_email call :get_daemon_address :: Prompt the user to start platform services