-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusbForm.sh
172 lines (160 loc) · 3.46 KB
/
usbForm.sh
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
###########################################
# Script: USB Format Utility
# Author: RJ Levesque, Jr. - Majik Cat Security
# Date: August 19, 2024
# Description: Simple USB format utility
###########################################
Splash(){
figlet "USB Format" | lolcat
}
###############################
##########################
# CHECK FOR ROOT #
##########################
if [ "$EUID" -ne 0 ]
then echo "You must run as root or sudo to run the file"
exit
fi
##########################
# CLEAR THE SCREEN #
##########################
clear
##########################
# SELECTION MENU #
##########################
options=("Check Drives" "Enter usb path (ie /dev/sdb)" "Unmount USB" "Format to FAT32" "Format to NTSF" "Format to exFAT" "Format to UDF" "Check File System" "Quit")
PS3="Choose the action to take or 9 to Quit: "
while [ "$menu" != 1 ]; do
clear
Splash
echo " "
select opt in "${options[@]}"; do
case $opt in
"Check Drives")
clear
Splash
echo " "
echo "Checking drive location..."
sleep 1
df
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 10 seconds...\e[0m"
sleep 10
clear
break
;;
"Enter usb path (ie /dev/sdb)")
clear
Splash
echo " "
echo "type the usb path here"
read UsbPath
echo "You entered $UsbPath"
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 3 seconds...\e[0m"
sleep 3
clear
break
;;
"Unmount USB")
clear
Splash
echo " "
echo "unmounting $UsbPath"
umount $UsbPath
sleep 1
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 3 seconds...\e[0m"
sleep 3
clear
break
;;
"Format to FAT32")
clear
Splash
echo " "
echo "Formating $UsbPath in FAT32 file system"
sleep 1
mkfs.vfat $UsbPath
sleep 3
echo "Format operation is complete!"
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 3 seconds...\e[0m"
sleep 3
clear
break
;;
"Format to NTFS")
clear
Splash
echo " "
echo "Formating $UsbPath in NTFS file system"
sleep 1
mkfs.ntfs $UsbPath
sleep 3
echo "Format operation is complete!"
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 3 seconds...\e[0m"
sleep 3
clear
break
;;
"Format to exFAT")
clear
Splash
echo " "
echo "Formating $UsbPath to exFAT file system"
sleep 1
mkfs.exfat $UsbPath
sleep 3
echo "Format operation is complete!"
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 3 seconds...\e[0m"
sleep 3
clear
break
;;
"Format to UDF")
clear
Splash
echo " "
echo "Formating $UsbPath to UDF file system"
sleep 1
mkfs.udf
sleep 3
echo "Format operation is complete!"
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 3 seconds...\e[0m"
sleep 3
clear
break
;;
"Check File System")
clear
Splash
echo " "
echo "Checking file system integrity"
sleep 1
fsck $UsbPath
echo " "
echo -e "\e[36mNOTE:\e[0m \e[7mYou will return to the main menu in 3 seconds...\e[0m"
sleep 3
clear
break
;;
"Quit")
clear
Splash
echo -e " "
echo -e "USB Format by hwac121 - 2024"
menu=1
sleep 3
clear
break
;;
* )
clear
Splash
echo " "
echo -e "$REPLY is an invalid option"
sleep 3
clear
break
;;
esac
done
done