The main.sh
script is used to process folders within a specific directory and execute JavaScript files (main.js
or index.js
) or Python files (main.py
). This script checks if a folder has been processed previously to avoid reprocessing the same folder. It also handles activating Python virtual environments, if available, and running Python files with specific options.
Before running this script, ensure you have the following:
- Ubuntu (Linux) / Windows (WSL / Git Bash)
- Node.js to execute JavaScript files (
main.js
orindex.js
). - Python 3 to execute Python files (
main.py
). - gnome-terminal (Linux only, used to open new terminals during script execution).
- Virtual Environment (Optional) to run Python scripts in an isolated environment.
If you haven’t cloned this repository yet, execute the following commands to clone it to your computer:
git clone https://github.com/0xsyo/automation-scripts.git
cd automation-scripts
This script assumes you have a bot
folder or have moved all folders containing code/scripts/bots into the automation-scripts
directory, which houses JavaScript or Python projects.
You can add JavaScript or Python project folders inside the bot
directory.
- On Windows (using Git Bash or WSL): If you are using Git Bash or WSL, adjust the directory path according to the location of the
bot
folder.
If you need to change the folder path in the script, open main.sh
and edit the following line:
Line 46 in 6b833e9
Move all folders/scripts or bots into the automation-scripts
folder:
automation-scripts/
├── main.sh
├── bot1/
│ ├── main.js
│ └── main.py
├── bot2/
│ ├── index.js
│ └── main.py
If you want to execute the script directly, grant execution permissions to the script file using the command:
chmod +x main.sh
Once everything is set up, you can run the main.sh
script with the following command:
./main.sh
If you do not grant execution permissions, you can also run the script with the command:
bash main.sh
- The script will check each sub-folder in the
bot
directory within the cloned repository. - If a JavaScript file (
main.js
orindex.js
) is found, the script will run the file usingnode
. - If a Python file (
main.py
) is found and a virtual environment exists, the script will activate the environment and runmain.py
with additional parameters--action 1
. - If no JavaScript or Python files are found, the script will notify you and proceed to the next folder.
To add a new folder to the bot
directory, simply create a sub-folder inside it and ensure it contains a main.js
, index.js
, or main.py
file. The script will automatically detect and process the new folder.
-
Issues with Virtual Environment:
If you are using Python with a virtual environment, ensure thevenv
directory is located in the same folder as themain.py
file. The script will look for thevenv
folder and activate it if found. -
Issues with
gnome-terminal
(Linux):
This script usesgnome-terminal
to open a new terminal during execution. If you use a desktop environment other than GNOME, you may need to replacegnome-terminal
with the terminal application you use, such asxterm
orkonsole
.
This script is released under the MIT license.