Skip to content

Commit 4aad51a

Browse files
authored
Create README-EN.md
1 parent 3632a6c commit 4aad51a

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

README-EN.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
# Automation Scripts - `main.sh`
3+
4+
The `main.sh` script is used to process folders within a specific directory and run JavaScript files (`main.js` or `index.js`) or Python files (`main.py`). The script checks whether a folder has been processed previously to avoid re-processing the same folder. It also handles activating a Python virtual environment if present and runs the Python file with certain options.
5+
6+
## Prerequisites
7+
8+
Before running this script, ensure you have the following:
9+
10+
- **Ubuntu (Linux) / Windows (WSL / Git Bash)**
11+
- **Node.js** to run JavaScript files (`main.js` or `index.js`).
12+
- **Python 3** to run Python files (`main.py`).
13+
- **gnome-terminal** (Linux only, to open a new terminal window while running the script).
14+
- **Virtual Environment (Optional)** to run Python scripts in an isolated environment.
15+
16+
## How to Run the Script
17+
18+
### 1. **Clone the Git Repository**
19+
20+
If you haven't cloned the repository yet, run the following command to clone the repository to your local machine:
21+
22+
```bash
23+
git clone https://github.com/0xsyo/automation-scripts.git
24+
cd automation-scripts
25+
```
26+
27+
### 2. **Prepare the `bot` Directory**
28+
29+
This script assumes you have a `bot` folder containing subfolders with either JavaScript or Python projects. Ensure the `bot` folder is located inside the cloned repository, or place the `bot` folder in another suitable directory.
30+
31+
- **Create the `bot` folder inside the repository you just cloned:**
32+
33+
```bash
34+
mkdir -p automation-scripts/bot
35+
```
36+
37+
You can add your JavaScript or Python project folders inside the `bot` directory.
38+
39+
- **On Windows (using Git Bash or WSL):** If you're using Git Bash or WSL, you can adjust the directory path according to where the `bot` folder is located.
40+
41+
If you need to change the folder path inside the script, open `main.sh` and edit the following line:
42+
43+
```bash
44+
DIR="./bot" # Points to the 'bot' folder inside the cloned repository
45+
```
46+
47+
### 3. **Grant Execute Permissions to the Script (Optional)**
48+
49+
If you want to run the script directly, make sure to grant execute permissions to the script file with the following command:
50+
51+
```bash
52+
chmod +x main.sh
53+
```
54+
55+
### 4. **Run the Script**
56+
57+
After the setup is complete, you can run the `main.sh` script with the following command:
58+
59+
```bash
60+
./main.sh
61+
```
62+
63+
If you did not grant execute permissions, you can also run the script using the following command:
64+
65+
```bash
66+
bash main.sh
67+
```
68+
69+
### 5. **Understanding What Happens**
70+
71+
- The script will check each subfolder inside the `bot` directory (in the cloned repository).
72+
- If a JavaScript file (`main.js` or `index.js`) is found, the script will run it using `node`.
73+
- If a Python file (`main.py`) is found and a virtual environment is detected, the script will activate the environment and run `main.py` with the additional `--action 1` argument.
74+
- If no JavaScript or Python files are found, the script will notify you and continue to the next folder.
75+
76+
## Adding a New Folder
77+
78+
To add a new folder to the `bot` directory, simply create a subfolder inside it and make sure it contains a `main.js`, `index.js`, or `main.py` file. The script will automatically detect and process the new folder.
79+
80+
## Troubleshooting
81+
82+
- **Issues with Virtual Environment:**
83+
If you're using Python with a virtual environment, ensure the `venv` directory is within the same folder as `main.py`. The script will look for the `venv` folder and activate it if found.
84+
85+
- **Issues with `gnome-terminal` (Linux):**
86+
The script uses `gnome-terminal` to open a new terminal window while running the script. If you're using a desktop environment other than GNOME, you may need to change `gnome-terminal` to the terminal you use, such as `xterm` or `konsole`.
87+
88+
## License
89+
90+
This script is released under the MIT License.

0 commit comments

Comments
 (0)