-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.sh
executable file
·76 lines (65 loc) · 1.96 KB
/
run.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
70
71
72
73
74
75
76
# ANSI color codes
BOLD_YELLOW='\033[1;33m'
GREEN='\033[1;32m'
LGREEN='\033[1;33m'
BLUE='\033[1;34m'
NC='\033[0m' # No Color
# ASCII art of a fountain pen nib
echo "${BLUE}"
cat << "EOF"
____ ___ _ _ _____ __ _ _ ___ ____ _
| |_ / / \ | | | | |\ | | | / /\ | | | |\ | | |_) | |_ | |\ |
|_| \_\_/ \_\_/ |_| \| |_| /_/--\ |_| |_| \| |_| |_|__ |_| \|
EOF
echo "${NC}"
#!/bin/bash
# Base directory containing data folders
DATA_DIR="data"
# Ensure the .env.local file exists
ENV_FILE=".env.local"
if [ ! -f "$ENV_FILE" ]; then
touch "$ENV_FILE"
fi
# List existing directories in the data folder
echo "Select a Project:"
count=1
directories=()
for dir in "$DATA_DIR"/*/; do
dirname=$(basename "$dir")
echo "${GREEN}$count) $dirname${NC}"
directories+=("$dirname")
((count++))
done
echo "Or"
echo "${GREEN}0) Create new project${NC} \n\n"
# Read user input
echo "Enter a project number: "
read -r choice
if [ "$choice" -eq 0 ]; then
# Create new directory
echo "Enter new project name. Please DO NOT use spaces in the name:"
read -r new_dir
new_path="$DATA_DIR/$new_dir"
# Create new directory structure
mkdir -p "$new_path/wd"
mkdir -p "$new_path/documents"
# Set the PROJECT_DIR environment variable using awk
awk '!/^PROJECT_DIR=/' "$ENV_FILE" > temp && mv temp "$ENV_FILE"
echo "PROJECT_DIR=$new_dir" >> "$ENV_FILE"
echo "New project '$new_dir' created."
echo "Starting docker container"
else
# Check if the choice is valid
if [ "$choice" -ge 1 ] && [ "$choice" -le "${#directories[@]}" ]; then
selected_dir="${directories[$choice-1]}"
# Set the PROJECT_DIR environment variable using awk
awk '!/^PROJECT_DIR=/' "$ENV_FILE" > temp && mv temp "$ENV_FILE"
echo "PROJECT_DIR=$selected_dir" >> "$ENV_FILE"
echo "Existing project '$selected_dir' selected."
echo "Starting docker container"
else
echo "Invalid choice. Exiting."
exit 1
fi
fi
docker compose up