V
V
ViieeS2015-02-19 14:18:52
ubuntu
ViieeS, 2015-02-19 14:18:52

Why doesn't the service (motion) start automatically on Ubunut Server 14.04?

Greetings. Please help me with what seems to be the easiest thing to do.. I can't defeat the motion daemon under Ubunut Server 14.04.
There is a script in init.d, I executed the update-rc.d motion defaults / enable commands, but when loading 0 reaction, manually everything starts fine
. in 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 <[email protected]>
# Modified by : Juan Angulo Moreno <[email protected]>
#               Eddy Petrisor <[email protected]>
#               ArAge <[email protected]>

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 775 motion:motion /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

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
ViieeS, 2015-02-20
@ViieeS

dealt with init.d, the problem was in these 2 lines, an incorrect path to the daemon was specified/usr/bin/motion

PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/
DAEMON=/usr/local/bin/motion

E
Ergil Osin, 2015-02-19
@Ernillew

Make a file to start with upstart and put it in /etc/init/
Trying to use SysV-init in 2015 is a very strange idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question