fhem.4 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. # description: Start or stop the fhem server
  3. # last change 2013-01-27
  4. # Added by Alex Peuchert with additions by Boris Neubert
  5. ### BEGIN INIT INFO
  6. # Provides: fhem.pl
  7. # Required-Start: $local_fs $remote_fs
  8. # Required-Stop: $local_fs $remote_fs
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: FHEM server
  12. ### END INIT INFO
  13. set -e
  14. cd /opt/fhem
  15. port=7072
  16. conf=/opt/fhem/conf/fhem.conf
  17. case "$1" in
  18. 'start')
  19. echo "Starting fhem..."
  20. perl fhem.pl $conf
  21. RETVAL=$?
  22. ;;
  23. 'prof')
  24. echo "Profiling fhem..."
  25. # Devel::NYTProf must be installed
  26. # type 'perldoc -q profile' for usage information
  27. perl -d:NYTProf fhem.pl $conf
  28. RETVAL=$?
  29. ;;
  30. 'stop')
  31. echo "Stopping fhem..."
  32. perl fhem.pl $port "shutdown"
  33. RETVAL=$?
  34. ;;
  35. 'restart')
  36. $0 stop
  37. $0 start
  38. RETVAL=$?
  39. ;;
  40. 'status')
  41. cnt=`ps -ef | grep "fhem.pl" | grep -v grep | wc -l`
  42. if [ "$cnt" -eq "0" ] ; then
  43. echo "fhem is not running"
  44. else
  45. echo "fhem is running"
  46. fi
  47. ;;
  48. *)
  49. echo "Usage: $0 { start | stop | restart | prof | status }"
  50. RETVAL=1
  51. ;;
  52. esac
  53. exit $RETVAL