feat: am and dm mount scripts

This commit is contained in:
AngeD 2022-12-22 22:48:59 +01:00
parent 57fd4f9fab
commit dbd7223f08
7 changed files with 52 additions and 9 deletions

@ -1 +1 @@
Subproject commit 54eb2a070a4f389b1be0f98070f81d23e2b1a715
Subproject commit 25f0c65bd8fddadbafd0048a68560bf160ceb98c

@ -1 +1 @@
Subproject commit cabf991b1d3996fa6f3232327fc649bbdf676496
Subproject commit e960efa60e97df58e089b00270f09d60f27202c8

@ -1 +1 @@
Subproject commit 2603f1d4316acb0e569d1cdf04c631e867468e37
Subproject commit eaeedfb80419e8145760d95d1840996a2746af7c

View File

@ -14,11 +14,6 @@ alias zconf='(cd $ZDOTDIR/ && $EDITOR . && . $ZDOTDIR/.zshrc)'
# dev
alias epitest='docker run -it --rm -v $PWD:/usr/app/ epitechcontent/epitest-docker bash'
# disk
alias automount='MNT=$(udisksctl mount -b /dev/sda1 2> /dev/null || udisksctl mount -b /dev/sdb1) && cd ${MNT/* }'
alias autoumount='umount /media/*/* /run/media/*/*'
alias umnt='sudo umount /mnt -R'
# compatibility
alias ssh='TERM=linux ssh'

@ -1 +1 @@
Subproject commit 13082bb159361d1c0807eb7e5577f4c670cb0f88
Subproject commit 9c2d1af8afa02b5439e8ccc81a160e62e1e59617

18
bin/am Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -e
# TODO
# - mount all partitions by selecting disk
# - hide already mounted partitions
# - usage
# - one device per line
# - support for /mnt
readarray -t LSBLK <<< "$(lsblk -n --paths --list | grep part)"
select dev in "${LSBLK[@]}"; do
name="$(cut -f1 -d' ' <<< "$dev")"
udisksctl mount -b "$name"
echo "$name" >> /tmp/automount
done

30
bin/dm Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
set -e
function unmount() {
local name
for dev in "$@"; do
name="$(cut -f1 -d' ' <<< "$dev")"
umount "$name"
sed -i "\\|$name|d" /tmp/automount
done
}
readarray -t LSBLK <<< "$(lsblk --paths --list | grep -f /tmp/automount)"
while getopts a o; do
case "$o" in
a)
unmount "${LSBLK[@]}"
exit 0
;;
*)
;;
esac
done
select dev in "${LSBLK[@]}"; do
unmount "$dev"
done