Last active
April 23, 2017 17:05
-
-
Save AloiSama/a30282933f3bb5081ebe9ceedb91776d to your computer and use it in GitHub Desktop.
Revisions
-
AloiSama revised this gist
Apr 23, 2017 . 4 changed files with 50 additions and 42 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,23 +7,23 @@ logfile="/home/scripts/logs/fuse-mount.cron.log" if pidof -o %PPID -x "fuse-mount.cron"; then echo "$(date "+%d.%m.%Y %T") EXIT: fuse-mount.cron already running." exit 1 fi if [[ -f "/home/tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Check successful, fuse mounted." | tee -a "$logfile" exit else echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress." | tee -a "$logfile" # Unmount before remounting fusermount -uz /home/tv | tee -a "$logfile" /usr/bin/unionfs-fuse -o cow,allow_other,nonempty /home/plex-tv-r=RW:/home/gd-tv=RO /home/tv if [[ -f "/home/tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile" else echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile" fi fi exit This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ hostname:/home/scripts# ls -l total --K -rwxr-xr-x 1 root root 1.1K Apr 16 02:30 fuse-mount.cron drwxr-xr-x 2 root root 4.0K Apr 17 02:43 logs -rwxr-xr-x 1 root root 1.2K Apr 23 10:53 mount-m.cron -rwxr-xr-x 1 root root 1.2K Apr 16 02:04 mount-tv.cron -rwxr-xr-x 1 root root 721 Apr 23 10:59 upload-m.cron -rwxr-xr-x 1 root root 716 Apr 23 10:59 upload-tv.cron This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,31 +7,31 @@ logfile="/home/scripts/logs/mount-tv.cron.log" if pidof -o %PPID -x "mount-tv.cron"; then echo "$(date "+%d.%m.%Y %T") EXIT: mount-tv.cron already running." exit 1 fi if [[ -f "/home/gd-tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Check successful, gd-tv mounted." | tee -a "$logfile" exit else echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress." | tee -a "$logfile" # Unmount before remounting fusermount -uz /home/gd-tv | tee -a "$logfile" rclone mount \ --read-only \ --allow-non-empty \ --allow-other \ --max-read-ahead 200M \ --checkers 16 \ --quiet \ --stats 0 \ egdtv:/LIBRARY/TV /home/gd-tv/& if [[ -f "/home/gd-tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile" else echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile" fi fi exit This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,19 +4,19 @@ # * * * * * root /home/scripts/upload-tv.cron >/dev/null 2>&1 if pidof -o %PPID -x "upload-tv.cron"; then exit 1 fi LOGFILE="/home/scripts/logs/upload-tv.cron" FROM="/home/plex-tv-r/" TO="egd1:/LIBRARY/TV" # 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 rclone move $FROM $TO -c --no-traverse --transfers=10 --checkers=10 --delete-after --min-age 15m --log-file="$LOGFILE" echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD ENDED" | tee -a "$LOGFILE" fi exit -
AloiSama revised this gist
Apr 23, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ if pidof -o %PPID -x "upload-tv.cron"; then exit 1 fi LOGFILE="/home/scripts/logs/upload-tv.cron.log" FROM="/home/plex-tv-r/" TO="egd1:/LIBRARY/TV" -
AloiSama created this gist
Apr 23, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/bin/bash # Change paths for mount and log file & create mountcheck file. # Add script to crontab by typing crontab -e and pasting the line below (without # in front ) # * * * * * /home/scripts/fuse-mount.cron >/dev/null 2>&1 # Make script executable with: chmod a+x /home/scripts/fuse-mount.cron logfile="/home/scripts/logs/fuse-mount.cron.log" if pidof -o %PPID -x "fuse-mount.cron"; then echo "$(date "+%d.%m.%Y %T") EXIT: fuse-mount.cron already running." exit 1 fi if [[ -f "/home/tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Check successful, fuse mounted." | tee -a "$logfile" exit else echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress." | tee -a "$logfile" # Unmount before remounting fusermount -uz /home/tv | tee -a "$logfile" /usr/bin/unionfs-fuse -o cow,allow_other,nonempty /home/plex-tv-r=RW:/home/gd-tv=RO /home/tv if [[ -f "/home/tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile" else echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile" fi fi exit This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ #!/bin/bash # Change paths for mount and log file & create mountcheck file. # Add script to crontab by typing crontab -e and pasting the line below (without # in front ) # * * * * * /home/plex/scripts/mount.cron >/dev/null 2>&1 # Make script executable with: chmod a+x /home/scripts/mount.cron logfile="/home/scripts/logs/mount-tv.cron.log" if pidof -o %PPID -x "mount-tv.cron"; then echo "$(date "+%d.%m.%Y %T") EXIT: mount-tv.cron already running." exit 1 fi if [[ -f "/home/gd-tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Check successful, gd-tv mounted." | tee -a "$logfile" exit else echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress." | tee -a "$logfile" # Unmount before remounting fusermount -uz /home/gd-tv | tee -a "$logfile" rclone mount \ --read-only \ --allow-non-empty \ --allow-other \ --max-read-ahead 200M \ --checkers 16 \ --quiet \ --stats 0 \ egdtv:/LIBRARY/TV /home/gd-tv/& if [[ -f "/home/gd-tv/mountcheck" ]]; then echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile" else echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile" fi fi exit This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #!/bin/bash # RCLONE UPLOAD CRON TAB SCRIPT # Type crontab -e and add line below (without # ) # * * * * * root /home/scripts/upload-tv.cron >/dev/null 2>&1 if pidof -o %PPID -x "upload-tv.cron"; then exit 1 fi LOGFILE="/home/scripts/logs/upload-tv.cron" FROM="/home/plex-tv-r/" TO="egd1:/LIBRARY/TV" # 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 rclone move $FROM $TO -c --no-traverse --transfers=10 --checkers=10 --delete-after --min-age 15m --log-file=$LOGFILE echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD ENDED" | tee -a $LOGFILE fi exit