ryzhov_al

[Aria2] Fix rights after download

Dec 6th, 2014
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. LOG_FILE="/var/lib/transmission-daemon/info/torrents/aria2_done.log"
  4. BASE_DIR="/mnt/DataVolume/Torrents"
  5.  
  6. [ -z "$1" ] && exit
  7.  
  8. echo "Called with GID:[$1], Num of files:[$2], File path:[$3]." >> $LOG_FILE
  9. # $1 GID:[9937097281ed1643],
  10. # $2 Num of files:[21],
  11. # $3 File path:[/mnt/DataVolume/Torrents/Folder with spaces/Redist/DirectX/dsetup32.dll]
  12.  
  13. if [ "$2" = "1" ] && [ "$(dirname "$3")" = "$BASE_DIR" ]; then
  14.     # Torrent with one file only
  15.     chmod 666 "$3"
  16. else
  17.     cur_dir="$(dirname "$3")"
  18.     while [ "$cur_dir" != "$BASE_DIR" ] && [ "$(dirname "$cur_dir")" != "$BASE_DIR" ]; do
  19.         cur_dir="$(dirname "$cur_dir")"
  20.     done
  21.     echo "Torrent dir is: $cur_dir" >> $LOG_FILE
  22.     find "$cur_dir" -type d -exec chmod 777 {} \; >> $LOG_FILE
  23.     find "$cur_dir" -type f -exec chmod 666 {} \; >> $LOG_FILE
  24. fi
Add Comment
Please, Sign In to add comment