-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.sh
61 lines (50 loc) · 1.38 KB
/
migrate.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
#!/bin/bash
# Array of target locations for .env file
TARGET_LOCATIONS=(
"./frontend/.env"
)
# Source .env file location (same directory as this script)
SOURCE_ENV="$(dirname "$0")/.env"
# Text colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Function to print success message
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
# Function to print error message
print_error() {
echo -e "${RED}✗${NC} $1"
}
# Check if source .env file exists
if [ ! -f "$SOURCE_ENV" ]; then
print_error "Source .env file not found at: $SOURCE_ENV"
exit 1
fi
# Counter for successful copies
success_count=0
# Iterate through target locations
for target in "${TARGET_LOCATIONS[@]}"; do
# Create target directory if it doesn't exist
target_dir=$(dirname "$target")
mkdir -p "$target_dir"
# Copy the file
if cp "$SOURCE_ENV" "$target"; then
print_success "Copied .env to: $target"
((success_count++))
else
print_error "Failed to copy .env to: $target"
fi
done
# Print summary
echo -e "\nMigration Summary:"
echo "Total targets: ${#TARGET_LOCATIONS[@]}"
echo "Successful copies: $success_count"
if [ "$success_count" -eq "${#TARGET_LOCATIONS[@]}" ]; then
echo -e "${GREEN}All files copied successfully!${NC}"
exit 0
else
echo -e "${RED}Some copies failed. Please check the errors above.${NC}"
exit 1
fi