Can't get zoneminder to autoboot

Forum for questions and support relating to the 1.24.x releases only.
Post Reply
doubleoseverin
Posts: 6
Joined: Fri Feb 27, 2009 10:46 am

Can't get zoneminder to autoboot

Post by doubleoseverin » Sat Feb 28, 2009 7:16 pm

I have Opensuse 11.0 and have followed the instructions at:

http://www.zoneminder.com/wiki/index.ph ... _boot_time

But when I do a 'service zm start', I get the following:

Starting ZoneMinder: /etc/init.d/zm: line 48: failure: command not found

Here is the code, just to assure you I have not fiddled with it; although that said there was no echo_success or echo_failure strings to replace! I presume this is because the documentation is for an older version of zoneminder. I have also indicated the line of code that seems to be causing the error:

Code: Select all

#!/bin/sh
# description: ZoneMinder is the top Linux video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security applications.Copyright: Philip Coombes, Corey DeLasaux 2003-2008
# chkconfig: 2345 99 00
# processname: zmpkg.pl

prog=ZoneMinder
ZM_CONFIG="/usr/local/etc/zm.conf"
pidfile="/var/run/zm"
LOCKFILE=/var/lock/subsys/zm

loadconf()
{
	if [ -f $ZM_CONFIG ]; then
		. $ZM_CONFIG
	else
		echo "ERROR: $ZM_CONFIG not found."
		return 1
	fi
}

loadconf
command="$ZM_PATH_BIN/zmpkg.pl"

start()
{
	zmupdate || return $?
	loadconf || return $?
	#Make sure the directory for our PID folder exists or create one.
	[ ! -d /var/run/zm ] \
		&& mkdir -m 774 $pidfile \
		&& chown $ZM_WEB_USER:$ZM_WEB_GROUP $pidfile
	#Make sure the folder for the socks file exists or create one
	GetPath="select Value from Config where Name='ZM_PATH_SOCKS'"
    dbHost=`echo $ZM_DB_HOST | cut -d: -f1`
    dbPort=`echo $ZM_DB_HOST | cut -d: -s -f2`
    if [ "$dbPort" = "" ]
    then
	    ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$ZM_DB_HOST -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
    else
	    ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$dbHost -P$dbPort -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
    fi 
	[ ! -d $ZM_PATH_SOCK ] \
		&& mkdir -m 774 $ZM_PATH_SOCK \
		&& chown $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK
	echo -n $"Starting $prog: "
	$command start
	RETVAL=$?
	[ $RETVAL = 0 ] && success || failure
	echo
	[ $RETVAL = 0 ] && touch $LOCKFILE
	return $RETVAL
}

stop()
{
	loadconf
	echo -n $"Stopping $prog: "
	$command stop
	RETVAL=$?


#######Fails here#######	[ $RETVAL = 0 ] && success || failure


	echo
	[ $RETVAL = 0 ] && rm -f $LOCKFILE
}

zmstatus()
{
	loadconf
	result=`$command status`
	if [ "$result" = "running" ]; then
		echo "ZoneMinder is running"
		$ZM_PATH_BIN/zmu -l
		RETVAL=0
	else
		echo "ZoneMinder is stopped"
		RETVAL=1
	fi
}

zmupdate()
{
	if [ -x $ZM_PATH_BIN/zm_update ]; then
		$ZM_PATH_BIN/zm_update noi
	fi
}


case "$1" in
	'start')
		start
		;;
	'stop')
		stop
		;;
	'restart')
		stop
		start
		;;
	'condrestart')
		loadconf
		result=`$ZM_PATH_BIN/zmdc.pl check`
		if [ "$result" = "running" ]; then
			$ZM_PATH_BIN/zmdc.pl shutdown > /dev/null
			rm -f $LOCKFILE
			start
		fi
		;;
	'status')
		status httpd
		status mysqld
		zmstatus
		;;
	*)
		echo "Usage: $0 { start | stop | restart | condrestart | status }"
		RETVAL=1
		;;
esac
exit $RETVAL
Thanks once again...

User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle
Contact:

Post by cordel » Sat Feb 28, 2009 7:29 pm

Edit /etc/rc.d/zm with your favorite text editor (kwrite ?)
remove the line related to include functions
replace all occurences of echo_success by echo success
replace all occurences of echo_failure by echo failure
save the changes (ie :x!)
so these lines need changed:

Code: Select all

[ $RETVAL = 0 ] && success || failure
to

Code: Select all

[ $RETVAL = 0 ] && echo success || echo failure

doubleoseverin
Posts: 6
Joined: Fri Feb 27, 2009 10:46 am

thanks for that

Post by doubleoseverin » Sat Feb 28, 2009 9:35 pm

It's now autobooting successfully after I did a 'chkconfig zm on'. Cheers for that Cordel

doubleoseverin
Posts: 6
Joined: Fri Feb 27, 2009 10:46 am

still can't get it to autoboot ;(

Post by doubleoseverin » Tue Jul 14, 2009 1:49 pm

