Guest User

sandbox transmission

a guest
Feb 9th, 2014
58
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. # info: start transmission in sandbox taking .torrent files from desktop
  3.  
  4. CONF=$HOME"/.config/transmission"
  5. TORR="$CONF/torrents"
  6. LINK=$HOME"/Desktop/sandbox"
  7. TEMP="/tmp/.sandbox_"$USER"_transmission_"$RANDOM
  8. #TEMP=$HOME"/tmp/.sandbox_"$USER"_transmission_"$RANDOM
  9.  
  10. # is there any .torrent files in desktop?
  11. if ! ls ~/Desktop/*.torrent &>/dev/null; then
  12. zenity --error --title "Transmission sandbox" --text "No torrent files on Desktop"
  13. exit 1
  14. fi
  15.  
  16. # trap code to delete temp dirs even on unexpected exit
  17. trap "{ rm -rf $TEMP $LINK; }" 0 1 2 3 5 15
  18.  
  19. # copy torrent files to config and create temp dir
  20. rm -f "$TORR"/*
  21. cp ~/Desktop/*.torrent "$TORR"/
  22. rm -rf "$TEMP"
  23. mkdir -p -m 0700 "$TEMP"
  24. ln -sf "$TEMP" "$LINK"
  25.  
  26. # start sandboxed transmission
  27. sandbox -i "$CONF" -t sandbox_net_t -w 500x600 -H "$TEMP" -X transmission-gtk
  28.  
  29. # delete temp dir and file
  30. rm -f "$LINK"
  31. rm -rf "$TEMP"
RAW Paste Data