Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ### BEGIN INIT INFO
- # Provides: Autostart NTFS drives
- # Description: Automatically mounts NTFS drives in Read-Write mode
- ### END INIT INFO
- win_dir="/mnt/windows"
- win_drive="/dev/sda5"
- fir_cmd="ntfsfix"
- sec_cmd="mount.ntfs-3g"
- thi_cmd="umount"
- user="patryk"
- # If is already mounted → unmount:
- if grep -qs "$win_dir" /proc/mounts; then
- echo "Mounted, unmounting..."
- sudo -u "$user" "$sec_cmd" "$win_dir"
- echo "Success"
- else
- # Fix mounted disk:
- sudo -u "$user" "$fir_cmd" "$win_drive"
- echo "Fixing NTFS disk..."
- if [ $? -eq 0 ] ; then
- echo "Done"
- else
- echo "Something went wrong..."
- fi
- # Mount again:
- echo "Mounting NTFS disk..."
- sudo -u "$user" "$thi_cmd" "$win_drive" "$win_dir"
- if [ $? -eq 0 ] ; then
- echo "Done"
- else
- echo "Something went wrong..."
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement