+

Last commit for ushare.init: 353c3be7ceb5962b080b384a99eff81a6fa0ccdb

Initial commit

Benjamin Renard [2012-01-27 18:47:10]
Initial commit
  1. #!/bin/sh -e
  2. #
  3. # uShare init script
  4. #
  5. ### BEGIN INIT INFO
  6. # Provides: ushare
  7. # Required-Start: $local_fs $syslog $network
  8. # Should-Start:
  9. # Required-Stop:
  10. # Should-Stop:
  11. # Default-Start: 2 3 4 5
  12. # Default-Stop: 0 1 6
  13. # Short-Description: uShare
  14. # Description: uShare UPnP (TM) A/V & DLNA Media Server
  15. # You should edit configuration in /etc/ushare.conf file
  16. # See http://ushare.geexbox.org for details
  17. ### END INIT INFO
  18.  
  19. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  20. DAEMON=/usr/bin/ushare
  21. NAME=ushare
  22. DESC="uShare UPnP A/V & DLNA Media Server"
  23. PIDFILE=/var/run/ushare.pid
  24. CONFIGFILE=/etc/ushare.conf
  25.  
  26. # abort if no executable exists
  27. [ -x $DAEMON ] || exit 0
  28.  
  29. # Get lsb functions
  30. . /lib/lsb/init-functions
  31. . /etc/default/rcS
  32.  
  33. [ -f /etc/default/ushare ] && . /etc/default/ushare
  34.  
  35. checkpid() {
  36. [ -e $PIDFILE ] || touch $PIDFILE
  37. }
  38.  
  39. check_shares() {
  40. if [ -r "$CONFIGFILE" ]; then
  41. . $CONFIGFILE
  42. [ -n "$USHARE_DIR" ] && return 0
  43. fi
  44. return 1
  45. }
  46.  
  47. case "$1" in
  48. start)
  49. log_daemon_msg "Starting $DESC: $NAME"
  50. if ! $(check_shares); then
  51. log_warning_msg "No shares avalaible ..."
  52. log_end_msg 0
  53. else
  54. checkpid
  55. start-stop-daemon --start --quiet --background --oknodo \
  56. --make-pidfile --pidfile $PIDFILE \
  57. --exec $DAEMON -- $USHARE_OPTIONS
  58. log_end_msg $?
  59. fi
  60. ;;
  61. stop)
  62. log_daemon_msg "Stopping $DESC: $NAME"
  63. start-stop-daemon --stop --signal 2 --quiet --oknodo --pidfile $PIDFILE
  64. log_end_msg $?
  65. ;;
  66. reload|force-reload)
  67. log_daemon_msg "Reloading $DESC: $NAME"
  68. start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
  69. log_end_msg $?
  70. ;;
  71. restart)
  72. $0 stop
  73. $0 start
  74. ;;
  75. *)
  76. N=/etc/init.d/$NAME
  77. log_success_msg "Usage: $N {start|stop|restart|reload|force-reload}"
  78. exit 1
  79. ;;
  80. esac
  81.  
  82. exit 0