Page 1 of 1
boot/init Startup not working on suse 10
Posted: Thu Jun 15, 2006 9:18 am
by kevin_robson
Has anyone managed ZM to start automatically at boot in Suse 10? I've seen a few articles on here with various problems/solutions but I still cant get mine to start.
I've tried two ways:
Copy scripts/zm to /etc/init.d, removed functions line, and linked to rc3.d and rc5.d
Nothing much happens at boot. But if I run manually from root it starts fine.
I then wrote my own script that just runs zmpkg.pl (I think that is the script - not in front of my PC now) - that shows errors at boot complaining about not being able to open sock file. As I'm root at startup I dont see how - or is it something to do with mysql not being fully up? Or do I need extra env variables that aren't set at boot?
If anyone has this working I'd appreciate some help.
Thanks
Posted: Thu Jun 15, 2006 10:08 am
by rmo
Hi,
insert into /etc/init.d/.depend.start
zm now only will start if mysql is running.
insert into /etc/init.d/.depend.stop
Code: Select all
mysql: apache2 name_of_zm_startscript
to prevent error messages zm has to be stopped before mysql.
or change /etc/sysconfig/boot
Code: Select all
## Type: yesno
## Default: yes
#
# Run all scripts or rather start/stop all services
# which are independent from each other in parallel.
#
RUN_PARALLEL=no
Regards,
Rainer
Posted: Thu Jun 15, 2006 12:19 pm
by kevin_robson
Thanks. Will try it tonight.
Which of the two methods is best - copying the zm script or using my own based on zmpkg.pl?
I'd prefer to use the zm script - I assume this works?
Posted: Thu Jun 15, 2006 3:00 pm
by byte
I managed to get it working, here's what I posted in the hints & tips section...
I finally managed to get it to work on boot up to get it working just do...
cd /etc/init.d/rc5.d
ln -s ../zm S10zm
ln -s ../zm K10zm
Now mine safely boot's up and shut's down.
Hope this helps you Mark!
Posted: Sun Jun 18, 2006 4:34 pm
by kevin_robson
Have done all you both suggested but still the same problem. Below is an extract from the shutting down log. When booting I get the same message - what file do I see this boot log in?
Any ideas?
<notice>zm stop
Stopping ZoneMinder: DBI connect('database=zm;host=localhost','zm',...) failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) at /usr/lib/perl5/site_perl/5.8.7/ZoneMinder/Config.pm line 89
Can't call method "prepare_cached" on an undefined value at /usr/lib/perl5/site_perl/5.8.7/ZoneMinder/Config.pm line 91.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.7/ZoneMinder/Config.pm line 100.
Compilation failed in require at /usr/lib/perl5/site_perl/5.8.7/ZoneMinder.pm line 33.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.7/ZoneMinder.pm line 33.
Compilation failed in require at /usr/local/bin/zmpkg.pl line 45.
BEGIN failed--compilation aborted at /usr/local/bin/zmpkg.pl line 45.
/etc/init.d/rc5.d/K10zm: line 153: echo_failure: command not found
Posted: Thu Jun 22, 2006 10:28 am
by kevin_robson
Has nobody any ideas?
Booting zm in suse seems to be a regular problem.
Posted: Thu Jun 22, 2006 1:13 pm
by rmo
Hi,
you have to take care of mysql is running before zm starts and before zm stops.
Code: Select all
/etc/init.d # ls -la rc3.d/ | grep zm
lrwxrwxrwx 1 root root 5 Jun 21 07:32 K09zm -> ../zm
lrwxrwxrwx 1 root root 5 Jun 21 07:32 S13zm -> ../zm
suserv1:/etc/init.d # ls -la rc3.d/ | grep mysql
lrwxrwxrwx 1 root root 8 Jun 17 2005 K10mysql -> ../mysql
lrwxrwxrwx 1 root root 15 Jun 19 18:47 S01mysql-repchk -> ../mysql-repchk
lrwxrwxrwx 1 root root 8 Jun 17 2005 S12mysql -> ../mysql
In runlevel 3 here mysql is starting before zm and stopping after zm . Same in runlevel 5.
Code: Select all
cat .depend.start | grep zm
zm: mysql
Code: Select all
cat .depend.stop | grep zm
mysql: apache2 zm
My /etc/init.d/zm looks like
Code: Select all
#
# /etc/init.d/zm
#
# and its symbolic link
#
# /usr/sbin/rczm
#
### BEGIN INIT INFO
# Provides: zm
# Required-Start: mysql
# Required-Stop: mysql
# Default-Start: 2 3 5
# Default-Stop:
# Description: Start the Zoneminder daemon
### END INIT INFO
# 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 ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First 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 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
prog=ZoneMinder
ZM_VERSION="1.22.2"
ZM_PATH_BIN="/opt/zoneminder/bin"
ZM_CONFIG="/etc/zoneminder/zm.conf"
command="$ZM_PATH_BIN/zmpkg.pl"
[ -f $ZM_CONFIG ] && . $ZM_CONFIG
unset MYSQLD
if test -x /usr/sbin/mysqld-max
then
MYSQLD=/usr/sbin/mysqld-max
elif test -x /usr/sbin/mysqld
then
MYSQLD=/usr/sbin/mysqld
fi
test "$MYSQLD" || { echo "Nor /usr/sbin/mysqld nor /usr/sbin/mysqld-max exists"; rc_failed 5; rc_status -v; rc_exit; }
checkdb() {
GetVer="select Value from Config where Name='ZM_DYN_CURR_VERSION'"
VERSION=`echo $GetVer | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
RETVAL=$?
if [ $RETVAL != 0 ]; then
echo -e "\033[1;31mNo access to ZoneMinder database. Running $ZM_PATH_BIN/zminit.'\33[0m"
$ZM_PATH_BIN/zminit
echo -e "\033[1;31mTry to start zm again !!\33[0m"
return $RETVAL
fi
echo -e "\033[1;32mO.K. Database exists !\33[0m"
return $RETVAL
}
start() {
until test -S $socket && checkproc $MYSQLD
do
sleep 1
echo -e "\033[1;33mWaiting for MySQL !\33[0m "
done
sleep 5
echo -n "Starting $prog: "
$command start
rc_status -v
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/zm
return $RETVAL
}
stop() {
echo -n "Stopping $prog: "
$command stop
rc_status -v
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/zm
}
status() {
result=`$command status`
if [ "$result" = "running" ]; then
echo "ZoneMinder is running"
RETVAL=0
else
echo "ZoneMinder is stopped"
RETVAL=1
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'condrestart')
result=`$command status`
if [ "$result" = "running" ]; then
stop
start
fi
;;
'status')
status
;;
'checkdb')
checkdb
;;
*)
echo "Usage: $0 { start | stop | restart | condrestart | status | checkdb }"
RETVAL=1
;;
esac
ps awx | grep "/opt/zoneminder/bin/zma -m" | grep -v grep | awk '{print $1}' | xargs -i renice 19 -p {}
exit $RETVAL
Regards,
Rainer
Posted: Fri Jun 23, 2006 9:44 am
by zoneminder
Hi Rainier,
This looks useful, would you mind putting it onto the Wiki if it's not there already as we get lots of questions about SuSE start scripts.
Cheers
Posted: Sat Jun 24, 2006 6:07 pm
by kevin_robson
Strange.
I was just about to try this suggestion but I rebooted first, and it worked this time.
Not sure why it wasn't working previously.
Thanks all for your help
1.22.3
Posted: Wed Jan 10, 2007 11:58 am
by emo82
rmo - script for version 1.22.3
just have to change 2 lines
1. version="1.22.3"
2. ZM_PACH_BIN="/usr/local/bin"