50 lines
1.3 KiB
Bash
Executable File
50 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Image Sync Script for SkyArtShop
|
|
# Keeps uploads directory in sync between main and publish folders
|
|
|
|
echo "==================================="
|
|
echo "SkyArtShop Image Sync Script"
|
|
echo "==================================="
|
|
|
|
SOURCE_DIR="/var/www/SkyArtShop/wwwroot/uploads"
|
|
PUBLISH_DIR="/var/www/SkyArtShop/publish/wwwroot/uploads"
|
|
|
|
# Ensure directories exist
|
|
mkdir -p "$SOURCE_DIR/images"
|
|
mkdir -p "$PUBLISH_DIR/images"
|
|
|
|
echo ""
|
|
echo "Source: $SOURCE_DIR"
|
|
echo "Publish: $PUBLISH_DIR"
|
|
echo ""
|
|
|
|
# Sync from source to publish (main direction)
|
|
echo "Syncing from main wwwroot to publish..."
|
|
rsync -av --progress "$SOURCE_DIR/" "$PUBLISH_DIR/"
|
|
|
|
echo ""
|
|
echo "Checking for files in publish not in source..."
|
|
# Also sync back any files that might be in publish but not in source
|
|
rsync -av --ignore-existing "$PUBLISH_DIR/" "$SOURCE_DIR/"
|
|
|
|
echo ""
|
|
echo "==================================="
|
|
echo "Image Sync Complete!"
|
|
echo "==================================="
|
|
|
|
# Show statistics
|
|
SOURCE_COUNT=$(find "$SOURCE_DIR/images" -type f | wc -l)
|
|
PUBLISH_COUNT=$(find "$PUBLISH_DIR/images" -type f | wc -l)
|
|
|
|
echo ""
|
|
echo "Files in source: $SOURCE_COUNT"
|
|
echo "Files in publish: $PUBLISH_COUNT"
|
|
echo ""
|
|
|
|
# Set proper permissions
|
|
echo "Setting permissions..."
|
|
chmod -R 755 "$SOURCE_DIR"
|
|
chmod -R 755 "$PUBLISH_DIR"
|
|
|
|
echo "Done!"
|