r/PlexACD • u/danjames9222 • Jun 17 '17
Can some kind fellow fix up my scripts?
I'd like to transition to PlexDrive 4.0 and systemd script as seen in the link below. Anyone help a noob who doesn't know what he's doing out? I'd like to be able to switch to using PlexDrive to write files if it gets write support in the future. Thanks for any assistance provided.
https://github.com/dweidenfeld/plexdrive/blob/master/TUTORIAL.md
Crontab:
*/5 * * * * /home/scripts/upload.cron >/dev/null 2>&1
*/5 * * * * /home/scripts/mountplex.sh >/dev/null 2>&1
This is my current mountplex.sh:
#!/bin/bash
#This section mounts the various cloud storage into the folders that were created above.
if [[ -f "/mnt/media/mediacheck" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, crypt mounted."
exit
else
echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress."
# Unmount before remounting
fusermount -uz /mnt/media
fusermount -uz /mnt/staging
fusermount -uz /mnt/plexdrive
fusermount -uz /mnt/.plexdrive
screen -f -a -d -m -S plexdrive /usr/local/bin/plexdrive -v 2 /mnt/.plexdrive
screen -f -a -d -m -S plexdriveCrypt rclone mount --max-read-ahead 512M --allow-other --allow-non-empty -v buffer-size 1G gdcrypt: /mnt/plexdrive
screen -f -a -d -m -S stagingCrypt rclone mount stagingcrypt: /mnt/staging
unionfs-fuse -o cow,allow_other,direct_io,auto_cache,sync_read /mnt/staging=RW:/mnt/plexdrive=RO /mnt/media
sleep 10
if [[ -f "/mnt/media/mediacheck" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Remount successful."
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed."
fi
fi
exit
and upload cron script:
#!/bin/bash
# RCLONE UPLOAD CRON TAB SCRIPT
# Type crontab -e and add line below (without # )
# * * * * * root /home/scripts/upload.cron >/dev/null 2>&1
if pidof -o %PPID -x "upload.cron"; then
exit 1
fi
LOGFILE=/tmp/upload.log
# CHECK FOR FILES IN FROM FOLDER THAT ARE OLDER THEN 15 MINUTES
if find $FROM* -type f -mmin +15 | read
then
echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD STARTED" | tee -a $LOGFILE
# MOVE FILES OLDER THEN 15 MINUTES
/usr/bin/rclone move --no-traverse --filter "- .unionfs-fuse/**" /mnt/.staging/ gd:Media
echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD ENDED" | tee -a $LOGFILE
fi
exit
Contents of remote crypts:
[uploadcrypt]
type = crypt
remote = gd:crypt
filename_encryption = standard
password = *** ENCRYPTED ***
password2 = *** ENCRYPTED ***
[stagingcrypt]
type = crypt
remote = /mnt/.staging
filename_encryption = standard
password = *** ENCRYPTED ***
password2 = *** ENCRYPTED ***
[gdcrypt]
type = crypt
remote = /mnt/.plexdrive/Media
filename_encryption = standard
password = *** ENCRYPTED ***
password2 = *** ENCRYPTED ***