summaryrefslogtreecommitdiffstats
path: root/fix_ntfs.sh
blob: f3867170f4f342c2da35af340d3ae34c5b85036c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

gksu -S true 

sudo -n true &> /dev/null
exitcode=$?
if [ $exitcode -gt 0 ]; then 
  exit
fi

DRIVE=$(dmesg | grep -o "sd.: sd.." | grep "sd.." | tail -n 1)
DEVICE=$(echo $DRIVE | grep -o "sd.")

sudo fdisk -l $DEVICE | grep "$DRIVE.*NTFS"
exitcode=$?

if [ $exitcode -eq 0 ]; then
  xterm -geometry "40x10" -title "Fixing..." -e "sudo ntfsfix $DRIVE && sleep 2"
fi