diff --git a/sync-project.sh b/sync-project.sh index 55b363c..c7cf7e6 100755 --- a/sync-project.sh +++ b/sync-project.sh @@ -24,20 +24,41 @@ NC='\033[0m' # No Color # Get current script real directory (follow symlinks) SCRIPT_PATH="$(realpath "$0")" SCRIPT_DIR="$(dirname "$SCRIPT_PATH")" +ARCHIVE_NAME="leo.tar.gz" echo -e "${BLUE}=== Project Sync Configuration ===${NC}" echo "" -# Prompt for configuration -read -p "Server user@host (e.g., leo@server.com): " SERVER_HOST -read -p "Server project path (e.g., /home/leo/public_leo): " SERVER_PROJECT_PATH -read -p "Local folder path (e.g., Delta Pharmacy): " LOCAL_FOLDER -read -sp "SSH Password: " SSH_PASSWORD -echo "" -echo "" +# Check if config is predefined (for testing usually) +if [ -f ".sync-credentials" ]; then + source ".sync-credentials" +else + # Prompt for configuration + read -p "Server user@host (e.g., leo@server.com): " SERVER_HOST + read -p "Server project path (e.g., /home/leo/public_leo): " SERVER_PROJECT_PATH + read -p "Local folder path (e.g., Delta Pharmacy): " LOCAL_FOLDER + read -sp "SSH Password: " SSH_PASSWORD + echo "" + echo "" +fi -ARCHIVE_NAME="leo.tar.gz" +# Validate required variables (all except password) +if [ -z "$SERVER_HOST" ]; then + echo -e "${RED}Error: SERVER_HOST is not set${NC}" + exit 1 +fi +if [ -z "$SERVER_PROJECT_PATH" ]; then + echo -e "${RED}Error: SERVER_PROJECT_PATH is not set${NC}" + exit 1 +fi + +if [ -z "$LOCAL_FOLDER" ]; then + echo -e "${RED}Error: LOCAL_FOLDER is not set${NC}" + exit 1 +fi + +# Start sync process echo "Starting project sync..." # Step 1: SSH into server and create tar archive