ZM 1.22.3 will not start from the Console screen

Support and queries relating to all previous versions of ZoneMinder
Locked
andrewh
Posts: 5
Joined: Mon Jan 15, 2007 7:28 pm

ZM 1.22.3 will not start from the Console screen

Post by andrewh »

Hi,

I am a new zoneminder user and am wondering if someone here could help me get zm 1.22.3 up and running. I have installed zm from sources under Ubuntu Edgy without any apparent problems. I can access the zm admin screen and have setup monitors for 4 IP cams and one usb cam (all cameras are working ok outside of zm).

However when I attempt to start zm from the console screen there is a brief wait and then the console says running and then stopped. I see the following in /var/log/syslog;

Jan 16 09:23:17 kubuntu-desktop zmpkg[27379]: INF [Command: start]
Jan 16 09:23:17 kubuntu-desktop zmfix[27384]: ERR [fopen() for home/dianemo/zoneminder/tmp/zm_debug.log.27384, error = No such file $
Jan 16 09:23:17 kubuntu-desktop zmfix[27384]: INF [New Debug Level = 2, New Debug Log = home/dianemo/zoneminder/tmp/zm_debug.log.273$
Jan 16 09:23:17 kubuntu-desktop zmdc[27386]: INF [Server starting at 07/01/16 09:23:17]
Jan 16 09:23:19 kubuntu-desktop zmdc[27386]: FAT [Can't bind: Permission denied]
Jan 16 09:23:27 kubuntu-desktop zmdc[27385]: FAT [Can't connect: No such file or directory]
Jan 16 09:23:27 kubuntu-desktop zmpkg[27379]: ERR [Unable to run "/usr/local/bin/zmdc.pl startup", output is "Starting server"]

Can anyone help me figure out why I am getting these errors when I start zm?

Thanks in advance for your help.

Andrew
andrewh
Posts: 5
Joined: Mon Jan 15, 2007 7:28 pm

Post by andrewh »

I have now checked the apache2 access and error logs and they show no errors are being generated by zm.... zm activity there looks normal.

I guess this is some kind of permissions problem but nothing I have tried so far fixes it.

I'd appreciate any ideas on what maybe going wrong... as I feel zm is working perfectly in all other respects but being so close to a working installation is very frustrating!

Again thanks for any help on this in advance.

Andrew
emo82
Posts: 21
Joined: Wed Oct 18, 2006 6:21 pm
Contact:

firewall

Post by emo82 »

turn off firewall.
check your zm.conf!
version= 1.22.3
ZM_PACH_BIN="/usr/local/bin"
andrewh
Posts: 5
Joined: Mon Jan 15, 2007 7:28 pm

Re: firewall

Post by andrewh »

emo82 wrote:turn off firewall.
check your zm.conf!
version= 1.22.3
ZM_PACH_BIN="/usr/local/bin"
My firewall is off and my zm.conf has;

# Current version of ZoneMinder
ZM_VERSION=1.22.3

# Path to build directory, used mostly for finding DB upgrade scripts
ZM_PATH_BUILD=/home/dianemo/zoneminder/ZoneMinder-1.22.3

# Build time, used to record when to trigger various checks
ZM_TIME_BUILD=1168865009

# Path to ZoneMinder binaries
ZM_PATH_BIN=/usr/local/bin

# Path to ZoneMinder libraries (none at present, for future use)
ZM_PATH_LIB=/usr/local/lib

# Path to ZoneMinder configuration (this file only at present)
ZM_PATH_CONF=/usr/local/etc

# Path to ZoneMinder web files
ZM_PATH_WEB=/var/www/zm

# Path to ZoneMinder cgi files
ZM_PATH_CGI=/usr/lib/cgi-bin

# Username and group that web daemon (httpd/apache) runs as
ZM_WEB_USER=www-data
ZM_WEB_GROUP=www-data

# ZoneMinder database hostname or ip address
ZM_DB_HOST=localhost

# ZoneMinder database name
ZM_DB_NAME=zm

# ZoneMinder database user
ZM_DB_USER=zmuser

# ZoneMinder database password
ZM_DB_PASS=zmpass

Which I think all looks right... at least it does to me. But I still cant set my zm console to its running state. Any further suggestions?

Thanks very much for your post.
emo82
Posts: 21
Joined: Wed Oct 18, 2006 6:21 pm
Contact:

Post by emo82 »

Do you have Selinux?
If so you have to desable it to.
emo82
Posts: 21
Joined: Wed Oct 18, 2006 6:21 pm
Contact:

Post by emo82 »

Configure ZoneMinder Auto-Start

Create a file /etc/init.d/zm containing the following:

#!/bin/sh
# description: Control ZoneMinder as a Service
# chkconfig: 2345 99 00
# Source function library.
#. /etc/rc.d/init.d/functions

prog=ZoneMinder
ZM_VERSION="1.22.3"
ZM_PATH_BIN="/usr/local/bin"
ZM_CONFIG="/usr/local/etc/zm.conf"
command="$ZM_PATH_BIN/zmpkg.pl"

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

# Check for old config and update if needed
checkcfg()
{
# Check config
if [ "$ZM_DB_HOST" = "" -o "$ZM_DB_NAME" = "" -o "$ZM_DB_USER" = "" -o "$ZM_DB_PASS" = "" ]; then
if [ "$ZM_DB_SERVER" != "" -a "$ZM_DB_NAME" != "" -a "$ZM_DB_USERA" != "" -a "$ZM_DB_PASSA" != "" ]; then
echo -n "Converting $ZM_CONFIG"
cp $ZM_CONFIG $ZM_CONFIG.old && \
cat $ZM_CONFIG.old | \
grep -v ZM_DB_USERB | \
grep -v ZM_DB_PASSB | \
sed -e 's/ZM_DB_USERA/ZM_DB_USER/' | \
sed -e 's/ZM_DB_PASSA/ZM_DB_PASS/' >$ZM_CONFIG && \
rm -f $ZM_CONFIG.old
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
fi
if [ "$ZM_DB_SERVER" != "" -a "$ZM_DB_NAME" != "" -a "$ZM_DB_USER" != "" -a "$ZM_DB_PASS" != "" ]; then
echo -n "Converting $ZM_CONFIG to 1.22.0"
cp $ZM_CONFIG $ZM_CONFIG.old
rm -f $ZM_CONFIG
cat $ZM_CONFIG.old | \
sed -e 's/ZM_DB_SERVER/ZM_DB_HOST/' >/tmp/$$
. /tmp/$$
cp $ZM_CONFIG.rpmnew $ZM_CONFIG && chmod 644 $ZM_CONFIG
for n in ZM_DB_HOST ZM_DB_NAME ZM_DB_USER ZM_DB_PASS; do
eval "val=\$$n"
if [ "$val" != "" ]; then
cp $ZM_CONFIG /tmp/$$.rpmnew &&
sed 's/^'$n='.*$/'$n=$val'/g' /tmp/$$.rpmnew >$ZM_CONFIG
fi
done
rm /tmp/$$
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
else
echo "In $ZM_CONFIG there should not be null values."
return 1
fi
loadconf
fi
}

checkdb()
{
# Check database exisits and version
GetVer="select Value from Config where Name='ZM_DYN_DB_VERSION'"
OLD_VERSION=`echo $GetVer | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
if [ "$OLD_VERSION" = "" ]; then
GetVer="select Value from Config where Name='ZM_DYN_CURR_VERSION'"
OLD_VERSION=`echo $GetVer | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
if [ "$OLD_VERSION" = "" ]; then
echo -n "You must run zmupdate.pl manualy"
return 1
fi
fi
RETVAL=$?

if [ $RETVAL != 0 ]; then
tbls=`mysql -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS -s -e 'show tables' $ZM_DB_NAME`
RETVAL=$?
if [ $RETVAL = 0 ]; then
echo -n "Initialize $prog database: "
echo tbls | grep Config >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL != 0 ]; then
mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME < $ZM_PATH_UPDATE/zm_create.sql
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
return $RETVAL
fi
( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
return $RETVAL
else
echo "No access to ZoneMinder database. Run $ZM_PATH_BIN/zminit manually."
return $RETVAL
fi
else
[ "$ZM_VERSION" = "$OLD_VERSION" ] && return 0
echo -n "Upgrade $prog database: "
$ZM_PATH_BIN/zmupdate.pl --version=$OLD_VERSION --noi && ( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
return $RETVAL
fi
}

start()
{
loadconf || return $?
checkcfg || return $?
checkdb || return $?
#/usr/local/sbin/motd.sh > /etc/motd
echo -n "Starting $prog: "
[ ! -d /var/run/zm ] \
&& mkdir -m 774 /var/run/zm \
&& chown $ZM_WEB_USER:$ZM_WEB_GROUP /var/run/zm
GetPath="select Value from Config where Name='ZM_PATH_SOCKS'"
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'`
[ ! -d $ZM_PATH_SOCK ] \
&& mkdir -m 774 $ZM_PATH_SOCK \
&&chown $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK
$command start
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/zm
return $RETVAL
}

stop()
{
echo -n $"Stopping $prog: "
$command stop
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
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')
loadconf
checkcfg
result=`$ZM_PATH_BIN/zmdc.pl check`
if [ "$result" = "running" ]; then
$ZM_PATH_BIN/zmdc.pl shutdown > /dev/null
start
fi
;;
'status')
status
;;
*)
echo "Usage: $0 { start | stop | restart | condrestart | status }"
RETVAL=1
;;
esac
exit $RETVAL
--------------------------------------------------------------------------------------
Create the lock subsystem directory, make the ZoneMinder startup executable, make it run at all default levels, and then start it up:

sudo mkdir /var/lock/subsys/
sudo chmod +x /etc/init.d/zm
sudo update-rc.d zm defaults
sudo /etc/init.d/zm restart
andrewh
Posts: 5
Joined: Mon Jan 15, 2007 7:28 pm

Post by andrewh »

Hi again,

I am running Ubuntu Edgy 6.10

I followed the instructions you provided in your last post and the following error was displayed on the console;

dianemo@kubuntu-desktop:/etc/init.d$ sudo /etc/init.d/zm restart
$Stopping ZoneMinder: sh: Syntax error: Bad fd number
failure

Starting ZoneMinder: sh: Syntax error: Bad fd number
Can't open log file '/home/dianemo/zoneminder/tmp/zmdc.log': Permission denied at /usr/local/share/perl/5.8.8/ZoneMinder/Debug.pm line 279.
Can't connect: No such file or directory at /usr/local/share/perl/5.8.8/ZoneMinder/Debug.pm line 349
ZoneMinder::Debug::Fatal('Can\'t connect: No such file or directory') called at /usr/local/bin/zmdc.pl line 167
failure

I used your script as is without any changes.

Thanks very much for you help

Andrew



emo82 wrote:Configure ZoneMinder Auto-Start

Create a file /etc/init.d/zm containing the following:

#!/bin/sh
# description: Control ZoneMinder as a Service
# chkconfig: 2345 99 00
# Source function library.
#. /etc/rc.d/init.d/functions

prog=ZoneMinder
ZM_VERSION="1.22.3"
ZM_PATH_BIN="/usr/local/bin"
ZM_CONFIG="/usr/local/etc/zm.conf"
command="$ZM_PATH_BIN/zmpkg.pl"

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

# Check for old config and update if needed
checkcfg()
{
# Check config
if [ "$ZM_DB_HOST" = "" -o "$ZM_DB_NAME" = "" -o "$ZM_DB_USER" = "" -o "$ZM_DB_PASS" = "" ]; then
if [ "$ZM_DB_SERVER" != "" -a "$ZM_DB_NAME" != "" -a "$ZM_DB_USERA" != "" -a "$ZM_DB_PASSA" != "" ]; then
echo -n "Converting $ZM_CONFIG"
cp $ZM_CONFIG $ZM_CONFIG.old && \
cat $ZM_CONFIG.old | \
grep -v ZM_DB_USERB | \
grep -v ZM_DB_PASSB | \
sed -e 's/ZM_DB_USERA/ZM_DB_USER/' | \
sed -e 's/ZM_DB_PASSA/ZM_DB_PASS/' >$ZM_CONFIG && \
rm -f $ZM_CONFIG.old
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
fi
if [ "$ZM_DB_SERVER" != "" -a "$ZM_DB_NAME" != "" -a "$ZM_DB_USER" != "" -a "$ZM_DB_PASS" != "" ]; then
echo -n "Converting $ZM_CONFIG to 1.22.0"
cp $ZM_CONFIG $ZM_CONFIG.old
rm -f $ZM_CONFIG
cat $ZM_CONFIG.old | \
sed -e 's/ZM_DB_SERVER/ZM_DB_HOST/' >/tmp/$$
. /tmp/$$
cp $ZM_CONFIG.rpmnew $ZM_CONFIG && chmod 644 $ZM_CONFIG
for n in ZM_DB_HOST ZM_DB_NAME ZM_DB_USER ZM_DB_PASS; do
eval "val=\$$n"
if [ "$val" != "" ]; then
cp $ZM_CONFIG /tmp/$$.rpmnew &&
sed 's/^'$n='.*$/'$n=$val'/g' /tmp/$$.rpmnew >$ZM_CONFIG
fi
done
rm /tmp/$$
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
else
echo "In $ZM_CONFIG there should not be null values."
return 1
fi
loadconf
fi
}

checkdb()
{
# Check database exisits and version
GetVer="select Value from Config where Name='ZM_DYN_DB_VERSION'"
OLD_VERSION=`echo $GetVer | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
if [ "$OLD_VERSION" = "" ]; then
GetVer="select Value from Config where Name='ZM_DYN_CURR_VERSION'"
OLD_VERSION=`echo $GetVer | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
if [ "$OLD_VERSION" = "" ]; then
echo -n "You must run zmupdate.pl manualy"
return 1
fi
fi
RETVAL=$?

if [ $RETVAL != 0 ]; then
tbls=`mysql -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS -s -e 'show tables' $ZM_DB_NAME`
RETVAL=$?
if [ $RETVAL = 0 ]; then
echo -n "Initialize $prog database: "
echo tbls | grep Config >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL != 0 ]; then
mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME < $ZM_PATH_UPDATE/zm_create.sql
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
return $RETVAL
fi
( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
return $RETVAL
else
echo "No access to ZoneMinder database. Run $ZM_PATH_BIN/zminit manually."
return $RETVAL
fi
else
[ "$ZM_VERSION" = "$OLD_VERSION" ] && return 0
echo -n "Upgrade $prog database: "
$ZM_PATH_BIN/zmupdate.pl --version=$OLD_VERSION --noi && ( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
RETVAL=$?
[ $RETVAL = 0 ] && echo_success
[ $RETVAL != 0 ] && echo_failure
echo
return $RETVAL
fi
}

start()
{
loadconf || return $?
checkcfg || return $?
checkdb || return $?
#/usr/local/sbin/motd.sh > /etc/motd
echo -n "Starting $prog: "
[ ! -d /var/run/zm ] \
&& mkdir -m 774 /var/run/zm \
&& chown $ZM_WEB_USER:$ZM_WEB_GROUP /var/run/zm
GetPath="select Value from Config where Name='ZM_PATH_SOCKS'"
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'`
[ ! -d $ZM_PATH_SOCK ] \
&& mkdir -m 774 $ZM_PATH_SOCK \
&&chown $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK
$command start
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/zm
return $RETVAL
}

stop()
{
echo -n $"Stopping $prog: "
$command stop
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
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')
loadconf
checkcfg
result=`$ZM_PATH_BIN/zmdc.pl check`
if [ "$result" = "running" ]; then
$ZM_PATH_BIN/zmdc.pl shutdown > /dev/null
start
fi
;;
'status')
status
;;
*)
echo "Usage: $0 { start | stop | restart | condrestart | status }"
RETVAL=1
;;
esac
exit $RETVAL
--------------------------------------------------------------------------------------
Create the lock subsystem directory, make the ZoneMinder startup executable, make it run at all default levels, and then start it up:

sudo mkdir /var/lock/subsys/
sudo chmod +x /etc/init.d/zm
sudo update-rc.d zm defaults
sudo /etc/init.d/zm restart
emo82
Posts: 21
Joined: Wed Oct 18, 2006 6:21 pm
Contact:

Post by emo82 »

what about SElinux?
emo82
Posts: 21
Joined: Wed Oct 18, 2006 6:21 pm
Contact:

Post by emo82 »

andrewh
Posts: 5
Joined: Mon Jan 15, 2007 7:28 pm

Post by andrewh »

Wow.... that seems to have fixed the problem!

Thank you very much indeed.

Andrew
Locked