rc.g15daemon 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh
  2. # rc script to start/stop g15daemon.
  3. # Copyright 2011 Alan Alberghini <414N@slacky.it>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. G15DAEMON_PATH=/usr/sbin/g15daemon
  23. . /etc/rc.d/rc.g15daemon.conf
  24. NUM_PLUGINS=${#PLUGINS[*]}
  25. function start()
  26. {
  27. echo -n "Starting g15daemon..."
  28. "$G15DAEMON_PATH"
  29. if [ $NUM_PLUGINS -gt 0 ]
  30. then
  31. ( sleep 2 # Need a little time for g15daemon to settle
  32. for I in $(seq 0 $NUM_PLUGINS)
  33. do
  34. ${PLUGINS[$I]} ${PLUGIN_PARAMS[$I]} &>/dev/null &
  35. done ) &
  36. fi
  37. echo -ne "Done!\n"
  38. }
  39. function stop()
  40. {
  41. echo -n "Stopping g15daemon..."
  42. if [ $(pidof g15daemon) ]
  43. then
  44. /usr/sbin/g15daemon -k
  45. echo -ne "Done!\n"
  46. else
  47. echo -ne "Failed! g15daemon not running!\n"
  48. fi
  49. }
  50. function restart()
  51. {
  52. stop
  53. sleep 1
  54. start
  55. }
  56. case $1 in
  57. start)
  58. start;;
  59. stop)
  60. stop;;
  61. restart)
  62. restart;;
  63. *)
  64. echo "Usage: $(basename $0) start | stop | restart"
  65. exit 1;;
  66. esac