OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.8 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../vdr/mount.sh
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. #
  16. # This script is called from VDR to mount/unmount/eject
  17. # the sources for MP3 play.
  18. #
  19. # argument 1: wanted action, one of mount,unmount,eject,status
  20. # argument 2: mountpoint to act on
  21. #
  22. # mount,unmount,eject must return 0 if succeeded, 1 if failed
  23. # status must return 0 if device is mounted, 1 if not
  24. #
  25. action="$1"
  26. path="$2"
  27. mount_device() {
  28. case "$action" in
  29. mount)
  30. eject -t "$path" || exit 1 # close the tray
  31. mount "$path" || exit 1 # mount it
  32. ;;
  33. unmount)
  34. umount "$path" || exit 1 # unmount it
  35. ;;
  36. eject)
  37. eject "$path" || exit 1 # eject disk
  38. ;;
  39. status)
  40. cat /proc/mounts | grep -q "$path" # check if mounted
  41. if [ $? -ne 0 ]; then # not mounted ...
  42. exit 1
  43. fi
  44. esac
  45. }
  46. mount_directory() {
  47. if [ ! -d $path ] ; then # not an existing directory
  48. logger " $path does not exist !"
  49. exit 1
  50. fi
  51. case "$action" in
  52. mount)
  53. ;;
  54. unmount)
  55. ;;
  56. eject)
  57. ;;
  58. status)
  59. ;;
  60. esac
  61. }
  62. if [ "`grep $path /etc/fstab | grep -v '^#' `" != "" ] ; then # there is an entry in fstab
  63. logger "Mounting device $path ..."
  64. mount_device
  65. else
  66. logger "Mounting dir $path ..."
  67. mount_directory
  68. fi
  69. exit 0