summaryrefslogtreecommitdiff
path: root/vdr/scripts/vdrmount
blob: 0be7b02904a089d9d3484de7d4e6bb16fa3a5133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#
# This script is called from VDR to mount/unmount/eject
# the sources for MP3 play.
#
# argument 1: wanted action, one of mount,unmount,eject,status
# argument 2: mountpoint to act on
#
# mount,unmount,eject must return 0 if succeeded, 1 if failed
# status must return 0 if device is mounted, 1 if not
#

action="$1"
path="$2"

case "$action" in
   mount)
      if [ -z "$(echo $path | grep "usb")" ]; then
         eject -t "$path" || exit 1       # close the tray
      fi
      mount "$path" || exit 1             # mount it
      ;;
   unmount)
      umount "$path" || exit 1            # unmount it
      ;;
   eject)
      eject "$path" || exit 1             # eject disk
      ;;
   status)
      cat /proc/mounts | grep -q "$path"  # check if mounted
      [ $? -ne 0 ] && exit 1              # not mounted ...
      ;;
esac

exit 0