HEX
Server: LiteSpeed
System: Linux ip-172-31-76-142.ec2.internal 4.14.158-129.185.amzn2.x86_64 #1 SMP Tue Dec 24 03:15:32 UTC 2019 x86_64
User: 69b4844ae61d4e92bf26ad98af552775 (1065)
PHP: 7.2.27
Disabled: exec,passthru,shell_exec,system,eval
Upload Files
File: //efs/scripts/fix_uploads_mount.sh
UUIDS=$(ls /var/readyship/volumes)
UUIDS_ALT=""
for UUID in $UUIDS
do
    R=`cat /etc/fstab | grep $UUID`
    if [ -n "$R" ]; then
      UUIDS_ALT="$UUIDS_ALT $UUID"
    fi
done
UUIDS=$UUIDS_ALT

echo "3. Only if bad condition, restart it"
BAD_UUIDS=""
for UUID in $UUIDS
do
  CONTAINER_ID=`docker ps --filter "name=$UUID" --format "{{.ID}}" | sed -n 1P`
  if [ -z "$CONTAINER_ID" ]; then
    echo "$UUID Container is not found, skip..."
    continue
  fi
  docker exec $CONTAINER_ID ls /mnt/www/${UUID}/wordpress/wp-content/uploads/2019 > /dev/null
  if [ $? -gt 0 ]; then
    echo "$UUID uploads dir is not working well... (CONTAINER_ID: $CONTAINER_ID)"
    BAD_UUIDS="$BAD_UUIDS $UUID"
    docker restart $CONTAINER_ID
    echo "Waiting 60 sec..."
    sleep 60
  fi
done

sleep 30

echo "4. Checking if it's working well again"

for UUID in $BAD_UUIDS
do
  docker exec `docker ps --filter "name=$UUID" --format "{{.ID}}" | sed -n 1P` ls /mnt/www/${UUID}/wordpress/wp-content/uploads/2019 > /dev/null
  if [ $? -gt 0 ]; then
    echo "$UUID uploads dir is not working well..."
  fi
done