Начальная последовательность движения – модификация скрипта оболочки

Я попытался изменить этот скрипт, чтобы запустить Motion, используя следующие библиотеки.

Я запускаю скрипт, введя следующую команду в терминал:

sudo /etc/init.d/motion start 

Который дает:

 start-stop-daemon: user '/etc/motion/motion.conf' not found Starting motion detection daemon: motion failed! 

Я triple проверил, что файл motion.conf имеет правильные разрешения и находится в каталоге / etc / motion /.

Если я введу следующую команду в терминал, движение начнется правильно.

 LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so motion -c /etc/motion/motion.conf 

Сценарий находится в /etc/init.d и называется движением.

 #!/bin/sh -e # # /etc/init.d/motion: Start the motion detection # ### BEGIN INIT INFO # Provides: motion # Required-Start: $local_fs $syslog $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Motion detection # Description: loads motion and assigns privileges ### END INIT INFO # Ported to new debian way using sh and /lib/lsb/init-functions # by Angel Carpintero <ack@telefonica.net> # Modified by : Juan Angulo Moreno <juan@apuntale.com> # eddy Petrisor <eddy.petrisor@gmail.com> # ArAge <ArAge@gmx.co.uk> NAME=motion PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/bin/motion PIDFILE=/var/run/$NAME.pid DEFAULTS=/etc/default/$NAME DESC="motion detection daemon" export "LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so" ########################################################################################################### ### this above command is what is needed to be entered into terminal to run motion from command prompt #### ########################################################################################################### ENV="env -i LANG=C PATH=$PATH_BIN" . /lib/lsb/init-functions test -x $DAEMON || exit 0 RET=0 [ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes check_daemon_enabled () { if [ "$start_motion_daemon" = "yes" ] ; then return 0 else log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" return 1 fi } case "$1" in start) if check_daemon_enabled ; then if ! [ -d /var/run/motion ]; then mkdir /var/run/motion fi chown motion:motion /var/run/motion chmod 777 /var/run/motion # this is the fix we've added to allow the network share to be connected first before we try to start motion: sleep 30 log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion $DAEMON -c /etc/motion/motion.conf ; then log_end_msg 0 else log_end_msg 1 RET=1 fi fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; reload|force-reload) log_daemon_msg "Reloading $NAME configuration" if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; restart-motion) if check_daemon_enabled ; then log_action_begin_msg "Restarting $NAME" if $0 stop && $0 start ; then log_action_end_msg 0 else log_action_cont_msg "(failed)" RET=1 fi fi ;; restart) $0 restart-motion ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" RET=1 ;; esac exit $RET и #!/bin/sh -e # # /etc/init.d/motion: Start the motion detection # ### BEGIN INIT INFO # Provides: motion # Required-Start: $local_fs $syslog $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Motion detection # Description: loads motion and assigns privileges ### END INIT INFO # Ported to new debian way using sh and /lib/lsb/init-functions # by Angel Carpintero <ack@telefonica.net> # Modified by : Juan Angulo Moreno <juan@apuntale.com> # eddy Petrisor <eddy.petrisor@gmail.com> # ArAge <ArAge@gmx.co.uk> NAME=motion PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/bin/motion PIDFILE=/var/run/$NAME.pid DEFAULTS=/etc/default/$NAME DESC="motion detection daemon" export "LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so" ########################################################################################################### ### this above command is what is needed to be entered into terminal to run motion from command prompt #### ########################################################################################################### ENV="env -i LANG=C PATH=$PATH_BIN" . /lib/lsb/init-functions test -x $DAEMON || exit 0 RET=0 [ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes check_daemon_enabled () { if [ "$start_motion_daemon" = "yes" ] ; then return 0 else log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" return 1 fi } case "$1" in start) if check_daemon_enabled ; then if ! [ -d /var/run/motion ]; then mkdir /var/run/motion fi chown motion:motion /var/run/motion chmod 777 /var/run/motion # this is the fix we've added to allow the network share to be connected first before we try to start motion: sleep 30 log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion $DAEMON -c /etc/motion/motion.conf ; then log_end_msg 0 else log_end_msg 1 RET=1 fi fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; reload|force-reload) log_daemon_msg "Reloading $NAME configuration" if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; restart-motion) if check_daemon_enabled ; then log_action_begin_msg "Restarting $NAME" if $0 stop && $0 start ; then log_action_end_msg 0 else log_action_cont_msg "(failed)" RET=1 fi fi ;; restart) $0 restart-motion ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" RET=1 ;; esac exit $RET по #!/bin/sh -e # # /etc/init.d/motion: Start the motion detection # ### BEGIN INIT INFO # Provides: motion # Required-Start: $local_fs $syslog $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Motion detection # Description: loads motion and assigns privileges ### END INIT INFO # Ported to new debian way using sh and /lib/lsb/init-functions # by Angel Carpintero <ack@telefonica.net> # Modified by : Juan Angulo Moreno <juan@apuntale.com> # eddy Petrisor <eddy.petrisor@gmail.com> # ArAge <ArAge@gmx.co.uk> NAME=motion PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/bin/motion PIDFILE=/var/run/$NAME.pid DEFAULTS=/etc/default/$NAME DESC="motion detection daemon" export "LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so" ########################################################################################################### ### this above command is what is needed to be entered into terminal to run motion from command prompt #### ########################################################################################################### ENV="env -i LANG=C PATH=$PATH_BIN" . /lib/lsb/init-functions test -x $DAEMON || exit 0 RET=0 [ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes check_daemon_enabled () { if [ "$start_motion_daemon" = "yes" ] ; then return 0 else log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" return 1 fi } case "$1" in start) if check_daemon_enabled ; then if ! [ -d /var/run/motion ]; then mkdir /var/run/motion fi chown motion:motion /var/run/motion chmod 777 /var/run/motion # this is the fix we've added to allow the network share to be connected first before we try to start motion: sleep 30 log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion $DAEMON -c /etc/motion/motion.conf ; then log_end_msg 0 else log_end_msg 1 RET=1 fi fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; reload|force-reload) log_daemon_msg "Reloading $NAME configuration" if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; restart-motion) if check_daemon_enabled ; then log_action_begin_msg "Restarting $NAME" if $0 stop && $0 start ; then log_action_end_msg 0 else log_action_cont_msg "(failed)" RET=1 fi fi ;; restart) $0 restart-motion ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" RET=1 ;; esac exit $RET 

