howto get init script on gentoo?

Support and queries relating to all previous versions of ZoneMinder
Locked
salix
Posts: 12
Joined: Wed Aug 31, 2005 7:48 pm

howto get init script on gentoo?

Post by salix »

Hi there!

I just emerged the zm ebuild that comes with portage and fixed several things to get it running (permission stuff, missing event folder, etc.).

zmpkg.pl start works fine but as far as I have read the documentation there should be an init script as well to bring it up every time the system boots.

I found an init script posted somewhere in the forum but that didn't work for me.

It would be nice if anyone had a suggestion...
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

Mine looks like this. You may have to tweak the "use" line and the "ZM_PATH*" bits:

Code: Select all

#!/sbin/runscript
# Start and stop zoneminder (for Gentoo)

opts="start stop status"

depend() {
        use mysql apache2
}

prog=ZoneMinder
ZM_PATH_BIN="/usr/bin"
command="$ZM_PATH_BIN/zmpkg.pl"

start() {
        ebegin "Starting $prog"
        $command start
        eend $? "Failed to start $prog"
}
stop() {
        ebegin "Stopping $prog"
        $command stop
        eend $? "Failed to stop $prog"
}
status() {
        result=`$command status`
        if [ "$result" = "running" ]; then
                echo "ZoneMinder is running"
                RETVAL=0
        else
                echo "ZoneMinder is stopped"
                RETVAL=1
        fi
        exit ${RETVAL}
}
Rick Hewett
salix
Posts: 12
Joined: Wed Aug 31, 2005 7:48 pm

Post by salix »

thanks for the fast reply

unfortunately it doesn't work for me

I am using apache2 and mysql as well - both of them are running.
The path seems to be correct as well - I have /usr/bin/zmpkg.pl

if I try to start the script I get the following output

Code: Select all

 * Re-caching dependency info (mtimes differ)...
 * Starting ZoneMinder ...
 * Failed to start ZoneMinder                                             [ !! ]
and this is what can be found in /var/log/messages

Code: Select all

localhost zm # /etc/init.d/zm start

Nov 30 17:41:31 localhost su(pam_unix)[6258]: session opened for user apache by (uid=0)
Nov 30 17:41:31 localhost su(pam_unix)[6258]: session closed for user apache
Nov 30 17:41:31 localhost rc-scripts: Failed to start ZoneMinder
is there possibly a permission-problem again?
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

Could be all sorts of things; missing directories, permissions, shared memory, ...

Look for messages in /var/log/messages, /var/log/syslog (etc.) and also in the zoneminder error-log files.

As zoneminder is running as user apache you have to make sure that apache has a valid shell set in /etc/passwd .
Rick Hewett
salix
Posts: 12
Joined: Wed Aug 31, 2005 7:48 pm

Post by salix »

good god - I think that this was the hardest piece of work that I have done so far - my init script still isn't working (or perhaps wiping out the other errors killed this errors as well) - but I don't really need it anymway ;)

I wonder if there is anyone who managed to get zoneminder running using the ebuild right at the first try...

It took me about two weekends to find out which folders were not created where permissions went wrong and where links had to be added...

I guess next ime I will give your custom ebuild a try...

but in fact I really hope that this system will stay alive for all eternity.. so that I do not have to rebuild it...

perhaps I will post my experiences on the gentoo bug list...

thanks for your efforts anyway!

and in general thanks for this great App!
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

The main-line ebuild uses the webapp infrastructure which is intended to make running multiple instances of a webapp easier. It's not really appropriate for zoneminder, unfortunately, as it misses the fact that zoneminder is both a server and a webapp...
Rick Hewett
tfleming
Posts: 9
Joined: Mon Jul 21, 2003 5:23 am

Post by tfleming »

I had a hard time getting an init script to start Zoneminder under Gentoo. I could start it from the web interface but not from the command line or during init.

I changed a few things and now have it working. First I gave the 'apache' user shell access. Second I changed the 'execute' function in zmpkg.pl (about line 150) to the following:

Code: Select all

$command = "su ".ZM_WEB_USER." -c '$command'";
I also made sure the log directory (/var/log/zm) was owned by user 'apache'. Now the init script (similar to what lazyleopard published) works.
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

It's posible (most likily) that your entire problem was the permisions for the log files. If zmdc can't open a log, it will not start (or at least it used to be this way).

Regards,
Corey
Flash_
Posts: 441
Joined: Wed Jan 11, 2006 12:19 pm

Post by Flash_ »

Registered to say thanks to Cordel for that snippet - been bugging me for ages - couldn't figure out why my cams were being detected when starting/restarting from the webpage but when using zmpkg.pl to switch profiles was stalling every time.

Fixed now, thank you!
Locked