Hi there once again. I thought my problems were over but they are not. On a previous installation of zm, it only start sometimes but on the install I'm trying to do now it won't start at all. even though chkcconfig reports mysql, apache2 and zm as being 'on' something is not working correctly. When I issue the command chkconfig zm off it comes up with the following:
insserv: warning: script 'S02zm' missing LSB tags and overrides
insserv: warning: script 'zm' missing LSB tags and overrides
and when I do chkconfig zm on again, it comes up with
insserv: warning: script 'zm' missing LSB tags and overrides
Once again I followed the instructions at:
http://www.zoneminder.com/wiki/index.ph ... _boot_time
...but have not solved the problem. Just an aside: is LSB Least Significant Bit?

I tried going through the whole copy and soft link process again but this time it came up saying:
insserv: warning: script 'S01zm' missing LSB tags and overrides
insserv: warning: script 'zm' missing LSB tags and overrides
Any help much appreciated...

User avatar
monex
Posts: 169
Joined: Mon Jan 22, 2007 1:10 pm

Post by monex » Wed Jul 15, 2009 6:13 pm

Hi,

I've used the LSB tags in my zm.init script included in the RPM. The tags are at the beginning of the file:
### BEGIN INIT INFO
# Provides: zm
# Required-Start: mysql apache2 $syslog $remote_fs
# Required-Stop: mysql apache2 $syslog $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: starts the zone minder daemon
### END INIT INFO
This lines are used to determine the dependencies and default start/stop for the init script, e.g. which services should be enabled to start zm. This is very important because zm should start after mysql otherwise it cannot connect to the database. chkconfig uses this values to determine the correct start order and creates the links in the desired /etc/init.d/rc* directories.

The full init script can be found here http://liquid-co.de/pub/zm/scripts/zm.init (paths fits for the RPM if you want to use it you have to change them accordingly to your installation).

Hope this helps
Image

User avatar
Sir Veillance
Posts: 11
Joined: Tue Nov 13, 2007 3:44 am
Location: Germany

Post by Sir Veillance » Sun Oct 04, 2009 4:36 pm

This is how I got it to work with openSuSE 11:

(/etc/init.d/zm) copied from different sources

Code: Select all

#!/bin/sh
# description: ZoneMinder is the top Linux video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security applications.Copyright: Philip Coombes, Corey DeLasaux 2003-2008
# chkconfig: 2345 99 00
# processname: zmpkg.pl

# siehe auch http://liquid-co.de/pub/zm/scripts/zm.init

### BEGIN INIT INFO
# Provides:        Zoneminder
# Should-Start:    apache2
# Required-Start:  mysql apache2 $syslog $remote_fs 
## Should-Stop:    
# Required-Stop:   mysql apache2 $syslog $remote_fs 
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Zoneminder
# Description:     steuert Ãœberwachungskamera
# continued on second line by '#<TAB>'
### END INIT INFO

# http://de.opensuse.org/Paketbau/SUSE-Paketkonventionen/Init-Skripte#7.3._Kommentarkonventionen
# Required-Start gibt an, welche Facilities zum Starten und Ausführen dieses Dienstes verfügbar sein müssen. Das Init-Skriptsystem sollte sicher stellen, dass die benötigten Facilities gestartet werden, bevor das anfragende Skript gestartet wird.
# Should-Start ist ein optionales Feld. Die Funktion ist ähnlich der von Required-Start, definiert aber keine harten Abhängigkeiten. Falls ein unter Should-Start nicht installiert oder zum Starten aktiviert ist, wird dies stillschweigend ignoriert.
# Required-Stop gibt an, welche Facilities während des Abschalten des Dienstes immer noch aktiviert sein müssen. Das Init-Skriptsystem sollte ein Stoppen der hier aufgeführten Dienste vermeiden, bis das anfragende Skript gestoppt ist.
#  Dieses Kopfdatum wird unter SUSE Linux/openSUSE zur zeit ignoriert, da dass SUSE-Boot-Skript-Konzept ein anderes Verknüpfungsschema nutzt (Weitere Informationen dazu finden Sie in der man page init.d(7)).
# Should-Stop ist ein optionales Feld. Die Funktion ist ähnlich der von Required-Stop, defniert aber keine harten Abhängigkeiten. Falls ein unter Should-Stop nicht installiert oder zum Starten aktiviert ist, wird dies stillschweigend ignoriert.
# Default-Start gibt an, in welchen runlevels der Dienst standardmäßig gestartet werden soll. Die runlevels wurden an SUSE Linux 7.1 geändert.
# Default-Stop gibt an, in welchen runlevels das Skript standardmäßig gestoppt werden soll.
#  Dieses Kopfdatum wird unter SUSE Linux/openSUSE zur zeit ignoriert, da dass SUSE-Boot-Skript-Konzept ein anderes Verknüpfungsschema nutzt (Weitere Informationen dazu finden Sie in der man page init.d(7)). 

# Check for existence of needed config file and read it
ZM_CONFIG=/usr/local/etc/zm.conf

loadconf() {
	if [ -f $ZM_CONFIG ]; then
		. $ZM_CONFIG
	else
		echo "ERROR: $ZM_CONFIG not found."
		return 1
	fi
}

