| Current File : //www-data/script/repair.sh |
#!/bin/bash
# List of domains
domains=(
srichaitanyatechnoschoolkeelkattalai.net
srichaitanyatechnoschoolkknagar.net
srichaitanyatechnoschoolmanapakkam.net
srichaitanyatechnoschoolperungudi.net
srichaitanyatechnoschoolroyapuram.net
srichaitanyatechnoschoolzameenpallavaram.net
srichaitanyatechnoschoolgandhipuram.net
)
# Path to your clean WordPress core
wp_src="/www-data/wordpress"
for domain in "${domains[@]}"; do
site_path="/www-data/sites/$domain"
echo "🔧 Processing $domain ..."
if [ ! -d "$site_path" ]; then
echo "❌ Skipping $domain (directory not found)"
continue
fi
# 🔓 Unlock site (remove immutable flag)
chattr -i -R "$site_path"
cd "$site_path" || { echo "❌ Skipping $domain (cannot enter)"; continue; }
# Check wp-config.php
if [ ! -f "$site_path/wp-config.php" ]; then
echo "⚠️ wp-config.php missing in $domain, skipping..."
continue
fi
# Backup wp-config.php
mv wp-config.php /www-data/sites/wp-config.php.$domain.bak
# Remove old core files
rm -rf wp-admin wp-includes *.php
# Copy fresh WordPress core
cp -r $wp_src/wp-admin .
cp -r $wp_src/wp-includes .
cp $wp_src/*.php .
# Restore wp-config.php
mv /www-data/sites/wp-config.php.$domain.bak wp-config.php
# Fix ownership & permissions
chown -R www-data:www-data "$site_path"
find "$site_path" -type d -exec chmod 750 {} \;
find "$site_path" -type f -exec chmod 640 {} \;
# 🔒 Lock site files again
chattr +i -R "$site_path"
echo "✅ Finished $domain"
done
# Restart Apache once at the end (not per domain)
systemctl restart apache2
echo "🎉 All domains processed."