Skip to content

Instantly share code, notes, and snippets.

@mattrude
Last active May 23, 2023 16:16
Show Gist options
  • Save mattrude/95a1d0dde854dfb56edf7f9fab1b36f9 to your computer and use it in GitHub Desktop.
Save mattrude/95a1d0dde854dfb56edf7f9fab1b36f9 to your computer and use it in GitHub Desktop.
#!/bin/ash
MEDIA1="Data1"
MEDIA2="Data2"
DRIVES=`df -h |grep -v ${MEDIA1} |grep -v ${MEDIA2} |grep 'var/media' |awk '{ print $6 }'`
UPDATED=0
for DRIVE in ${DRIVES}
do
TVSHOWS="`ls -d ${DRIVE}/*/ |egrep -i 'tv' |sed 's/\/$//g'`"
MOVIES="`ls -d ${DRIVE}/*/ |egrep -i 'movie' |sed 's/\/$//g'`"
MUSIC="`ls -d ${DRIVE}/*/ |egrep -i 'music' |sed 's/\/$//g'`"
PICTURES="`ls -d ${DRIVE}/*/ |egrep -i 'picture' |sed 's/\/$//g'`"
UPDATE="`ls -d ${DRIVE}/*/ |egrep -i 'update|software' |sed 's/\/$//g'`"
if [ `ls ${DRIVE}/${TVSHOWS} |wc -l` ]; then
echo "Working on ${DRIVE}/${TVSHOWS}"
/storage/.kodi/addons/virtual.network-tools/bin/rsync -a ${DRIVE}/${TVSHOWS}/* /var/media/${MEDIA1}/TV_Shows/
UPDATED=1
fi
if [ `ls ${DRIVE}/${MOVIES} |wc -l` ]; then
echo "Working on ${DRIVE}/${MOVIES}"
/storage/.kodi/addons/virtual.network-tools/bin/rsync -a ${DRIVE}/${MOVIES}/* /var/media/${MEDIA1}/Movies/
UPDATED=1
fi
if [ `ls ${DRIVE}/${MUSIC} |wc -l` ]; then
echo "Working on ${DRIVE}/${MUSIC}"
/storage/.kodi/addons/virtual.network-tools/bin/rsync -a ${DRIVE}/${MUSIC}/* /var/media/${MEDIA}/Music/
UPDATED=1
fi
if [ `ls ${DRIVE}/${PICTURES} |wc -l` ]; then
echo "Working on ${DRIVE}/${PICTURES}"
/storage/.kodi/addons/virtual.network-tools/bin/rsync -a ${DRIVE}/${PICTURES}/* /storage/pictures/
UPDATED=1
fi
if [ `ls ${DRIVE}/${UPDATE} |wc -l` ]; then
echo "Working on ${DRIVE}/${UPDATE}"
/storage/.kodi/addons/virtual.network-tools/bin/rsync -a ${DRIVE}/${UPDATE}/* /storage/.update/
UPDATED=1
fi
if [ ${UPDATED} == 1 ]; then
echo "Updated!"
umount ${DRIVE}
kodi-send --action="UpdateLibrary(video)"
fi
done
#!/bin/ash
BINDIR="/storage/bin"
BKDIR="/var/media/Data1/Backups"
DAY="`hostname -s`.`date +%u`"
if [ ! -f ${BINDIR}/texturecache.py ]; then
echo "Downloading texturecache.py"
curl -Ls https://raw.github.com/MilhouseVH/texturecache.py/master/texturecache.py -o ${BINDIR}/texturecache.py
chmod +x ${BINDIR}/texturecache.py
fi
mkdir -p $BKDIR
for TYPE in tvshows movies
do
${BINDIR}/texturecache.py watched $TYPE backup ${BKDIR}/watched.${TYPE}.${DAY}.json
done
#m h dom mon dow command
*/15 * * * * /storage/bin/auto-copy.sh
22 4 * * * /storage/bin/backup-watched.sh
#!/bin/ash
BIN="/storage/bin"
URL="https://gist.githubusercontent.com/mattrude/95a1d0dde854dfb56edf7f9fab1b36f9/raw"
rm /var/run/localtime
ln -s /usr/share/zoneinfo/US/Central /var/run/localtime
mkdir -p ${BIN}
echo 'export PATH="/storage/bin/:$PATH"
alias l="ls -lh"' > /storage/.profile
curl -Ls https://raw.githubusercontent.com/MilhouseVH/texturecache.py/master/texturecache.py -o ${BIN}/texturecache.py
chmod 755 ${BIN}/texturecache.py
mkdir -p /storage/.ssh
curl -Ls ${URL}/ssh-authorized_keys.txt -o /storage/.ssh/authorized_keys
curl -Ls ${URL}/auto-copy.sh -o ${BIN}/auto-copy.sh
chmod 755 ${BIN}/auto-copy.sh
curl -Ls ${URL}/backup-watched.sh -o ${BIN}/backup-watched.sh
chmod 755 ${BIN}/backup-watched.sh
curl -Ls ${URL}/restore-watched.sh -o ${BIN}/restore-watched.sh
chmod 755 ${BIN}/restore-watched.sh
curl -Ls ${URL}/crontab.bkp |crontab -
if [ ! -f /storage/.kodi/userdata/sources.xml ]; then
echo "Installing sources.xml"
curl -Ls ${URL}/sources.xml -o /storage/.kodi/userdata/sources.xml
fi
if [ ! -f /storage/.kodi/userdata/mediasources.xml ]; then
echo "Installing mediasources.xml"
curl -Ls ${URL}/mediasources.xml -o /storage/.kodi/userdata/mediasources.xml
fi
<mediasources>
<network>
<location id="0">smb://jackmedia/Media1/Movies</location>
<location id="1">smb://jackmedia/Media2/Movies</location>
<location id="2">smb://jackmedia/Media2/Movies-Kids</location>
<location id="3">smb://jackmedia/Media1/TV_Shows</location>
<location id="4">smb://jackmedia/Media2/TV_Shows</location>
<location id="5">smb://jackmedia/Media2/TV_Shows-Kids</location>
<location id="6">smb://jackmedia/Media1/Music</location>
<location id="7">smb://jackmedia/Media1/Movie_Sets</location>
<location id="8">smb://jackmedia/Media1/Music_Artists</location>
</network>
</mediasources>
#!/bin/ash
DOW="`date +%u`"
BKDIR="/storage/backup"
BINDIR="/storage/bin"
if [ ! -f ${BINDIR}/texturecache.py ]; then
echo "Downloading texturecache.py"
curl -Ls https://raw.github.com/MilhouseVH/texturecache.py/master/texturecache.py -o ${BINDIR}/texturecache.py
chmod +x ${BINDIR}/texturecache.py
fi
for type in tvshows movies
do
${BINDIR}/texturecache.py watched $type restore ${BKDIR}/watched.${type}.`hostname -s`.`date +%u`.json
done
<sources>
<programs>
<default pathversion="1"></default>
</programs>
<video>
<default pathversion="1"></default>
<source>
<name>TV Shows</name>
<path pathversion="1">smb://jackmedia/Media1/TV_Shows/</path>
<path pathversion="1">smb://jackmedia/Media2/TV_Shows/</path>
<path pathversion="1">smb://jackmedia/Media2/TV_Shows-Kids/</path>
<allowsharing>true</allowsharing>
</source>
<source>
<name>Movies</name>
<path pathversion="1">smb://jackmedia/Media1/Movies/</path>
<path pathversion="1">smb://jackmedia/Media2/Movies/</path>
<path pathversion="1">smb://jackmedia/Media2/Movies-Kids/</path>
<allowsharing>true</allowsharing>
</source>
</video>
<music>
<default pathversion="1"></default>
<source>
<name>Music</name>
<path pathversion="1">smb://jackmedia/Media1/Music/</path>
<allowsharing>true</allowsharing>
</source>
</music>
<pictures>
<default pathversion="1"></default>
<source>
<name>Pictures</name>
<path pathversion="1">smb://jackmedia/Media1/Pictures/</path>
<allowsharing>true</allowsharing>
</source>
</pictures>
<files>
<default pathversion="1"></default>
</files>
<games>
<default pathversion="1"></default>
</games>
</sources>
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEA1f64qldHelhwbujxqPIEdcH8L9Hw+GX55u6wNfDPwSylHxsqVbFATBu8A9OsYIBTmLDokj2roqvmhSh361yVPLHTNbbGW3JJVyadtwr8qc8jPMg/0ceBCyyEO7fwDjyFDH1s/+U5Arjsvzc+avGsplWe+13bvoos6ZqMVTC8bZZ9FhKcpZZZ2C1U04rUQtKhu3iOyiQLRWdOPPpLzIsE/bVSnmA2BlXFZGmCaaFjQXSieEGnhEbQb4+KUe56LC54i7Lj5J5ZpegKTNyl6cMKpDNL46ntDv8cV236+FKkMOuIR6OqCKCamKZsR1J/YZxw9QrZERY3a8g1Nm7syiPJjQ== New-Dell-Laptop
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9L5NWSOwJF11851nDa8MEFx90hGFtx4Jy5owfHIDhbx05A3K3s4q80kAVQKLEUvE3NCmgUqrO2lPCRf3+m7oQVM0rN6/pcVi9vHq6ElkL41wEtblyGH+5FQ1BOQaBh4tfcIrJ3BAnedx5GdhzKDGeX9imTxSvPYZujeImJ9aXM1LVVMMBhBTphKkDeqewHozAv1Rnv3xtD+3YsZwhuIj86D+iBQ9PIDbaVb3OQncwu2hU+FjL89gXSstKi5tZv6H5cNzP7uA0S4hdHLUGocnGNw/ECN9gy3KW1p6xyAXqErzDeW/TOrOGsWvSggpplegRP8Ap9oqmOUe/b5SSD6nenT/ZQDma8IkbX9AMaclGtUVVSIS2bemmH3P7ZUvaRlT7kpTV62koH3Hi7WWjn2XGK16DwpP5ZSOoxkZQrj9mVeVlPlrMHairuqUGCql01p5JYiHue2+4LiDBNJHaBgy5NqwRqa27Jt/ViZJJQ9LfXQcOIv7WJeSopI+1aGUwM1U= matt@jackMedia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment