2014-08-10 21:47:11 +08:00
|
|
|
#!/usr/bin/pkexec /usr/bin/perl
|
|
|
|
#
|
|
|
|
# ==========================================================================
|
|
|
|
#
|
2015-04-16 12:37:49 +08:00
|
|
|
# ZoneMinder systemctl wrapper, $Date$, $Revision$
|
2014-08-10 21:47:11 +08:00
|
|
|
# Copyright (C) 2001-2008 Philip Coombes
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# ==========================================================================
|
2015-04-16 12:37:49 +08:00
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
zmsystemctl.pl - ZoneMinder systemctl wrapper
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
zmsystemctl.pl {start|stop|restart|version}
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
This is a wrapper script that allows zoneminder to start and stop itself
|
|
|
|
in a manner that keeps it in-sync with systemd. This script is intended
|
|
|
|
to be called internally by zoneminder and may not give the desired results
|
|
|
|
if run from the command line.
|
|
|
|
|
|
|
|
=cut
|
2014-08-10 21:47:11 +08:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
use bytes;
|
2015-04-16 12:37:49 +08:00
|
|
|
use autouse 'Pod::Usage'=>qw(pod2usage);
|
2014-08-20 06:19:44 +08:00
|
|
|
|
|
|
|
@EXTRA_PERL_LIB@
|
2014-08-10 21:47:11 +08:00
|
|
|
use ZoneMinder::Logger qw(:all);
|
|
|
|
|
|
|
|
my $command = $ARGV[0];
|
|
|
|
|
2015-04-16 12:37:49 +08:00
|
|
|
if ( (scalar(@ARGV) == 1)
|
|
|
|
&& ($command =~ /^(start|stop|restart|version)$/ )
|
|
|
|
){
|
|
|
|
$command = $1;
|
2014-08-10 21:47:11 +08:00
|
|
|
} else {
|
2015-04-16 12:37:49 +08:00
|
|
|
pod2usage(-exitstatus => -1);
|
2014-08-10 21:47:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
my $path = qx(which systemctl);
|
|
|
|
chomp($path);
|
|
|
|
|
|
|
|
my $status = $? >> 8;
|
|
|
|
if ( !$path || $status ) {
|
2015-04-16 12:37:49 +08:00
|
|
|
Fatal( "Unable to determine systemctl executable. Is systemd in use?" );
|
2014-08-10 21:47:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Info( "Redirecting command through systemctl\n" );
|
|
|
|
exec("$path $command zoneminder");
|
|
|
|
|