-
Notifications
You must be signed in to change notification settings - Fork 0
/
formata.sh
executable file
·137 lines (121 loc) · 3.89 KB
/
formata.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
#! /bin/bash
sudo uname -a
clear
printf "********************\n"
printf "USB Floppy Formatter for Linux - AKITASOFT 2021\n"
printf "********************\n\n"
if ! command -v ufiformat &>/dev/null; then
printf "ufiformat could not be found, would you like me to help you install?\n"
select yn in "Yes, help me install ufiformat" "No thank you!"; do
case $yn in
Yes*)
printf ""
printf "OK we will help you install...\n"
helpme=1
break
;;
No*)
printf "OK then... Goodbye!!\n"
exit
;;
esac
done
if helpme=1; then
printf "Select package manager\n"
select pm in "Apt (Debian/Ubuntu)" "DNF (Fedora/RHEL/Etc.)" "Yay (Arch/Manjaro)"; do
case $pm in
Apt*)
sudo apt install ufiformat
break
;;
DNF*)
sudo dnf install ufiformat
break
;;
Yay*)
yay -S ufiformat
break
;;
esac
done
fi
fi
printf "ufiformat found, continuing...\n\n"
sleep .3
printf "**** Drives Avaialble ****\n"
diskselect=1
while diskselect=1; do
usblist="$(sudo ufiformat -i | awk '$1 ~ /dev/ {print $1}')"
sudo ufiformat -i
printf "\nSelect Drive to Format: \n"
select device in ${usblist[@]} "Refresh Devices"; do
case $device in
Refresh*)
printf "Running udevadm trigger...\n"
sudo udevadm trigger
printf "Waiting while devices initialize...\n"
sleep 10
break
;;
${usblist[@]})
formattypes=("1440" "1232" "1200" "720" "640")
printf "\nSelect format type (Kb)\n"
select format in "Quick Format DOS FAT" ${formattypes[@]}; do
case $format in
Quick*)
formatme=0
break
;;
${formattypes[@]})
formatme=1
break
;;
esac
break
done
if [[ $formatme = "0" ]]; then
printf "\nQuick Formatting Floppy as DOS FAT\n"
else
printf "\nYou have selected $device to be formatted as a $format Kb floppy disk\n"
fi
printf "\n****************************************\n"
printf "\nWARNING: ALL DATA WILL BE LOST ON DISK PLEASE PROCEED WITH CAUTION\n"
printf "\n****************************************\n\n"
select yn in "Yes, I understand" "No!!! STOP!!!"; do
case $yn in
Yes*)
printf "\nOK you asked for it...\n"
break
;;
No*)
printf "\nOK then... Goodbye!!\n"
exit
;;
esac
done
printf "\nUnmounting if needed...\n"
sudo umount $device
if [[ $formatme != "0" ]]; then
printf "\nRunning Format...\n\n"
formatter="$(sudo ufiformat -f $format -v $device 2>&1)"
for f in $formatter; do
echo $f
done
if [[ $formatter = *'media type mismatch'* ]]; then
printf "\nMedia type error, please see that you are using the correct density disk...\n\n"
printf "\nExiting...\n"
exit
fi
fi
printf "\nMaking Filesystem...\n\n"
sudo mkfs.msdos $device
sleep 10
printf $'\a'
printf $'\a'
printf $'\a'
printf "\nAll done! Exiting!\n\n"
exit
;;
esac
done
done