Advertisement
Frash

"distruggi", permanently delete files (Thunar custom action)

Nov 7th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.12 KB | None | 0 0
  1. #!/bin/bash
  2. # Author: Frash Pikass
  3. # Filename: distruggi
  4. #
  5. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  6. # This is a potentially dangerous piece of code. Make sure to change owner to
  7. # root and make sure only root has execution permissions with
  8. #
  9. #   sudo chown root distruggi
  10. #   sudo chmod 744 distruggi
  11. #
  12. # to avoid accidental execution.
  13. #
  14. # This is based on shred, so the disclaimer in man shred is still valid:
  15. #
  16. #     CAUTION: Note that shred relies on a very  important  assumption:  that
  17. #     the  file system overwrites data in place.  This is the traditional way
  18. #     to do things, but many modern file system designs do not  satisfy  this
  19. #     assumption.   The following are examples of file systems on which shred
  20. #     is not effective, or is not guaranteed to be effective in all file sys‐
  21. #     tem modes:
  22. #
  23. #     * log-structured or journaled file systems, such as those supplied with
  24. #     AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)
  25. #
  26. #     * file systems that write redundant data and  carry  on  even  if  some
  27. #     writes fail, such as RAID-based file systems
  28. #
  29. #     *  file  systems  that  make snapshots, such as Network Appliance's NFS
  30. #     server
  31. #
  32. #     * file systems that cache in temporary locations, such as NFS version 3
  33. #     clients
  34. #
  35. #     * compressed file systems
  36. #
  37. #     In  the  case  of  ext3 file systems, the above disclaimer applies (and
  38. #     shred is thus of limited  effectiveness)  only  in  data=journal  mode,
  39. #     which  journals  file  data  in addition to just metadata.  In both the
  40. #     data=ordered (default) and data=writeback modes, shred works as  usual.
  41. #     Ext3  journaling  modes  can  be  changed  by adding the data=something
  42. #     option to the mount  options  for  a  particular  file  system  in  the
  43. #     /etc/fstab file, as documented in the mount man page (man mount).
  44. #
  45. #     In  addition, file system backups and remote mirrors may contain copies
  46. #     of the file that cannot be removed, and that will allow a shredded file
  47. #     to be recovered later.
  48. #
  49. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  50. #
  51. # DESCRIPTION AND INSTRUCTIONS:
  52. # distruggi asks for permissions, asks for confirmation then permanently
  53. # deletes the argument file. It's optimized for integration with Thunar.
  54. # Launch with:
  55. #   gksudo ./distruggi fileName filePath
  56. #
  57. # To add this as a custom action in Thunar, make sure the script distruggi is
  58. # in /usr/bin then follow the tutorial at
  59. #   http://docs.xfce.org/xfce/thunar/custom-actions
  60. # Put this line in the command field:
  61. #   gksudo /usr/bin/./distruggi %n %f
  62. # and make sure to check the right flags in the Appearance Conditions tab so
  63. # that file scheme is * and all boxes are checked except for Directories.
  64.  
  65. zenity  --question --title "Warning!"   --text  "Are you sure you want to permanently delete the file '$1'?" && test $? -eq 0 && (shred -n 200 -z -u "$2"; exit 0)
  66.  
  67.  
  68. # In Italian
  69. # zenity  --question --title "Attenzione!"   --text  "Vuoi davvero cancellare il file '$1' in modo sicuro?" && test $? -eq 0 && (shred -n 200 -z -u "$2"; exit 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement