dotfiles/local/bin/mount-jool

34 lines
599 B
Plaintext
Raw Normal View History

2021-02-13 18:26:38 +00:00
#!/usr/bin/env bash
set -o errexit
set -o pipefail
main() {
if [[ -f ~/mnt/jool/.mounted ]]; then
printf 'Already mounted\n' >&2
exit 0
fi
2021-02-14 14:40:45 +00:00
local sshfs_args=(
me@jool:/store/sshfs/meatballhat
~/mnt/jool
-p 23436
-C
)
local sshfs_uidfile="${HOME}/.config/sshfs-$(_hostname)-uidmap"
if [[ -f "${sshfs_uidfile}" ]]; then
sshfs_args=(-o uidfile="${sshfs_uidfile}" "${sshfs_args[@]}")
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 "${@}"