-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ndu
committed
Dec 27, 2024
1 parent
91c8b4f
commit e059b8e
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .base import * | ||
from decouple import config | ||
|
||
# Development-specific settings | ||
DEBUG = True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
# Function to validate environment name | ||
validate_env() { | ||
if [[ ! "$1" =~ ^(local|production)$ ]]; then | ||
echo "Error: Invalid environment. Please specify 'local' or 'production'." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to check file existence | ||
check_file() { | ||
if [[ ! -f "$1" ]]; then | ||
echo "Error: $1 does not exist." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Main script | ||
if [[ -z "$1" ]]; then | ||
echo "Error: No environment specified. Please specify 'local' or 'prod'." | ||
exit 1 | ||
fi | ||
|
||
validate_env "$1" | ||
|
||
source_file=".env.$1" | ||
check_file "$source_file" | ||
|
||
# Backup existing .env if it exists | ||
if [[ -f .env ]]; then | ||
backup_file=".env.backup.$(date +%Y%m%d_%H%M%S)" | ||
cp .env "$backup_file" | ||
echo "Existing .env backed up to $backup_file" | ||
fi | ||
|
||
# Copy the specified environment file to .env | ||
cp "$source_file" .env | ||
|
||
# Verify the copy was successful | ||
if [[ $? -eq 0 ]]; then | ||
echo "Successfully switched to $1 environment." | ||
else | ||
echo "Error: Failed to switch environment." | ||
exit 1 | ||
fi |