Advertisement
Shiny_

Untitled

Mar 11th, 2015
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.81 KB | None | 0 0
  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides:             Autostart NTFS drives
  4. # Description:  Automatically mounts NTFS drives in Read-Write mode
  5. ### END INIT INFO
  6.  
  7. win_dir="/mnt/windows"
  8. win_drive="/dev/sda5"
  9. fir_cmd="ntfsfix"
  10. sec_cmd="mount.ntfs-3g"
  11. thi_cmd="umount"
  12. user="patryk"
  13.  
  14. # If is already mounted → unmount:
  15. if grep -qs "$win_dir" /proc/mounts; then
  16.     echo "Mounted, unmounting..."
  17.     sudo -u "$user" "$sec_cmd" "$win_dir"
  18.     echo "Success"
  19. else
  20.     # Fix mounted disk:
  21.     sudo -u "$user" "$fir_cmd" "$win_drive"
  22.     echo "Fixing NTFS disk..."
  23.     if [ $? -eq 0 ] ; then
  24.         echo "Done"
  25.     else
  26.         echo "Something went wrong..."
  27.     fi
  28.     # Mount again:
  29.     echo "Mounting NTFS disk..."
  30.     sudo -u "$user" "$thi_cmd" "$win_drive" "$win_dir"
  31.     if [ $? -eq 0 ] ; then
  32.         echo "Done"
  33.     else
  34.         echo "Something went wrong..."
  35.     fi
  36. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement