commit 1235f4b3534dacf8e0d0c8a1f2c4bac4d6103aa4 Author: E. S Date: Sun Dec 29 00:14:21 2024 +0300 initial diff --git a/dlna_bind.sh b/dlna_bind.sh new file mode 100755 index 0000000..02338bc --- /dev/null +++ b/dlna_bind.sh @@ -0,0 +1,24 @@ +#!/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" diff --git a/dlna_restart.sh b/dlna_restart.sh new file mode 100755 index 0000000..274e442 --- /dev/null +++ b/dlna_restart.sh @@ -0,0 +1,4 @@ +#!/bin/sh +systemctl stop minidlna +rm /var/cache/minidlna/files.db +systemctl start minidlna diff --git a/dlna_unbind_all.sh b/dlna_unbind_all.sh new file mode 100755 index 0000000..eb9fdd7 --- /dev/null +++ b/dlna_unbind_all.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +bind_root="/media/minidlnad" + +if [ -z "$(ls $bind_root)" ]; then + >&2 echo "directory $bind_root is empty" + exit +fi + +for f in $bind_root/*; do + if umount "$bind_root/$(basename "$f")"; then + rm "$bind_root/$(basename "$f")" + echo "[ OK ] $f" + else + echo "[FAIL] $f" + fi +done