-
Notifications
You must be signed in to change notification settings - Fork 30
/
bashmount
executable file
·738 lines (680 loc) · 21.8 KB
/
bashmount
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
#!/bin/bash
#=============================================================================#
# FILE: bashmount #
# VERSION: 3.0.1 #
# DESCRIPTION: bashmount is a menu-driven bash script that can use different #
# backends to easily mount, unmount or eject removable devices #
# without dependencies on udisks or any GUI. An extensive #
# configuration file allows many aspects of the script to be #
# modified and custom commands to be run on devices. #
# LICENSE: GPLv2 #
# AUTHORS: Jamie Nguyen <j@jamielinux.com> #
# Lukas B. #
#=============================================================================#
# Copyright (C) 2013-2014 Jamie Nguyen <j@jamielinux.com>
# Copyright (C) 2014 Lukas B.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License v2 as published by the
# Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
declare -r VERSION='3.0.1'
#-------------------------------------#
# CONFIGURATION #
#-------------------------------------#
# {{{
# Make sure that user defined options will not interfere with grep.
unset GREP_OPTIONS
# Set defaults.
declare udisks='auto'
declare default_mount_options='--options nosuid,noexec,noatime'
declare -i show_internal=1
declare -i show_removable=1
declare -i show_optical=1
declare -i show_commands=1
declare -i colourize=1
declare -i custom4_show=0
declare -i custom5_show=0
declare -i custom6_show=0
declare -i run_post_mount=0
declare -i run_post_unmount=0
declare -a blacklist=()
mount_command() {
if (( udisks == 0 )); then
read -r -e -p 'Choose the mountpoint directory: ' dir
while [[ ! -d "${dir}" ]] || findmnt "${dir}" >/dev/null 2>&1; do
error 'No such directory, or mountpoint is already in use.'
read -r -e -p 'Choose the mountpoint directory: ' dir
done
mount ${mount_options} "${1}" "${dir}"
else
udisksctl mount ${mount_options} --block-device "${1}"
fi
}
unmount_command() {
if (( udisks == 0 )); then
umount "${1}"
else
udisksctl unmount --block-device "${1}"
fi
}
filemanager() {
cd "${1}" && "$SHELL"
exit 0
}
post_mount() {
error "No command specified in 'bashmount.conf'."
return 1
}
post_unmount() {
error "No command specified in 'bashmount.conf'."
return 1
}
# Load configuration file.
declare CONFIGFILE=
if [[ -z "${XDG_CONFIG_HOME}" ]]; then
CONFIGFILE="${HOME}/.config/bashmount/config"
else
CONFIGFILE="${XDG_CONFIG_HOME}/bashmount/config"
fi
if [[ ! -f "${CONFIGFILE}" ]]; then
CONFIGFILE='/etc/bashmount.conf'
fi
if [[ -f "${CONFIGFILE}" ]]; then
if ! . "${CONFIGFILE}"; then
printf '%s\n' 'bashmount: Failed to source configuration file.'
exit 78
fi
fi
if [[ "${udisks}" == "auto" ]]; then
type -p udisksctl >/dev/null 2>&1 && udisks=1 || udisks=0
elif (( udisks == 1 )); then
if ! type -p udisksctl >/dev/null 2>&1; then
printf '%s\n' "bashmount: 'udisksctl': command not found"
exit 69
fi
fi
if ! type -p lsblk >/dev/null 2>&1; then
printf '%s\n' "bashmount: 'lsblk': command not found"
exit 69
fi
declare mount_options="${default_mount_options}"
# }}}
#-------------------------------------#
# GENERAL FUNCTIONS #
#-------------------------------------#
# {{{
unset ALL_OFF BOLD BLUE GREEN RED
if (( colourize )); then
if tput setaf 0 >/dev/null 2>&1; then
ALL_OFF="$(tput sgr0)"
BOLD="$(tput bold)"
BLUE="${BOLD}$(tput setaf 4)"
GREEN="${BOLD}$(tput setaf 2)"
RED="${BOLD}$(tput setaf 1)"
else
ALL_OFF='\e[1;0m'
BOLD='\e[1;1m'
BLUE="${BOLD}\e[1;34m"
GREEN="${BOLD}\e[1;32m"
RED="${BOLD}\e[1;31m"
fi
readonly ALL_OFF BOLD BLUE GREEN RED
fi
msg() {
printf '%s\n' "${GREEN}==>${ALL_OFF}${BOLD} ${@}${ALL_OFF}" >&2
}
error() {
printf '%s\n' "${RED}==>${ALL_OFF}${BOLD} ERROR: ${@}${ALL_OFF}" >&2
}
clear_screen() {
clear
printf '%s\n\n' "bashmount ${VERSION}"
}
print_commands() {
print_separator_commands
printf '%s' "${BLUE}e${ALL_OFF}: eject ${BLUE}i${ALL_OFF}: info"
printf '%s' " ${BLUE}m${ALL_OFF}: mount ${BLUE}o${ALL_OFF}: open"
printf '%s\n\n' " ${BLUE}u${ALL_OFF}: unmount"
printf '%s' "${BLUE}a${ALL_OFF}: unmount all"
printf '%s' " ${BLUE}r${ALL_OFF}: refresh"
printf '%s\n\n' " ${BLUE}q${ALL_OFF}: quit ${BLUE}?${ALL_OFF}: help"
}
print_submenu_commands() {
print_separator_commands
printf '%s' "${BLUE}e${ALL_OFF}: eject ${BLUE}i${ALL_OFF}: info"
if info_mounted "${devname}"; then
printf '%s' " ${BLUE}u${ALL_OFF}: unmount"
else
printf '%s' " ${BLUE}m${ALL_OFF}: mount"
fi
printf '%s\n\n' " ${BLUE}o${ALL_OFF}: open"
printf '%s' "${BLUE}b${ALL_OFF}: back ${BLUE}r${ALL_OFF}: refresh"
printf '%s\n' " ${BLUE}q${ALL_OFF}: quit ${BLUE}?${ALL_OFF}: help"
printf '\n'
printf '%s' "${BLUE}1${ALL_OFF}: read-only"
printf '%s' " ${BLUE}2${ALL_OFF}: luksOpen"
printf '%s' " ${BLUE}3${ALL_OFF}: luksClose"
printf '\n'
if (( custom4_show )) || (( custom5_show )) || (( custom6_show )); then
printf '\n'
fi
if (( custom4_show )) && [[ -n "${custom4_desc}" ]]; then
printf '%s' "${BLUE}4${ALL_OFF}: ${custom4_desc}"
fi
if (( custom5_show )) && [[ -n "${custom5_desc}" ]]; then
printf '%s' " ${BLUE}5${ALL_OFF}: ${custom5_desc}"
fi
if (( custom6_show )) && [[ -n "${custom6_desc}" ]]; then
printf '%s' " ${BLUE}6${ALL_OFF}: ${custom6_desc}"
fi
if (( custom4_show )) || (( custom5_show )) || (( custom6_show )); then
printf '\n'
fi
}
enter_to_continue() {
printf '\n'
read -r -e -p "Press [${BLUE}enter${ALL_OFF}] to continue: " null
}
invalid_command() {
printf '\n'
error 'Invalid command. See the help menu.'
enter_to_continue
}
print_separator() {
printf '%s\n\n' '====================================================='
}
print_separator_commands() {
printf '%s\n\n' '===================== COMMANDS ======================'
}
print_separator_device() {
printf '%s\n\n' '==================== DEVICE MENU ===================='
}
print_separator_optical() {
printf '%s\n\n' '=================== OPTICAL MEDIA ==================='
}
print_separator_removable() {
printf '%s\n\n' '================== REMOVABLE MEDIA =================='
}
print_separator_internal() {
printf '%s\n\n' '================== INTERNAL MEDIA ==================='
}
print_help() {
clear_screen
print_commands
print_separator
printf '%s' "${GREEN}==>${ALL_OFF} "
printf '%s' "${BOLD}To mount the first device, enter ${ALL_OFF}"
printf '%s' "${BLUE}1m${ALL_OFF}"
printf '%s\n\n' "${BOLD}.${ALL_OFF}"
printf '%s' "${GREEN}==>${ALL_OFF} "
printf '%s\n\n' "${BOLD}To open the mountpath directory of the first${ALL_OFF}"
printf '%s' "${BOLD} device (mounting if required), enter "
printf '%s' "${BLUE}1o${ALL_OFF}"
printf '%s\n\n' "${BOLD}.${ALL_OFF}"
printf '%s' "${GREEN}==>${ALL_OFF} "
printf '%s' "${BOLD}To view a device sub-menu, "
printf '%s\n\n' "just enter the number.${ALL_OFF}"
printf '%s' "${GREEN}==>${ALL_OFF} "
printf '%s' "${BLUE}a${ALL_OFF}"
printf '%s' "${BOLD}, "
printf '%s' "${BLUE}r${ALL_OFF}"
printf '%s' "${BOLD}, "
printf '%s' "${BLUE}q${ALL_OFF} "
printf '%s' "${BOLD}and "
printf '%s' "${BLUE}?${ALL_OFF} "
printf '%s\n\n' "${BOLD}do not require a number.${ALL_OFF}"
print_separator
enter_to_continue
}
print_help_sub() {
clear_screen
print_submenu_commands
printf '\n'
print_separator
printf '%s' "${GREEN}==>${ALL_OFF} "
printf '%s\n\n' "${BOLD}To perform a command, enter a character.${ALL_OFF}"
printf '%s' "${GREEN}==>${ALL_OFF} "
printf '%s' "${BOLD}For example, to mount this device, enter ${ALL_OFF}"
printf '%s' "${BLUE}m${ALL_OFF}"
printf '%s\n\n' "${BOLD}.${ALL_OFF}"
print_separator
enter_to_continue
}
# }}}
#-------------------------------------#
# INFORMATION RETRIEVAL #
#-------------------------------------#
# {{{
# Returns 0 if the device is registered as removable device in the kernel,
# otherwise it returns 1.
info_removable() {
[[ "$(lsblk -drno RM "${1}")" == '1' ]]
}
# Prints the device type, for example partition or disk.
info_type() {
lsblk -drno TYPE "${1}"
}
# Prints the filesystem label, if present.
info_fslabel() {
lsblk -drno LABEL "${1}"
}
# Prints the partition label, if present.
info_partlabel() {
lsblk -drno PARTLABEL "${1}"
}
# Prints the mountpath, if mounted.
info_mountpath() {
findmnt -no TARGET "${1}"
}
# Returns 0 if the device is mounted, 1 otherwise.
info_mounted() {
findmnt -no TARGET "${1}" >/dev/null 2>&1
}
# Prints the filesystem type.
info_fstype() {
lsblk -drno FSTYPE "${1}"
}
# Prints the device size.
info_size() {
lsblk -drno SIZE "${1}"
}
# }}}
#-------------------------------------#
# DEVICE MANIPULATION #
#-------------------------------------#
# {{{
check_device() {
if [[ ! -b "${1}" ]]; then
printf '\n'
error "${1} is no longer available."
enter_to_continue
return 1
fi
return 0
}
action_eject() {
check_device "${1}" || return 1
info_mounted "${1}" && action_unmount "${1}"
if ! info_mounted "${1}"; then
printf '\n'
msg "Ejecting ${1} ..."
printf '\n'
eject "${1}"
# Give the device some time to eject. If we don't then sometimes the ejected
# device will still be present when returning to the main menu.
enter_to_continue
sleep 2
fi
}
action_info() {
check_device "${1}" || return 1
lsblk -o NAME,FSTYPE,MOUNTPOINT,SIZE "${1}" | less
}
action_mount() {
check_device "${1}" || return 1
printf '\n'
if info_mounted "${1}"; then
error "${1} is already mounted."
else
msg "Mounting ${1} ..."
if mount_command "${1}"; then
msg "${1} mounted succesfullly."
(( run_post_mount )) && post_mount "${1}"
else
printf '\n'
error "${1} could not be mounted."
fi
fi
enter_to_continue
}
action_open() {
if ! info_mounted "${1}"; then
printf '\n'
msg "Mounting ${1} ..."
if mount_command "${1}"; then
msg "${1} mounted succesfullly."
(( run_post_mount )) && post_mount "${1}"
else
printf '\n'
error "${1} could not be mounted."
enter_to_continue
return 1
fi
fi
printf '\n'
msg "Opening ${1} ..."
printf '\n'
filemanager "$(info_mountpath "${1}")"
enter_to_continue
}
action_unmount() {
printf '\n'
if info_mounted "${1}"; then
msg "Unmounting ${1} ..."
printf '\n'
if unmount_command "${1}"; then
msg "${1} unmounted successfully."
(( run_post_unmount )) && post_unmount "${1}"
else
printf '\n'
error "${1} could not be unmounted."
fi
else
error "${1} is not mounted."
fi
enter_to_continue
}
# }}}
#-------------------------------------#
# MENU FUNCTIONS #
#-------------------------------------#
# {{{
list_devices() {
local -a all=() removable=() internal=() optical=()
# The array "all" contains the sorted list of devices returned by lsblk.
all=( $(lsblk -plno NAME) )
# The array "listed" contains all devices that are shown to the user.
listed=()
# The array "mounted" contains all devices that are listed and mounted.
mounted=()
# "device_number" is the total number of devices listed and equals ${#listed[*]}.
device_number=0
for devname in ${all[@]}; do
local info_type=
# Hide blacklisted devices.
for string in ${blacklist[@]}; do
lsblk -dPno NAME,TYPE,FSTYPE,LABEL,MOUNTPOINT,PARTLABEL "${devname}" \
| grep -E "${string}" >/dev/null 2>&1
(( $? )) || continue 2
done
info_type=$(info_type "${devname}")
# Sort devices into arrays removable, internal, and optical.
if [[ "${info_type}" == 'part' || "${info_type}" == 'crypt' ]]; then
if info_removable "${devname}"; then
removable[${#removable[*]}]="${devname}"
else
internal[${#internal[*]}]="${devname}"
fi
elif [[ "${info_type}" == 'rom' ]]; then
optical[${#optical[*]}]="${devname}"
else
continue
fi
done
# Print output.
# List internal media.
if (( show_internal )) && (( ${#internal[*]} )); then
print_separator_internal
for devname in ${internal[@]}; do
info_label="$(info_fslabel "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label="$(info_partlabel "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label='No label'
fi
fi
listed[device_number]="${devname}"
(( device_number++ ))
printf '%s' " ${BLUE}${device_number})${ALL_OFF}"
printf '%s' " ${devname:5}:"
printf '%s' " ${info_label}"
if info_mounted "${devname}"; then
printf '%s' " ${GREEN}[mounted]${ALL_OFF}"
mounted[${#mounted[*]}]="${devname}"
fi
printf '\n'
done
fi
# List removable media.
if (( show_removable )) && (( ${#removable[*]} )); then
printf '\n'
print_separator_removable
for devname in ${removable[@]}; do
info_label="$(info_fslabel "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label="$(info_partlabel "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label='No label'
fi
fi
listed[device_number]="${devname}"
(( device_number++ ))
printf '%s' " ${BLUE}${device_number})${ALL_OFF}"
printf '%s' " ${devname:5}:"
printf '%s' " ${info_label}"
if info_mounted "${devname}"; then
printf '%s' " ${GREEN}[mounted]${ALL_OFF}"
mounted[${#mounted[*]}]="${devname}"
fi
printf '\n'
done
fi
# List optical media.
if (( show_optical )) && (( ${#optical[*]} )); then
printf '\n'
print_separator_optical
for devname in ${optical[@]}; do
info_label="$(info_fslabel "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label="$(lsblk -dno MODEL "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label='No label'
fi
fi
listed[device_number]="${devname}"
(( device_number++ ))
printf '%s' " ${BLUE}${device_number})${ALL_OFF}"
printf '%s' " ${devname:5}:"
printf '%s' " ${info_label}"
if info_mounted "${devname}"; then
printf '%s' " ${GREEN}[mounted]${ALL_OFF}"
mounted[${#mounted[*]}]="${devname}"
fi
printf '\n'
done
fi
(( device_number )) || printf '%s\n' 'No devices.'
printf '\n'
}
submenu() {
check_device "${devname}" || return 1
local info_label= info_fstype= info_size=
info_label="$(info_fslabel "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label="$(info_partlabel "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label='-'
fi
fi
info_fstype="$(info_fstype "${devname}")"
info_size="$(info_size "${devname}")"
clear_screen
print_separator_device
printf '%s\n' "device : ${devname}"
printf '%s\n' "label : ${info_label}"
printf '%s' 'mounted : '
if info_mounted "${devname}"; then
printf '%s\n' "${GREEN}yes${ALL_OFF}"
printf '%s\n' "mountpath : $(info_mountpath "${devname}")"
else
printf '%s\n' "${RED}no${ALL_OFF}"
fi
printf '%s\n' "fstype : ${info_fstype}"
printf '%s\n' "size : ${info_size}"
if (( show_commands )); then
printf '\n'
print_submenu_commands
fi
printf '\n'
print_separator
printf '\n'
read -r -e -p 'Command: ' action
case "${action}" in
'e') action_eject "${devname}";;
'i') action_info "${devname}";;
'm') action_mount "${devname}";;
'o') action_open "${devname}";;
'u') action_unmount "${devname}";;
'b') return 1;;
'r') return 0;;
'q') exit;;
'?')
print_help_sub
return 0;;
'1')
printf '\n'
msg 'Mounting read-only ...'
printf '\n'
mount_options="${default_mount_options}"' --read-only'
mount_command "${devname}"
mount_options="${default_mount_options}"
enter_to_continue
return 0;;
'2')
printf '\n'
msg 'Opening luks volume ...'
printf '\n'
if (( udisks == 0 )); then
cryptsetup open --type luks -v "${devname}" "luks-${devname##*/}"
else
udisksctl unlock --block-device "${devname}"
fi
enter_to_continue
return 0;;
'3')
printf '\n'
msg 'Closing luks volume ...'
printf '\n'
if (( udisks == 0 )); then
cryptsetup close --type luks "${devname}"
else
udisksctl lock --block-device "${devname}"
fi
enter_to_continue
return 0;;
'4')
if (( custom4_show )); then
printf '\n'
msg "Running custom command ${custom4_desc} ..."
printf '\n'
custom4_command "${devname}"
enter_to_continue
else
invalid_command
fi
return 0;;
'5')
if (( custom5_show )); then
printf '\n'
msg "Running custom command ${custom5_desc} ..."
printf '\n'
custom5_command "${devname}"
enter_to_continue
else
invalid_command
fi
return 0;;
'6')
if (( custom6_show )); then
printf '\n'
msg "Running custom command ${custom6_desc} ..."
printf '\n'
custom6_command "${devname}"
enter_to_continue
else
invalid_command
fi
return 0;;
*) invalid_command
return 0;;
esac
}
select_action() {
local devname= letter=
local -i number=
print_separator
printf '\n'
read -r -e -p 'Command: ' action
if [[ "${action}" =~ ^[1-9] ]]; then
if [[ "${action}" =~ ^[1-9][0-9]*$ ]]; then
number="$(( action - 1 ))"
if (( number >= device_number )); then
invalid_command
return 1
fi
devname=${listed[number]}
while :; do
submenu || break
done
elif [[ "${action}" =~ ^[1-9][0-9]*[eimou]$ ]]; then
number="$(( ${action%?} - 1 ))"
letter="${action: -1}"
if (( number >= device_number )); then
invalid_command
return 1
fi
devname="${listed[number]}"
case "${letter}" in
'e') action_eject "${devname}";;
'i') action_info "${devname}";;
'm') action_mount "${devname}";;
'o') action_open "${devname}";;
'u') action_unmount "${devname}";;
*) return 1;;
esac
return 0
else
invalid_command
return 1
fi
else
case "${action}" in
'a')
printf '\n'
if (( ! ${#mounted[*]} )); then
error 'No devices mounted.'
enter_to_continue
return 1
fi
read -r -e -p 'Unmount all devices [y/N]?: ' unmount
if [[ "${unmount}" != 'y' ]] && [[ "${unmount}" != 'Y' ]]; then
return 0
fi
clear_screen
for devname in ${mounted[@]}; do
action_unmount "${devname}" || continue
done
enter_to_contine
return 1;;
'r'|"")
return 0;;
'q'|'b')
exit 0;;
'?')
print_help
return 0;;
*)
invalid_command
return 1;;
esac
fi
}
# }}}
declare -i device_number=
declare -a mounted=()
declare -a listed=()
while true; do
clear_screen
list_devices
(( show_commands )) && print_commands
select_action
done