ImageAlfred / hf.sh
0xsaeed
refactored
27f8934
raw
history blame
1.14 kB
#!/bin/bash
# Set variables
REPO_URL="https://github.com/mahan-ym/ImageAlfred"
REPO_DIR="ImageAlfred"
TEMP_DIR="./tmp"
SRC_DIR="src"
REQUIREMENTS_FILE="requirements.txt"
echo "πŸš€ Starting Huggingface Space update script..."
# Clone or update the repository
ORIGINAL_DIR=$(pwd)
if [ -d "$TEMP_DIR" ]; then
echo "πŸ“₯ Updating repository..."
cd "$TEMP_DIR" && git pull
else
echo "πŸ“₯ Cloning repository..."
mkdir -p "$TEMP_DIR" && cd "$TEMP_DIR" && git clone "$REPO_URL"
fi
cd "$ORIGINAL_DIR" # Return to original directory
# Copy src directory to current directory
echo "πŸ“ Updating source code..."
if [ ! -d "$TEMP_DIR/$REPO_DIR/$SRC_DIR" ]; then
echo "❌ Source directory not found in the repository!"
exit 1
fi
if [ -d "$SRC_DIR" ]; then
rm -rf "$SRC_DIR"
fi
cp -r "$TEMP_DIR/$REPO_DIR/$SRC_DIR" .
mv "$TEMP_DIR/$REPO_DIR/Makefile" .
# Check if copy was successful
if [ $? -eq 0 ]; then
rm -rf "$TEMP_DIR"
echo "βœ… Source code updated successfully!"
else
echo "❌ Failed to copy source code!"
exit 1
fi
echo "πŸŽ‰ Update completed! Source code and requirements are now up to date."