universe

Universe
git clone https://git.dasho.dev/universe.git
Log | Files | Refs | Submodules | README

fix-permissions.sh (2171B)


      1 #!/bin/bash
      2 # Permission fixer script - can be run manually or via cron
      3 
      4 echo "=== Fixing File and Folder Permissions ==="
      5 
      6 # Fix web directory permissions
      7 echo "Fixing /var/www/html permissions..."
      8 if [ -d /var/www/html ]; then
      9    chown -R www-data:www-data /var/www/html
     10    find /var/www/html -type d -exec chmod 755 {} \;
     11    find /var/www/html -type f -exec chmod 644 {} \;
     12    echo "✅ Web directory permissions fixed"
     13 fi
     14 
     15 # Fix SQLite permissions in all containers
     16 for container in chatterbox shitchat2 shitchat3 chatterbox_php; do
     17    if docker ps --format "table {{.Names}}" | grep -q "^${container}$"; then
     18        echo "Fixing SQLite permissions in $container..."
     19        docker exec "$container" bash -c '
     20            if [ -d /var/lib/sqlite ]; then
     21                chown -R www-data:www-data /var/lib/sqlite
     22                chmod 755 /var/lib/sqlite
     23                find /var/lib/sqlite -name "*.sqlite*" -exec chmod 664 {} \; 2>/dev/null || true
     24                echo "✅ SQLite permissions fixed in '$container'"
     25            fi
     26        ' 2>/dev/null || echo "⚠️  Could not fix SQLite permissions in $container"
     27    fi
     28 done
     29 
     30 # Fix Tor permissions in nginx containers
     31 for container in chatterbox shitchat2 shitchat3; do
     32    if docker ps --format "table {{.Names}}" | grep -q "^${container}$"; then
     33        echo "Fixing Tor permissions in $container..."
     34        docker exec "$container" bash -c '
     35            if [ -d /var/lib/tor ]; then
     36                chown -R debian-tor:debian-tor /var/lib/tor
     37                chmod 700 /var/lib/tor
     38                chmod 700 /var/lib/tor/hidden_service 2>/dev/null || true
     39                echo "✅ Tor permissions fixed in '$container'"
     40            fi
     41        ' 2>/dev/null || echo "⚠️  Could not fix Tor permissions in $container"
     42    fi
     43 done
     44 
     45 # Fix hostname files permissions
     46 echo "Fixing hostname file permissions..."
     47 if [ -d /var/www/html ]; then
     48    find . -name "hostname_*.txt" -exec chmod 644 {} \; 2>/dev/null || true
     49    find . -name "hostname_*.txt" -exec chown www-data:www-data {} \; 2>/dev/null || true
     50    echo "✅ Hostname file permissions fixed"
     51 fi
     52 
     53 echo "=== Permission fixing complete ==="