после помощи Anthon's и Mikeserv, вот еще информация:

1): ls -lrt /var/log

дает:

-rw-r —– 1 root adm 122336 Oct 12 08:10 auth.log

2) запись auth.log дает:

08:10:26 raspberrypi sudo: pam_unix (sudo: session): сеанс закрыт для пользователя root

Замените линии LOAD_LIBRARIES.... с помощью:

 export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so 

Это делает параметр LD_PRELOAD доступным для команд / программ, вызываемых из сценария (например, motion

И строка, if start-stop-daemon --start ....

 if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion $DAEMON -c /etc/motion/motion.conf ; then 

Параметр start-stop-daemon --chuid принимает в качестве параметра имя пользователя, поэтому я ожидаю, что motion будет таким именем. Это не оставляет команды в исходной строке, поэтому вам следует вставить $ DAEMON (полный путь к motion ) и его параметр командной строки.

После многих часов разочарования и большой помощи от участников форума мне удалось заставить его работать. Я никоим образом не беру на себя ответственность за это, отправив ответ и ценю всю помощь, которую мне дали; но только для полноты, вот как я это сделал.

Я добавил строку export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so в скрипт /etc/init.d/motion и удостоверился, что папка, в которой я export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so свои фотографии, имела разрешения, чтобы пользовательское движение может написать ему -opps!

 #!/bin/sh -e # # /etc/init.d/motion: Start the motion detection # ### BEGIN INIT INFO # Provides: motion # Required-Start: $local_fs $syslog $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Motion detection # Description: loads motion and assigns privileges ### END INIT INFO # Ported to new debian way using sh and /lib/lsb/init-functions # by Angel Carpintero <ack@telefonica.net> # Modified by : Juan Angulo Moreno <juan@apuntale.com> # eddy Petrisor <eddy.petrisor@gmail.com> # ArAge <ArAge@gmx.co.uk> NAME=motion PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/bin/motion PIDFILE=/var/run/$NAME.pid DEFAULTS=/etc/default/$NAME DESC="motion detection daemon" ENV="env -i LANG=C PATH=$PATH_BIN" . /lib/lsb/init-functions test -x $DAEMON || exit 0 RET=0 [ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes check_daemon_enabled () { if [ "$start_motion_daemon" = "yes" ] ; then return 0 else log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" return 1 fi } case "$1" in start) if check_daemon_enabled ; then if ! [ -d /var/run/motion ]; then mkdir /var/run/motion fi chown motion:motion /var/run/motion #=================insert this line to load the uv4l libraries==== export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so #================================================================= chmod 777 /var/run/motion sleep 30 log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then log_end_msg 0 else log_end_msg 1 RET=1 fi fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; reload|force-reload) log_daemon_msg "Reloading $NAME configuration" if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; restart-motion) if check_daemon_enabled ; then log_action_begin_msg "Restarting $NAME" if $0 stop && $0 start ; then log_action_end_msg 0 else log_action_cont_msg "(failed)" RET=1 fi fi ;; restart) $0 restart-motion ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" RET=1 ;; esac exit $RET и #!/bin/sh -e # # /etc/init.d/motion: Start the motion detection # ### BEGIN INIT INFO # Provides: motion # Required-Start: $local_fs $syslog $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Motion detection # Description: loads motion and assigns privileges ### END INIT INFO # Ported to new debian way using sh and /lib/lsb/init-functions # by Angel Carpintero <ack@telefonica.net> # Modified by : Juan Angulo Moreno <juan@apuntale.com> # eddy Petrisor <eddy.petrisor@gmail.com> # ArAge <ArAge@gmx.co.uk> NAME=motion PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/bin/motion PIDFILE=/var/run/$NAME.pid DEFAULTS=/etc/default/$NAME DESC="motion detection daemon" ENV="env -i LANG=C PATH=$PATH_BIN" . /lib/lsb/init-functions test -x $DAEMON || exit 0 RET=0 [ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes check_daemon_enabled () { if [ "$start_motion_daemon" = "yes" ] ; then return 0 else log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" return 1 fi } case "$1" in start) if check_daemon_enabled ; then if ! [ -d /var/run/motion ]; then mkdir /var/run/motion fi chown motion:motion /var/run/motion #=================insert this line to load the uv4l libraries==== export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so #================================================================= chmod 777 /var/run/motion sleep 30 log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then log_end_msg 0 else log_end_msg 1 RET=1 fi fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; reload|force-reload) log_daemon_msg "Reloading $NAME configuration" if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; restart-motion) if check_daemon_enabled ; then log_action_begin_msg "Restarting $NAME" if $0 stop && $0 start ; then log_action_end_msg 0 else log_action_cont_msg "(failed)" RET=1 fi fi ;; restart) $0 restart-motion ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" RET=1 ;; esac exit $RET по #!/bin/sh -e # # /etc/init.d/motion: Start the motion detection # ### BEGIN INIT INFO # Provides: motion # Required-Start: $local_fs $syslog $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Motion detection # Description: loads motion and assigns privileges ### END INIT INFO # Ported to new debian way using sh and /lib/lsb/init-functions # by Angel Carpintero <ack@telefonica.net> # Modified by : Juan Angulo Moreno <juan@apuntale.com> # eddy Petrisor <eddy.petrisor@gmail.com> # ArAge <ArAge@gmx.co.uk> NAME=motion PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/bin/motion PIDFILE=/var/run/$NAME.pid DEFAULTS=/etc/default/$NAME DESC="motion detection daemon" ENV="env -i LANG=C PATH=$PATH_BIN" . /lib/lsb/init-functions test -x $DAEMON || exit 0 RET=0 [ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes check_daemon_enabled () { if [ "$start_motion_daemon" = "yes" ] ; then return 0 else log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" return 1 fi } case "$1" in start) if check_daemon_enabled ; then if ! [ -d /var/run/motion ]; then mkdir /var/run/motion fi chown motion:motion /var/run/motion #=================insert this line to load the uv4l libraries==== export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so #================================================================= chmod 777 /var/run/motion sleep 30 log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then log_end_msg 0 else log_end_msg 1 RET=1 fi fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; reload|force-reload) log_daemon_msg "Reloading $NAME configuration" if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then log_end_msg 0 else log_end_msg 1 RET=1 fi ;; restart-motion) if check_daemon_enabled ; then log_action_begin_msg "Restarting $NAME" if $0 stop && $0 start ; then log_action_end_msg 0 else log_action_cont_msg "(failed)" RET=1 fi fi ;; restart) $0 restart-motion ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" RET=1 ;; esac exit $RET