4 echo -e "\033[32m$*\033[0m"
8 echo -e "\033[33m$*\033[0m"
12 echo -e "\033[31m$*\033[0m"
16 sec
=$(cat /sys/block/$1/size)
23 ls /sys
/block
/ | egrep 'd[a-z]|nvme|mmc' | while read dev
; do
24 if ! [ -b /dev
/$dev ]; then
28 size
=$(get_disk_size $dev)
29 model
=$(parted -s /dev/$dev p 2>/dev/null | grep Model | sed 's/Model: \(.*\)/\
1/')
30 printf " <%d> %-4s %3s GB %s\r\n" $id "$dev" "$size" "$model" >> /device.list
37 echo "" > /dev/console
38 echo "" > /dev/console
40 if [ -f /device.list ]; then
41 lines=$(cat /device.list | wc -l)
42 cat /device.list > /dev/console
44 echo -e "\033[31m !!! NO device detected !!!\033[0m" > /dev/console
48 echo "" > /dev/console
49 echo " <a> Refresh device list <b> Reboot <c> Enter shell" > /dev/console
50 echo "" > /dev/console
54 if [ $lines -gt 0 ]; then
55 read -p "Please select the disk to operator [1-$lines] " Answer
57 read -p "Please choose your operation [a-c] " Answer
60 if [ "$Answer" = "shell" ]; then
62 elif [ "$Answer" = "c" ] || [ "$Answer" = "C" ]; then
66 if [ "$Answer" = "a" ] || [ "$Answer" = "A" ]; then
68 elif [ "$Answer" = "b" ] || [ "$Answer" = "B" ]; then
69 read -p "Do you really want to reboot? (y/n) " Ask
70 if [ "$Ask" = "y" ] || [ "$Ask" = "Y" ]; then
77 if [ -n "$Answer" ]; then
78 if echo $Answer | grep -q "^[1-9][0-9]*$"; then
79 if [ $Answer -gt 0 ] && [ $Answer -le $lines ]; then
88 get_dev_ventoy_ver() {
89 if ! [ -b /dev/${1}2 ]; then
93 mount -t vfat -o ro /dev/${1}2 /ventoy/mnt >/dev/null 2>/dev/null
94 if [ -e /ventoy/mnt/ventoy ] && [ -f /ventoy/mnt/grub/grub.cfg ]; then
95 if grep -q 'set.
*VENTOY_VERSION
=' /ventoy/mnt/grub/grub.cfg; then
96 grep 'set.
*VENTOY_VERSION
=' /ventoy/mnt/grub/grub.cfg | awk -F'"' '{print $2}'
108 ventoy_configuration() {
111 if [ -f /preserve.txt ]; then
112 SPACE=$(cat /preserve.txt)
117 if [ -f /secureboot.txt ]; then
118 SECURE=$(cat /secureboot.txt)
123 if [ -f /partstyle.txt ]; then
124 STYLE=$(cat /partstyle.txt)
130 echo -e " <1> Preserve space
(only
for install) \033[32m
[${SPACE}MB
]\033[0m
"
131 echo -e " <2> Secure boot support
\033[32m
[$SECURE]\033[0m
"
132 echo -e " <3> Partition style
(only
for install) \033[32m
[$STYLE]\033[0m
"
133 echo " <0> Back to previous menu
"
137 read -p "Please choose your operation
: " Answer
138 if echo $Answer | grep -q "^
[0-3]$
"; then
143 if [ "$Answer" = "0" ]; then
145 elif [ "$Answer" = "1" ]; then
147 read -p "Please input the preserve space
in MB
: " Answer
148 if echo $Answer | grep -q "^
[0-9][0-9]*$
"; then
149 echo $Answer > /preserve.txt
153 elif [ "$Answer" = "2" ]; then
154 if [ "$SECURE" = "Disable
" ]; then
155 echo "Enable
" > /secureboot.txt
157 echo "Disable
" > /secureboot.txt
160 if [ "$STYLE" = "GPT
" ]; then
161 echo "MBR
" > /partstyle.txt
163 echo "GPT
" > /partstyle.txt
170 VTPATH=$(ls -1 | grep ventoy-)
178 info "**************************************************"
179 vline=$(printf "* Ventoy LiveCD %6s *\r\n" "$VTVER")
181 info "**************************************************"
183 info "Scaning devices ......
"
191 if [ $sel -eq 8888 ]; then
193 elif [ $sel -eq 0 ]; then
198 DEV=$(sed -n "${sel}p" /device.list | awk '{print $2}')
199 DevVtVer=$(get_dev_ventoy_ver $DEV)
202 if [ "$DevVtVer" = "NO
" ]; then
206 echo " <1> Install Ventoy to
$DEV"
207 echo " <2> Set Configuration
"
208 echo " <0> Back to previous menu
"
212 read -p "Please choose your operation
: " Answer
213 if echo $Answer | grep -q "^
[0-2]$
"; then
218 if [ "$Answer" = "0" ]; then
220 elif [ "$Answer" = "2" ]; then
225 if [ -f /preserve.txt ]; then
226 opt="$opt -r $(cat /preserve.txt)"
229 if [ -f /secureboot.txt ] && grep -q "Enable
" /secureboot.txt; then
233 if [ -f /partstyle.txt ] && grep -q "GPT
" /partstyle.txt; then
237 info "Ventoy2Disk.sh
$opt -i /dev
/$DEV"
238 sh Ventoy2Disk.sh $opt -i /dev/$DEV
244 info "Ventoy
$DevVtVer detected
in the device
$DEV"
248 echo " <1> Update Ventoy
in $DEV from
$DevVtVer ==> $VTVER"
249 echo " <2> Re
-install Ventoy to
$DEV"
250 echo " <3> Set Configuration
"
251 echo " <0> Back to previous menu
"
255 read -p "Please choose your operation
: " Answer
256 if echo $Answer | grep -q "^
[0-3]$
"; then
261 if [ "$Answer" = "0" ]; then
263 elif [ "$Answer" = "1" ]; then
265 if [ -f /secureboot.txt ] && grep -q "Enable
" /secureboot.txt; then
269 info "Ventoy2Disk.sh
$opt -u /dev
/$DEV"
270 sh Ventoy2Disk.sh $opt -u /dev/$DEV
273 elif [ "$Answer" = "2" ]; then
275 if [ -f /preserve.txt ]; then
276 opt="$opt -r $(cat /preserve.txt)"
279 if [ -f /secureboot.txt ] && grep -q "Enable
" /secureboot.txt; then
283 if [ -f /partstyle.txt ] && grep -q "GPT
" /partstyle.txt; then
287 info "Ventoy2Disk.sh
$opt -I /dev
/$DEV"
288 sh Ventoy2Disk.sh $opt -I /dev/$DEV