Page 1 of 1

Centos 5.6 zm startup script errors.

Posted: Tue Jun 21, 2011 8:18 pm
by m1ke
OK here we go again... Decided to start a new thread for this:

Following the Centos Wiki & now having finally got ZM to build - when I come to add the zm startup script I get the following when I try to start it:

[root@zm1 init.d]# service zm start
env: /etc/init.d/zm: No such file or directory

This thread details the same issue - but no confirmed resolution:
http://www.zoneminder.com/forums/viewto ... ory#p69225

I done 'chkconfig --del zm' then 'chkconfig --add zm' to add it again. It lists as setup OK:

[root@zm1 init.d]# chkconfig --list zm
zm 0:off 1:off 2:on 3:on 4:on 5:on 6:off

When I try to run it manually:

[root@zm1 init.d]# ./zm
bash: ./zm: /bin/sh^M: bad interpreter: No such file or directory

Then force it through the interpreter:

[root@zm1 init.d]# bash ./zm
: command not found
: No such file or directoryt.d/functions
: command not found
: command not found
'/zm: line 14: syntax error near unexpected token `
'/zm: line 14: `loadconf()

There seems to be something wrong with the 'zm' script.

Here is the 1st bit of it: (I can't see anything obvious but then I'm not a programmer) Can anyone see what is wrong here - must be something simple I'm sure...

# processname: zmpkg.pl

# Source function library.
. /etc/rc.d/init.d/functions

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"


Thanks in advance,

Mike.

Re: Centos 5.6 zm startup script errors.

Posted: Tue Jun 21, 2011 9:04 pm
by m1ke
I'm thinking maybe this error is because there is no 'loadconf' function ??

If I 'vim /etc/init.d/functions' I can't see any reference to 'loadconf' - I dunno I'm just having a stab in the dark really.

Anyway I can get ZM to start on boot without a startup script by any chance - just a simple command I can bung in /etc/rc.local or something ?


Well I give up for now... I've spent near all day on this.


Cheers,
Mike.

Re: Centos 5.6 zm startup script errors.

Posted: Tue Jun 21, 2011 9:35 pm
by zoneminder
I have done this many times and it should 'just work'. I am a little suspicious of this line
bash: ./zm: /bin/sh^M: bad interpreter: No such file or directory
where it looks like there is a carriage return or something on the first line. Can you inspect the file and check that is isn't corrupted in some way? It's quite small and most of it should be fairly self-evident.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 9:45 am
by m1ke
zoneminder wrote:I have done this many times and it should 'just work'. I am a little suspicious of this line
bash: ./zm: /bin/sh^M: bad interpreter: No such file or directory
where it looks like there is a carriage return or something on the first line. Can you inspect the file and check that is isn't corrupted in some way? It's quite small and most of it should be fairly self-evident.
Hi Phil,
I have dd' out (in vim) the first line of the 'zm' script '#!/bin/sh' & replaced is with '#!/bin/bash'. There doesn't seem to be any special charactors after the #!/bin/bash line. As a test I did the same with the httpd startup file & that continued to work fine.
I still get the same error with zm file.

When I do on a known working script I get:
[root@zm1 init.d]# bash httpd
Usage: httpd {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}

with the zm script I get:
[root@zm1 init.d]# bash zm
: command not found
: No such file or directoryd/functions
: command not found
: command not found
'm: line 14: syntax error near unexpected token `
'm: line 14: `loadconf()

Thanks,

Mike.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 9:52 am
by m1ke
I have just found this artical on the Wiki: http://www.zoneminder.com/wiki/index.ph ... 6_-_Dapper

I pasted the script listed on this page into a new '/etc/init.d/zm' file & changed the 'ZM_VERSION="1.22.2" line to 'ZM_VERSION="1.24.4" '.

low and behold:

[root@zm1 init.d]# bash zm
Usage: zm { start | stop | restart | condrestart | status }

