Guest User

for http://otvety.google.ru/otvety/thread?tid=7af62b6cc7fc33

a guest
Oct 3rd, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. #!/bin/sh -e
  2. #
  3. # /etc/init.d/motion: Start the motion detection
  4. #
  5. ### BEGIN INIT INFO
  6. # Provides:<---> motion
  7. # Required-Start: $local_fs $syslog $remote_fs
  8. # Required-Stop: $remote_fs
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: Start Motion detection
  12. # Description: loads motion and assigns privileges
  13. ### END INIT INFO
  14.  
  15. # Ported to new debian way using sh and /lib/lsb/init-functions
  16. # by Angel Carpintero <ack@telefonica.net>
  17. # Modified by : Juan Angulo Moreno <juan@apuntale.com>
  18. # Eddy Petrisor <eddy.petrisor@gmail.com>
  19. # ArAge <ArAge@gmx.co.uk>
  20.  
  21. NAME=motion
  22. PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin
  23. DAEMON=/usr/bin/motion
  24. PIDFILE=/var/run/$NAME.pid
  25. DEFAULTS=/etc/default/$NAME
  26. DESC="motion detection daemon"
  27.  
  28. ENV="env -i LANG=C PATH=$PATH_BIN"
  29.  
  30. . /lib/lsb/init-functions
  31.  
  32. test -x $DAEMON || exit 0
  33.  
  34. RET=0
  35.  
  36. [ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes
  37.  
  38.  
  39. check_daemon_enabled () {
  40. if [ "$start_motion_daemon" = "yes" ] ; then
  41. return 0
  42. else
  43. log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME"
  44. return 1
  45. fi
  46.  
  47. }
  48.  
  49.  
  50. case "$1" in
  51. start)
  52. if check_daemon_enabled ; then
  53. if ! [ -d /var/run/motion ]; then
  54. mkdir /var/run/motion
  55. fi
  56. chown motion:motion /var/run/motion
  57.  
  58. <------>log_daemon_msg "Starting $DESC" "$NAME".
  59. if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then
  60. log_end_msg 0
  61. else
  62. log_end_msg 1
  63. RET=1
  64. fi
  65. fi
  66. ;;
  67.  
  68. stop)
  69. log_daemon_msg "Stopping $DESC" "$NAME"
  70. if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then
  71. log_end_msg 0
  72. else
  73. log_end_msg 1
  74. RET=1
  75. fi
  76. ;;
  77.  
  78. reload|force-reload)
  79. log_daemon_msg "Reloading $NAME configuration"
  80. if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then
  81. log_end_msg 0
  82. else
  83. log_end_msg 1
  84. RET=1
  85. fi
  86. ;;
  87.  
  88. restart-motion)
  89. if check_daemon_enabled ; then
  90. log_action_begin_msg "Restarting $NAME"
  91. if $0 stop && $0 start ; then
  92. log_action_end_msg 0
  93. else
  94. log_action_cont_msg "(failed)"
  95. RET=1
  96. fi
  97. fi
  98. ;;
  99.  
  100. restart)
  101. $0 restart-motion
  102. ;;
  103.  
  104. *)
  105. echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}"
  106. RET=1
  107. ;;
  108. esac
  109.  
  110.  
  111. exit $RET
Add Comment
Please, Sign In to add comment