dotfiles/local/bin/mount-jool

39 lines
811 B
Plaintext
Raw Permalink Normal View History

2021-02-13 18:26:38 +00:00
#!/usr/bin/env bash
set -o errexit
set -o pipefail
main() {
2022-07-13 14:52:20 +00:00
killall -9 -q -w -r 'sshfs.+me@jool:/store/sshfs/meatballhat.+' || true
2022-06-30 13:57:43 +00:00
fusermount -u ~/mnt/jool 2>/dev/null || true
2021-02-13 18:26:38 +00:00
2021-02-14 14:40:45 +00:00
local sshfs_args=(
me@jool:/store/sshfs/meatballhat
~/mnt/jool
2021-02-14 17:15:05 +00:00
-o auto_unmount
-o default_permissions
-o reconnect
2021-02-14 14:40:45 +00:00
-p 23436
-C
)
local sshfs_uidfile="${HOME}/.config/sshfs-$(_hostname)-uidmap"
if [[ -f "${sshfs_uidfile}" ]]; then
2021-02-14 17:15:05 +00:00
sshfs_args=("${sshfs_args[@]}" -o uidfile="${sshfs_uidfile}")
fi
if [[ "${DEBUG}" == enabled ]]; then
sshfs_args=("${sshfs_args[@]}" -f -o sshfs_debug -o LogLevel=DEBUG3)
2021-02-14 14:40:45 +00:00
fi
2021-02-13 18:26:38 +00:00
mkdir -p ~/mnt/jool
2021-02-14 14:40:45 +00:00
sshfs "${sshfs_args[@]}"
}
_hostname() {
hostname 2>/dev/null ||
hostnamectl status --static 2>/dev/null ||
echo unknown
2021-02-13 18:26:38 +00:00
}
main "${@}"