# Read config	
loadconf || return $? 

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
ZM_BIN=$ZM_PATH_BIN/zmpkg.pl
ZM_SHARE_PATH=/usr/share/zm
LOCKFILE=/var/lock/subsys/zm 

test -x $ZM_BIN || { 
	echo "$ZM_BIN not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; 
	fi; 
}
 
# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s     display "skipped" and exit with status 3
#      rc_status -u     display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset         clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

# Reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0	  - success
# 1       - generic or unspecified error
# 2       - invalid or excess argument(s)
# 3       - unimplemented feature (e.g. "reload")
# 4       - user had insufficient privileges
# 5       - program is not installed
# 6       - program is not configured
# 7       - program is not running
# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
# 
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.

zmupdate()
{
	if [ -x $ZM_PATH_BIN/zm_update ]; then
		$ZM_PATH_BIN/zm_update noi
	fi
}


case "$1" in
	########################################
   start)
		locked=0
		if test -f $LOCKFILE ; then
			echo "run zm_database_init first to create/update zm database"
			rc_failed 1
			locked=1
		fi
		echo -n "Starting ZoneMinder Daemon "
		## Start daemon with startproc(8). If this fails
		## the return value is set appropriately by startproc.
		if (($locked != 1))
		then
			eval startproc -t 5 -f $ZM_BIN start &> /dev/null
		fi

		# Remember status and be verbose
		rc_status -v
	;;
	
	########################################
    stop)
			locked=0
			if test -f $LOCKFILE ; then
				echo "run zm_database_init first to create/update zm database"
				locked=1
			fi
			echo -n "Shutting down ZoneMinder Daemon "
			## Stop daemon with killproc(8) and if this fails
			## killproc sets the return value according to LSB.

			$ZM_BIN stop &>/dev/null
			ret=$?
			if (($locked == 1))
			then
				:
			else
				$0 status &>/dev/null
				retstatus=$?
				# check weather unused
				if (($retstatus == 3))
				then
				 :
				else
				 rc_failed 1
				fi
			fi

			# Remember status and be verbose
			rc_status -v
	;;
 
	########################################
	try-restart|condrestart)
		## Do a restart only if the service was active before.
		## Note: try-restart is now part of LSB (as of 1.9).
		## RH has a similar command named condrestart.
		if test "$1" = "condrestart"; then
			echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
		fi
		$0 status
		if test $? = 0; then
			$0 restart
		else
			rc_reset	# Not running is not a failure.
		fi
		# Remember status and be quiet
		rc_status
 ;;
 
	########################################
	restart)
		## Stop the service and regardless of whether it was
		## running or not, start it again.
		$0 stop
		$0 start

		# Remember status and be quiet
		rc_status
	;;
	
	########################################
	force-reload)
		## Signal the daemon to reload its config. Most daemons
		## do this on signal 1 (SIGHUP).
		## If it does not support it, restart.

		echo -n "Reload service ZoneMinder "
		## if it supports it:
		eval startproc -f $ZM_BIN logrotate>/dev/null
		#touch /var/run/FOO.pid
		rc_status -v

		## Otherwise:
		#$0 try-restart
		#rc_status
	;;
 
	########################################
    reload)
	 ## Like force-reload, but if daemon does not support
	 ## signaling, do nothing (!)

	 # If it supports signaling:
	 echo -n "Reload service ZoneMinder "
	 eval startproc -f $ZM_BIN logrot > /dev/null
	 #touch /var/run/FOO.pid
	 rc_status -v
	 
	 ## Otherwise if it does not support reload:
	 #rc_failed 3
	 #rc_status -v
	;;
 
	########################################
	status)
		echo -n "Checking for service ZoneMinder "
		## Check status with checkproc(8), if process is running
		## checkproc will return with exit status 0.

		# Return value is slightly different for the status command:
		# 0 - service up and running
		# 1 - service dead, but /var/run/  pid  file exists
		# 2 - service dead, but /var/lock/ lock file exists
		# 3 - service not running (unused)
		# 4 - service status unknown :-(
		# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)

		# NOTE: checkproc returns LSB compliant status values.
		#checkproc $ZM_BIN
		status=`$ZM_BIN status 2> /dev/null`
		ret=$?
		if (($ret == 0))
		then
			if [ $status == "stopped" ]
			then 
				rc_failed 3
			else
				:
			fi
		else
			rc_failed 4
		fi
		# NOTE: rc_status knows that we called this init script with
		# "status" option and adapts its messages accordingly.
		rc_status -v
		;;
	
	########################################
	probe)
		## Optional: Probe for the necessity of a reload, print out the
		## argument to this init script which is required for a reload.
		## Note: probe is not (yet) part of LSB (as of 1.9)

		test /etc/zm.conf -nt /var/run/zm.pid && echo reload
	;;
	
	########################################
	*)
		echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
		exit 1
	;;
esac
rc_exit
then enter

Code: Select all

cd /etc/init.d
insserv zm  # integrate into rcX.d according to LSB header dependencies
ln -s /etc/init.d/zm /sbin/rczm
Then you can use rczm start|stop|restart and so on.
Martin from Germany

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests