Created
October 23, 2023 17:31
-
-
Save dreygur/ae9a9745a3244cae0a82ed2e1ae8485a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| envs_folder="envs" | |
| bot_file="bot.js" | |
| for env_file in "$envs_folder"/*.env; do | |
| filename=$(basename "$env_file") | |
| echo "Setting environment variables from file: $filename" | |
| while IFS= read -r line; do | |
| if [[ "$line" == *=* ]]; then | |
| key="${line%%=*}" | |
| value="${line#*=}" | |
| export "$key=$value" | |
| fi | |
| done < "$env_file" | |
| echo "Running javascript file with Node in a new terminal window..." | |
| gnome-terminal -- bash -c "node $bot_file; exec bash" | |
| # Clear the environment variables after each iteration | |
| while IFS= read -r line; do | |
| if [[ "$line" == *=* ]]; then | |
| key="${line%%=*}" | |
| unset "$key" | |
| fi | |
| done < "$env_file" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment