Unix scripting: Unraid and Extrafanart
#1
So I use a SSD drive as part of my unRAID array. Currently, it just holds the thumbnail cache for near instant response (no spin up time). My thought was that it would be cool to move all "extrafanart" folders to this drive. Currently I don't use it because it forces all drive to spin up when you page through your library. This causes delay and, of course, uses the drives.

My thought was it would be cool to create a script that runs daily to move all "extrafanart" folders to the SSD drive. So I created the script below. The script pretty much works as is. I would love to be able to schedule it though.

Anyway, just wondering if anyone has any thoughts?

Quote:#!/bin/bash
IFS=$'\n'

# Alter variables to suit your setup
SHARES=( "My TV" "My Movies" )
SOURCE_DISKS=( 1 2 3 4 )
DEST_DISK="5"

# Top loop includes all shares
for k in "${SHARES[@]}"; do
echo Processing $k

# 2nd loop includes all source disks
for j in "${SOURCE_DISKS[@]}"; do
echo Processing "Disk"$j

# 3rd loop recursively looks through all folders in the source shares/disks
for i in `find "/mnt/disk"$j"/"$k -type d`; do

# Only process extrafanart folders
if [ ""${i: -11}"" == "extrafanart" ]; then

# recreate file structure in destination disk, if necessary
if [ -d "/mnt/disk"$DEST_DISK"/"${i:11} ]; then
echo "/mnt/disk"$DEST_DISK"/"${i:11} already exists
else
mkdir -m a=rwx -p -v "/mnt/disk"$DEST_DISK"/"${i:11}
fi

# moves all files in the extrafanart directory to the destination folder
for m in `find $i -type f`; do
mv -u -v $m "/mnt/disk"$DEST_DISK"/"${i:11}
done

# remove directory on source disk
rm -v -r $i

fi
done
done
done
Reply

Logout Mark Read Team Forum Stats Members Help
Unix scripting: Unraid and Extrafanart0