bin: improve stick handling

This commit is contained in:
xeruf 2022-11-23 02:28:30 +01:00
parent 87a38aaccd
commit 3e0e10a41a
2 changed files with 16 additions and 8 deletions

View File

@ -3,12 +3,14 @@
set -eo pipefail set -eo pipefail
_help="$0 <device> [mountpoint] [options...]" _help="$0 <device> [mountpoint] [options...]"
case $1 in case $1 in
(-v) shift
bash -x "$0" "$@";;
("") # TODO include size ("") # TODO include size
arg=$(lsblk --list --noheadings --output name,label,fstype,mountpoint | arg=$(lsblk --list --noheadings --output name,label,fstype,mountpoint |
grep -v '/' | grep ".\+ [^ ]\+" | fzf --select-1 --exit-0 | grep -v '/' | grep ".\+ [^ ]\+" | fzf --select-1 --exit-0 |
sed "s/^\([^ ]\+ \+\)\?\([^ ]\+\) \+[^ ]\+ *$/\2/");; sed "s/^\([^ ]\+ \+\)\?\([^ ]\+\) \+[^ ]\+ *$/\2/");;
("--help") echo "$_help" && exit 0;; (--help) echo "$_help" && exit 0;;
("-u") shift (-u) shift
for last; do true; done for last; do true; done
sudo umount --verbose "$@" sudo umount --verbose "$@"
code=$? code=$?
@ -46,7 +48,8 @@ shift $(expr 2 \& $# \> 2 \| $#)
#uid=$(id --user),gid=$(id --group), \ #uid=$(id --user),gid=$(id --group), \
if ! mountpoint "$mountpoint" 2>/dev/null if ! mountpoint "$mountpoint" 2>/dev/null
then mp="/run/media/$USER/$arg" && test -e "$mp" && mountpoint="$mp" then mp="/run/media/$USER/$arg" && test -e "$mp" && mountpoint="$mp"
sudo mount -vo users,X-mount.mkdir,noatime,umask=003,gid=users,uid=$USER $partition $mountpoint "$@" sudo mount -vo users,X-mount.mkdir,noatime,umask=003,gid=users,uid=$USER $partition $mountpoint "$@" ||
sudo mount -vo users,X-mount.mkdir,noatime $partition $mountpoint "$@"
fi fi
cd $mountpoint cd $mountpoint
exec $SHELL exec $SHELL

View File

@ -1,4 +1,4 @@
#!/bin/sh -e #!/bin/sh -ex
# Update an Easy2Boot USB Stick after adding ISOs # Update an Easy2Boot USB Stick after adding ISOs
# Call with Linux ISOs to be copied as args # Call with Linux ISOs to be copied as args
# Need to be around E2B mountpoint if it is not the default # Need to be around E2B mountpoint if it is not the default
@ -6,9 +6,14 @@ if ! dir="$(find . "${MNT:-${XDG_RUNTIME_DIR}/mnt}" -maxdepth 3 -name _ISO -type
then echo "Please mount your multiboot stick first!" then echo "Please mount your multiboot stick first!"
exit 1 exit 1
fi fi
test $# -eq 0 || mv -vi "$@" "$dir/LINUX"
find "$dir" -iname "*32-*.iso" -exec mv -vi {} {}def32 \; cmd=mv
find "$dir" -iname "*.iso" -exec mv -vi {} {}def64 \; case $1 in
drive=$(mount | grep "$(basename "$dir")" | cut -d' ' -f1) (-cp) cmd=cp; shift;;
esac
test $# -eq 0 || $cmd -vi "$@" "$dir/LINUX"
find "$dir" -type f -iname "*32-*.iso" -exec mv -vi {} {}def32 \;
find "$dir" -type f -iname "*.iso" -exec mv -vi {} {}def64 \;
drive=$(mount | grep "$(dirname "$dir")" | cut -d' ' -f1)
sudo umount $drive sudo umount $drive
sudo udefrag $drive sudo udefrag $drive