diff --git a/.gitignore b/.gitignore index 04bcf05a93..46f93a2a36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ - -.DS_Store -plexguide.retry \ No newline at end of file +.DS_Store +plexguide.retry +.idea diff --git a/roles/pgblitz/templates/pgblitz.sh b/roles/pgblitz/templates/pgblitz.sh new file mode 100644 index 0000000000..09741f3303 --- /dev/null +++ b/roles/pgblitz/templates/pgblitz.sh @@ -0,0 +1,60 @@ +#!/bin/bash +## +# GitHub: https://github.com/Admin9705/PlexGuide.com-The-Awesome-Plex-Server +# Author: Admin9705 & FlickerRate & Bryde ツ & PhysK +# URL: https://plexguide.com +# +# PlexGuide Copyright (C) 2018 PlexGuide.com +# Licensed under GNU General Public License v3.0 GPL-3 (in short) +# +# You may copy, distribute and modify the software as long as you track +# changes/dates in source files. Any modifications to our software +# including (via compiler) GPL-licensed code must also be made available +# under the GPL along with build & install instructions. +# +################################################################################# +downloadpath=$(cat /var/plexguide/server.hd.path) + +echo "INFO - PGBlitz Started for the First Time - 10 Second Sleep" > /var/plexguide/pg.log && bash /opt/plexguide/roles/log/log.sh +sleep 10 +path=/opt/appdata/pgblitz/keys +mkdir $downloadpath/move/movies 1>/dev/null 2>&1 +mkdir $downloadpath/move/tv 1>/dev/null 2>&1 +chown 1000:1000 -R $downloadpath/move/* + +#### Generates the GDSA List from the Processed Keys +GDSAARRAY=(`ls -la /opt/appdata/pgblitz/keys/processed | awk '{print $9}' | grep GDSA`) +GDSACOUNT=${#GDSAARRAY[@]} +GDSAUSE=0 +while [ 1 ] +do + #Find files to transfer + files=(`find /mnt/move -type f ! -name '*partial~' ! -name '*_HIDDEN~' ! -path '.unionfs-fuse/*' ! -path '.unionfs/*'`) + if [[ ${#files[@]} -gt 0 ]]; then + #if files are found loop though and upload + for i in "${#files[@]}" + do + #Run upload script demonised + /opt/plexguide/pgblitz/upload.sh "${files[${i}]}" "${GDSAARRAY[${GDSAUSE}]}" & + PID=$! + + #get basename of file + fileBase=`basename ${files[${i}]}` + + #some logging + echo $PID >> /opt/appdata/pgblitz/${GDSAARRAY[${GDSAUSE}]}_${fileBase}.pid + echo "INFO - Started upload of ${files[${i}} - PID: ${PID}" > /var/plexguide/pg.log && bash /opt/plexguide/roles/log/log.sh + + #increase or reset $GDSAUSE + if [ ${GDSAUSE} -eq ${GDSACOUNT} ]; then + GSDAUSE=0 + else + GDSAUSE=`expr $GDSAUSE + 1` + fi + done + echo "INFO - Finished looking for files, sleeping 20 secs" > /var/plexguide/pg.log && bash /opt/plexguide/roles/log/log.sh + else + echo "INFO - Nothing to upload, sleeping 20 secs" > /var/plexguide/pg.log && bash /opt/plexguide/roles/log/log.sh + fi + sleep 20 +done \ No newline at end of file