25 lines
414 B
Bash
Executable File
25 lines
414 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
error_exit() {
|
|
>&2 echo "$@"
|
|
exit 1
|
|
}
|
|
|
|
[ -z "$1" ] && error_exit "usage: $0 file_or_directory_path"
|
|
|
|
bind_root=/media/minidlnad
|
|
name="$(basename "$1")"
|
|
mountpoint="$bind_root/$name"
|
|
|
|
[ -e "$mountpoint" ] && error_exit "error: mountpoint $bind_root/$name already exists"
|
|
|
|
if [ -f "$1" ]; then
|
|
touch "$mountpoint"
|
|
elif [ -d "$1" ]; then
|
|
mkdir "$mountpoint"
|
|
fi
|
|
|
|
mount --bind "$1" "$mountpoint"
|