-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatternfill
123 lines (123 loc) · 4.3 KB
/
patternfill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
clear
fillcheck="false"
while true
do
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "==================================================="
echo " Ontrack Erasure Verification Pattern Fill Script "
echo "==================================================="
echo "Please become root prior to running this script"
echo "This can be done by typing "su" in most distros"
echo "==================================================="
echo "Exiting script....."
echo "==================================================="
exit
fi
if [[ $fillcheck = false ]]; then
echo "==================================================="
echo " Ontrack Erasure Verification Pattern Fill Script "
echo "==================================================="
echo "Enter (1) for 55aa Pattern (first pass)"
echo "Enter (2) for aa55 Pattern (second pass)"
echo "Enter (3) check status of last operation"
echo "Enter (q) to exit"
echo "==================================================="
fi
echo "Enter your choice: "
read -r choice
case "$choice" in
1) fillcheck="false"
echo "=============================================="
echo "Creating FIFO pipe named 55aa"
mkfifo 55aa
echo "=============================================="
echo "=============================================="
echo "Supplying FIFO file with 55aa datastream .."
if [[ $OSTYPE == 'darwin'* ]]; then
export LC_ALL=en_US.ISO8859-1
fi
printf "%b" '\x55\xAA' | tr -d '\n' | xargs yes | tr -d '\n' > 55aa &
echo "=============================================="
echo "======================================"
echo "Listing available storage devices.."
if [[ $OSTYPE == 'darwin'* ]]; then
diskutil list
fi
if [[ $OSTYPE == 'linux'* ]]; then
lsblk -a | sed '/loop/d'
fi
echo "========================================="
echo "Type name of target storage device"
echo "(ex "disk2s1" for mac ex "sdb" for linux) : "
read -r "storagedevice"
echo "Proceeding to fill $storagedevice with 55aa pattern."
echo "Type (y) to continue "
read -r confirmresponse
case $confirmresponse in
y) if [[ $OSTYPE == 'darwin'* ]]; then
dd bs=32768 if=55aa of=/dev/$storagedevice &
fi
if [[ $OSTYPE == 'linux'* ]]; then
dd bs=32768 iflag=fullblock if=55aa of=/dev/$storagedevice &
fi
echo "Fill Task Started, you may check progress with (3) at the main menu"
echo "Press any key to go to main menu "
read -r continue;;
n) exit ;;
esac;;
2) fillcheck="false"
echo "=============================================="
echo "Creating FIFO pipe named aa55"
mkfifo aa55
echo "=============================================="
echo "=============================================="
echo "Supplying FIFO file with aa55 datastream .."
if [[ $OSTYPE == 'darwin'* ]]; then
export LC_ALL=en_US.ISO8859-1
fi
printf "%b" '\xAA\x55' | tr -d '\n' | xargs yes | tr -d '\n' > aa55 &
echo "=============================================="
echo "======================================"
echo "Listing available storage devices.."
if [[ $OSTYPE == 'darwin'* ]]; then
diskutil list
fi
if [[ $OSTYPE == 'linux'* ]]; then
lsblk -a | sed '/loop/d'
fi
echo "========================================="
echo "Type name of target storage device"
echo "(ex "disk2s1" for mac ex "sdb" for linux) : "
read -r "storagedevice"
echo "Proceeding to fill $storagedevice with aa55 pattern."
echo "Type (y) to continue "
read -r confirmresponse
case $confirmresponse in
y) if [[ $OSTYPE == 'darwin'* ]]; then
dd bs=32768 if=aa55 of=/dev/$storagedevice &
fi
if [[ $OSTYPE == 'linux'* ]]; then
dd bs=32768 iflag=fullblock if=aa55 of=/dev/$storagedevice &
fi
echo "Fill Task Started, you may check progress with (3) at the main menu"
echo "Press any key to go to main menu"
read -r continue;;
n) exit ;;
esac;;
3) fillcheck="true"
if [[ $! == '' ]]; then
echo "There are no active fill operations running."
fi
if [[ $! != '' ]]; then
if [[ $OSTYPE == 'darwin'* ]]; then
kill -info $!
echo $!
fi
if [[ $OSTYPE == 'linux'* ]]; then
kill -s sigusr1 $!
fi
fi;;
q) pkill -P $$
exit ;;
esac
done