-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-overlays.sh
executable file
·69 lines (54 loc) · 1.77 KB
/
start-overlays.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Define an array of project directories
PROJECTS=(
"game-info"
"missions"
"youtube-stats"
)
# Loop through each project directory
for PROJECT in "${PROJECTS[@]}"; do
echo "Installing dependencies for $PROJECT..."
# Navigate to the project directory and install node modules
if [ -f "$PROJECT/package.json" ]; then
(cd "$PROJECT" && npm install)
# Check if npm install was successful
if [ $? -eq 0 ]; then
echo "Dependencies installed successfully for $PROJECT!"
else
echo "Failed to install dependencies for $PROJECT."
fi
else
echo "No package.json found in $PROJECT. Skipping..."
fi
echo "----------------------------------------"
done
echo "All done!"
# Display the list of projects
echo "Available projects:"
for i in "${!PROJECTS[@]}"; do
echo "$((i+1)). ${PROJECTS[i]}"
done
# Prompt the user to select a project
read -p "Enter the number of the project you want to run: " choice
# Validate the input
if [[ "$choice" -ge 1 && "$choice" -le "${#PROJECTS[@]}" ]]; then
PROJECT="${PROJECTS[$((choice-1))]}"
SERVER_FILE="./$PROJECT/server.js"
# Check if server.js exists in the selected project
if [ -f "$SERVER_FILE" ]; then
echo "Starting server for project: $PROJECT..."
(cd "$PROJECT" && node server.js)
# Check if the server process starts successfully
if [ $? -eq 0 ]; then
echo "Server for $PROJECT is running!"
else
echo "Failed to start the server for $PROJECT."
fi
else
echo "Error: $SERVER_FILE does not exist in the $PROJECT directory."
exit 1
fi
else
echo "Invalid choice. Please run the script again and select a valid option."
exit 1
fi