58 lines
1.4 KiB
Bash
58 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Shared variables and configuration for sync scripts
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[0;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# SSH options - auto-accept new host keys
|
|
SSH_OPTS="-o StrictHostKeyChecking=accept-new"
|
|
|
|
# Pause and wait for user to resolve an issue
|
|
pause_for_user() {
|
|
echo -e "${YELLOW}$1${NC}"
|
|
read -p "Press Enter to continue after resolving..."
|
|
}
|
|
|
|
# Extract value from .env file
|
|
# Usage: get_env_value <file> <key>
|
|
get_env_value() {
|
|
local file="$1"
|
|
local key="$2"
|
|
grep "^${key}=" "$file" 2>/dev/null | head -1 | cut -d'=' -f2- | tr -d '"' | tr -d "'" | tr -d '\r\n'
|
|
}
|
|
|
|
# Add or update value in .env file
|
|
# Usage: set_env_value <file> <key> <value>
|
|
set_env_value() {
|
|
local file="$1"
|
|
local key="$2"
|
|
local value="$3"
|
|
if grep -q "^${key}=" "$file" 2>/dev/null; then
|
|
sed -i "s|^${key}=.*|${key}=\"${value}\"|" "$file"
|
|
else
|
|
echo "${key}=\"${value}\"" >> "$file"
|
|
fi
|
|
}
|
|
|
|
# Add entry to .gitignore if not already present
|
|
# Usage: add_to_gitignore <entry>
|
|
add_to_gitignore() {
|
|
local entry="$1"
|
|
if [ -f .gitignore ]; then
|
|
if ! grep -q "^${entry}$" .gitignore 2>/dev/null; then
|
|
echo "$entry" >> .gitignore
|
|
echo -e "${BLUE}Added $entry to .gitignore${NC}"
|
|
else
|
|
echo -e "${YELLOW}$entry already in .gitignore${NC}"
|
|
fi
|
|
else
|
|
echo "$entry" > .gitignore
|
|
echo -e "${BLUE}Created .gitignore with $entry${NC}"
|
|
fi
|
|
}
|