[root@zm1 init.d]# bash zm start
Starting ZoneMinder: success

[root@zm1 init.d]# bash zm stop
Stopping ZoneMinder: success

[root@zm1 init.d]# bash zm status
ZoneMinder is running

Horaaay....!

Perhaps this script could be included in the main package ?

Thanks again,

Mike.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 10:10 am
by zoneminder
Actually I was just looking at the script in the distro and for some reason it has acquired DOS style line endings. If yours has those then you can use dos2unix to convert it or ':set fileformat=unix' in vim/vim.

To be honest I am a little out of my depth with the scripts here, I think Corey did the last update so I will point him at this thread and see what he makes of it.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 10:33 am
by m1ke
zoneminder wrote:Actually I was just looking at the script in the distro and for some reason it has acquired DOS style line endings. If yours has those then you can use dos2unix to convert it or ':set fileformat=unix' in vim/vim.

To be honest I am a little out of my depth with the scripts here, I think Corey did the last update so I will point him at this thread and see what he makes of it.
Aaaghh, yes just did ':set fileformat=unix' in vim on the original 'zm' file & look - as if by magic:

[root@zm1 init.d]# bash zm
Usage: zm { start | stop | restart | condrestart | status }

[root@zm1 init.d]# service zm stop
Stopping ZoneMinder: [ OK ]
[root@zm1 init.d]# service zm start
Starting ZoneMinder: [ OK ]
[root@zm1 init.d]#
[root@zm1 init.d]#
[root@zm1 init.d]# service zm status
httpd (pid 2565) is running...
mysqld (pid 2484) is running...
ZoneMinder is running
Id Func State TrgState LastImgTim RdIdx WrIdx LastEvt FrmRate

Well thats got to the bottom of it then!!

So how do you tell in vim if a file has DOS style line endings ?
Funnily enough I remember seeing a post on a completely different site saying the same sort of thing when I googled '/bin/sh^M: bad interpreter: No such file or directory'. There was something about dos2unix.

I'm just editing the Centos Wiki artical now to I'll make sure I add this in there too!

Cheers,
Mike.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 10:42 am
by zoneminder
When you first edit a file in vim, it normally says [dos] or something at the bottom I think next to the filename. Also if you do ctrl-G at any time I think it might point it out as well.

Anytime you see an error with ^M around it, it normally comes down to this sort of thing but I don't know how it got in there in the first place.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 12:34 pm
by m1ke
zoneminder wrote:When you first edit a file in vim, it normally says [dos] or something at the bottom I think next to the filename. Also if you do ctrl-G at any time I think it might point it out as well.

Anytime you see an error with ^M around it, it normally comes down to this sort of thing but I don't know how it got in there in the first place.
Ok I have updated the Centos Wiki to reflect the above & also the issues detailed on my other post.

Cheers,
Mike.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 12:49 pm
by zoneminder
Thanks.

Be aware that though you have corrected your zm file, this is actually generated from the zm.in file in the scripts directory during configuration and build. So if you are likely to rebuild at any point you might want to edit that one as well, though the file doesn't actually get installed anyway so won't necessarily be required.

Re: Centos 5.6 zm startup script errors.

Posted: Wed Jun 22, 2011 2:44 pm
by m1ke
zoneminder wrote:Thanks.

Be aware that though you have corrected your zm file, this is actually generated from the zm.in file in the scripts directory during configuration and build. So if you are likely to rebuild at any point you might want to edit that one as well, though the file doesn't actually get installed anyway so won't necessarily be required.
OK well noted, Thanks Phil.
No to get my 8 port BT878a card working... I've got the instructions from Camsecure :)

Mike.

Re: Centos 5.6 zm startup script errors.

Posted: Thu Jun 23, 2011 4:54 am
by cordel
Hi Mike,
I see you and Phil managed to get to the bottom of the issue which is great.
Phil, sorry I thought this was in regards to the Fedora issue which I'll be sending you the revised start script fairly shortly.