Small fixes of problems found while writing documentation

This commit is contained in:
Thomas Schmitt 2019-12-02 10:56:15 +01:00
parent 9ffb3ff2d5
commit a6ab055153

View File

@ -74,7 +74,7 @@ print_usage() {
echo " The found device is then shown with advice, vendor," echo " The found device is then shown with advice, vendor,"
echo " and model. Option -DO_WRITE is obeyed if given." echo " and model. Option -DO_WRITE is obeyed if given."
echo " -list_all Print list of all found devices with advice, vendor" echo " -list_all Print list of all found devices with advice, vendor"
echo " and model, One per line. Ignore any device names." echo " and model. One per line. Ignore any device names."
echo " Ignore -DO_WRITE." echo " Ignore -DO_WRITE."
echo " -with_vendor_model Print vendor and model with each submitted device." echo " -with_vendor_model Print vendor and model with each submitted device."
echo echo
@ -89,7 +89,6 @@ print_usage() {
echo " any further filesystem type is acceptable on that" echo " any further filesystem type is acceptable on that"
echo " device. Else only ISO 9660 and VFAT are accepted." echo " device. Else only ISO 9660 and VFAT are accepted."
echo " -with_sudo Run '$lsblk_cmd -o FSTYPE' by sudo." echo " -with_sudo Run '$lsblk_cmd -o FSTYPE' by sudo."
echo " If so, consider to enable this without password."
echo " If no filesystems are detected and the program" echo " If no filesystems are detected and the program"
echo " has no superuser power, the device is not advised." echo " has no superuser power, the device is not advised."
echo " If -DO_WRITE is given, run umount and dd by sudo." echo " If -DO_WRITE is given, run umount and dd by sudo."
@ -230,11 +229,11 @@ arg_interpreter() {
have_su_power=y have_su_power=y
elif test -n "$with_sudo" elif test -n "$with_sudo"
then then
echo "Testing sudo to possibly get password prompting done now:" echo "Testing sudo to possibly get password prompting done now:" >&2
if sudo $lsblk_cmd -h >/dev/null if sudo $lsblk_cmd -h >/dev/null
then then
echo "sudo $lsblk_cmd seems ok." echo "sudo $lsblk_cmd seems ok." >&2
echo echo >&2
sudo_cmd=sudo sudo_cmd=sudo
have_su_power=y have_su_power=y
else else
@ -247,13 +246,13 @@ arg_interpreter() {
## Trying to find the desired device by watching plug-in effects ## Trying to find the desired device by watching plug-in effects
plug_in_watcher() { plug_in_watcher() {
found_devices= found_devices=
echo echo >&2
echo "Caused by option -plug_test: Attempt to find the desired device" echo "Caused by option -plug_test: Attempt to find the desired device" >&2
echo "by watching it appear after being plugged in." echo "by watching it appear after being plugged in." >&2
echo echo >&2
echo "Step 1:" echo "Step 1:" >&2
echo "Please make sure that the desired target device is plugged _out_ now." echo "Please make sure that the desired target device is plugged _out_ now." >&2
echo "Press the Enter key when ready." echo "Press the Enter key when ready." >&2
read dummy read dummy
old_device_list=' '$($lsblk_cmd -d -n -o NAME | grep -v '^sr[0-9]' | grep -v '^fd[0-9]' | tr '\n\r' ' ')' ' old_device_list=' '$($lsblk_cmd -d -n -o NAME | grep -v '^sr[0-9]' | grep -v '^fd[0-9]' | tr '\n\r' ' ')' '
@ -261,12 +260,12 @@ plug_in_watcher() {
# <<< Their presence in new_device_list will let them appear as fresh plugs # <<< Their presence in new_device_list will let them appear as fresh plugs
# old_device_list=' '$(echo -n $old_device_list | sed -e 's/sd[e-f]//')' ' # old_device_list=' '$(echo -n $old_device_list | sed -e 's/sd[e-f]//')' '
echo "Found and noted as _not_ desired: $old_device_list" echo "Found and noted as _not_ desired: $old_device_list" >&2
echo echo >&2
echo "Step 2:" echo "Step 2:" >&2
echo "Please plug in the desired target device and then press the Enter key." echo "Please plug in the desired target device and then press the Enter key." >&2
read dummy read dummy
echo -n "Waiting up to 10 seconds for a new device to be listed ..." echo -n "Waiting up to 10 seconds for a new device to be listed ..." >&2
end_time="$(expr $(date +'%s') + 10)" end_time="$(expr $(date +'%s') + 10)"
while test $(date +'%s') -le "$end_time" while test $(date +'%s') -le "$end_time"
do do
@ -274,7 +273,7 @@ plug_in_watcher() {
if test "$old_device_list" = "$new_device_list" if test "$old_device_list" = "$new_device_list"
then then
sleep 1 sleep 1
echo -n '.' echo -n '.' >&2
else else
for i in $new_device_list for i in $new_device_list
do do
@ -287,7 +286,7 @@ plug_in_watcher() {
done done
fi fi
done done
echo echo >&2
if test -z "$found_devices" if test -z "$found_devices"
then then
echo "SORRY: No new candidate device was found." >&2 echo "SORRY: No new candidate device was found." >&2
@ -296,24 +295,24 @@ plug_in_watcher() {
num=$(echo $found_devices | wc -w) num=$(echo $found_devices | wc -w)
if test "$num" -gt 1 if test "$num" -gt 1
then then
echo "SORRY: More than one new candidate device appeared: $found_devices" echo "SORRY: More than one new candidate device appeared: $found_devices" >&2
return 9 return 9
fi fi
echo "Found and noted as desired device: $found_devices" echo "Found and noted as desired device: $found_devices" >&2
if test -n "$devs" if test -n "$devs"
then then
echo "(-plug_test is overriding device list given by arguments: $devs )" echo "(-plug_test is overriding device list given by arguments: $devs )" >&2
fi fi
if test -n "$list_all" if test -n "$list_all"
then then
echo "(-plug_test is overriding -list_all)" echo "(-plug_test is overriding -list_all)" >&2
list_all= list_all=
fi fi
devs_named=y devs_named=y
with_vendor_model=y with_vendor_model=y
show_reasons=y show_reasons=y
devs=$(echo -n $found_devices) devs=$(echo -n $found_devices)
echo echo >&2
return 0 return 0
} }
@ -520,6 +519,21 @@ write_image() {
echo "No executable program umount found in: $sudo_x_dir_list" >&2 echo "No executable program umount found in: $sudo_x_dir_list" >&2
return 6 return 6
fi fi
echo "Looking for mount points of $2:"
partitions=$($lsblk_cmd -n -p -o NAME /dev/"$2" | grep -v '^'/dev/"$2"'$' \
| sed -e 's/[^a-zA-Z0-9_+@:.,/-]//g' | tr '\n\r' ' ')
mounted_devs=
for i in /dev/"$2" $partitions
do
# Show the found mount lines and add their device paths to list
mount_line=$(mount | grep '^'"$i"' ')
if test -n "$mount_line"
then
echo " $mount_line"
mounted_devs="$mounted_devs $i"
fi
done
if test -n "$dummy_force" if test -n "$dummy_force"
then then
echo "AGAINST THE ADVICE BY THIS PROGRAM, a daring user could do:" echo "AGAINST THE ADVICE BY THIS PROGRAM, a daring user could do:"
@ -528,17 +542,6 @@ write_image() {
then then
echo "Would do if not -dummy:" echo "Would do if not -dummy:"
fi fi
partitions=$($lsblk_cmd -n -p -o NAME /dev/"$2" | grep -v '^'/dev/"$2"'$' \
| sed -e 's/[^a-zA-Z0-9_+@:.,/-]//g' | tr '\n\r' ' ')
mounted_devs=
for i in /dev/"$2" $partitions
do
if mount | grep '^'"$i"' ' >/dev/null
then
mounted_devs="$mounted_devs $i"
fi
done
if test -n "$mounted_devs" if test -n "$mounted_devs"
then then
for i in $mounted_devs for i in $mounted_devs
@ -573,6 +576,8 @@ write_image() {
echo "--- not activated yet ---" echo "--- not activated yet ---"
fi fi
# >>> ??? Erase possible GPT backup table at end of device ?
if test -n "$dummy_force" if test -n "$dummy_force"
then then
echo "BE SMART. BE CAUTIOUS. BEWARE." echo "BE SMART. BE CAUTIOUS. BEWARE."
@ -606,7 +611,7 @@ then
num_devs=$(echo $devs| wc -w) num_devs=$(echo $devs| wc -w)
if test -n "$dummy_force" -a "$num_devs" -ne 1 if test -n "$dummy_force" -a "$num_devs" -ne 1
then then
echo "SORRY: Refusing -dummy_force with not exactly one device." >&2 echo "SORRY: Refusing -dummy_force with not exactly one device given." >&2
exit 10 exit 10
fi fi
if test -n "$dummy_force" -a -n "$dummy_run" -a "$num_cand" -ne 1 if test -n "$dummy_force" -a -n "$dummy_run" -a "$num_cand" -ne 1
@ -629,19 +634,19 @@ then
if test -n "$do_plug_test" if test -n "$do_plug_test"
then then
echo echo
echo "Step 3:" echo "Step 3:" >&2
if test -n "$dummy_run" if test -n "$dummy_run"
then then
echo "This would be the last chance to abort. Press Enter to see -dummy report." echo "This would be the last chance to abort. Press Enter to see -dummy report." >&2
else else
echo "Last chance to abort. Press Enter to start REAL WRITING." echo "Last chance to abort. Press Enter to start REAL WRITING." >&2
fi fi
read dummy read dummy
fi fi
write_image "$image_file" $candidates write_image "$image_file" $candidates
exit $? exit $?
else else
echo "Would write to /dev/$candidates if an -image_file were given." >&2 echo "Would write to /dev/$candidates if an -image_file were given."
exit 0 exit 0
fi fi
elif test "$num_cand" -gt 1 elif test "$num_cand" -gt 1
@ -651,7 +656,7 @@ then
with_vendor_model=y with_vendor_model=y
devs="$candidates" devs="$candidates"
list_devices >&2 list_devices >&2
echo "HINT: Unplug the unwanted devices from the machine," echo "HINT: Unplug the unwanted devices from the machine," >&2
echo " or work with option -plug_test," >&2 echo " or work with option -plug_test," >&2
echo " or add the desired name out of {$(echo $candidates | sed -e 's/ /,/g')} as additional argument." >&2 echo " or add the desired name out of {$(echo $candidates | sed -e 's/ /,/g')} as additional argument." >&2
exit 3 exit 3
@ -662,7 +667,7 @@ then
else else
echo "NO CANDIDATE FOR TARGET DEVICE FOUND !" >&2 echo "NO CANDIDATE FOR TARGET DEVICE FOUND !" >&2
fi fi
echo "Overall available devices:" echo "Overall available devices:" >&2
list_all=y list_all=y
show_reasons=y show_reasons=y
with_vendor_model=y with_vendor_model=y