Merge branch 'master' into storageareas
This commit is contained in:
commit
1958351a13
|
@ -42,7 +42,7 @@ This is the recommended method to install ZoneMinder onto your system. ZoneMinde
|
||||||
|
|
||||||
If a repository that hosts ZoneMinder packages is not available for your distro, then you are encouraged to build your own package, rather than build from source. While each distro is different in ways that set it apart from all the others, they are often similar enough to allow you to adapt another distro's package building instructions to your own.
|
If a repository that hosts ZoneMinder packages is not available for your distro, then you are encouraged to build your own package, rather than build from source. While each distro is different in ways that set it apart from all the others, they are often similar enough to allow you to adapt another distro's package building instructions to your own.
|
||||||
|
|
||||||
### Building a ZoneMinder Package
|
### Building a ZoneMinder Package ###
|
||||||
|
|
||||||
Building ZoneMinder into a package is not any harder than building from source. As a matter of fact, if you have successfully built ZoneMinder from source in the past, then you may find these steps to be easier.
|
Building ZoneMinder into a package is not any harder than building from source. As a matter of fact, if you have successfully built ZoneMinder from source in the past, then you may find these steps to be easier.
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,13 @@ The API is built in CakePHP and lives under the ``/api`` directory. It
|
||||||
provides a RESTful service and supports CRUD (create, retrieve, update, delete)
|
provides a RESTful service and supports CRUD (create, retrieve, update, delete)
|
||||||
functions for Monitors, Events, Frames, Zones and Config.
|
functions for Monitors, Events, Frames, Zones and Config.
|
||||||
|
|
||||||
|
Enabling API
|
||||||
|
^^^^^^^^^^^^
|
||||||
|
A default ZoneMinder installs with APIs enabled. You can explictly enable/disable the APIs
|
||||||
|
via the Options->System menu by enabling/disabling ``OPT_USE_API``. Note that if you intend
|
||||||
|
to use APIs with 3rd party apps, such as zmNinja or others that use APIs, you should also
|
||||||
|
enable ``AUTH_HASH_LOGINS``.
|
||||||
|
|
||||||
Login, Logout & API Security
|
Login, Logout & API Security
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
The APIs tie into ZoneMinder's existing security model. This means if you have
|
The APIs tie into ZoneMinder's existing security model. This means if you have
|
||||||
|
|
|
@ -704,6 +704,8 @@ sub Fatal( @ ) {
|
||||||
if ( $SIG{TERM} and ( $SIG{TERM} ne 'DEFAULT' ) ) {
|
if ( $SIG{TERM} and ( $SIG{TERM} ne 'DEFAULT' ) ) {
|
||||||
$SIG{TERM}();
|
$SIG{TERM}();
|
||||||
}
|
}
|
||||||
|
# I think if we don't disconnect we will leave sockets around in TIME_WAIT
|
||||||
|
zmDbDisconnect();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -292,48 +292,48 @@ sub checkFilter {
|
||||||
last if $zm_terminate;
|
last if $zm_terminate;
|
||||||
my $Event = new ZoneMinder::Event($$event{Id}, $event);
|
my $Event = new ZoneMinder::Event($$event{Id}, $event);
|
||||||
|
|
||||||
Debug("Checking event $event->{Id}");
|
Debug("Checking event $Event->{Id}");
|
||||||
my $delete_ok = !undef;
|
my $delete_ok = !undef;
|
||||||
$dbh->ping();
|
$dbh->ping();
|
||||||
if ( $filter->{AutoArchive} ) {
|
if ( $filter->{AutoArchive} ) {
|
||||||
Info("Archiving event $event->{Id}");
|
Info("Archiving event $Event->{Id}");
|
||||||
# Do it individually to avoid locking up the table for new events
|
# Do it individually to avoid locking up the table for new events
|
||||||
my $sql = 'UPDATE Events SET Archived = 1 WHERE Id = ?';
|
my $sql = 'UPDATE Events SET Archived = 1 WHERE Id = ?';
|
||||||
my $sth = $dbh->prepare_cached( $sql )
|
my $sth = $dbh->prepare_cached( $sql )
|
||||||
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
||||||
my $res = $sth->execute( $event->{Id} )
|
my $res = $sth->execute( $Event->{Id} )
|
||||||
or Error("Unable to execute '$sql': ".$dbh->errstr());
|
or Error("Unable to execute '$sql': ".$dbh->errstr());
|
||||||
}
|
}
|
||||||
if ( $Config{ZM_OPT_FFMPEG} && $filter->{AutoVideo} ) {
|
if ( $Config{ZM_OPT_FFMPEG} && $filter->{AutoVideo} ) {
|
||||||
if ( !$event->{Videoed} ) {
|
if ( !$Event->{Videoed} ) {
|
||||||
$delete_ok = undef if !generateVideo($filter, $event);
|
$delete_ok = undef if !generateVideo($filter, $Event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $Config{ZM_OPT_EMAIL} && $filter->{AutoEmail} ) {
|
if ( $Config{ZM_OPT_EMAIL} && $filter->{AutoEmail} ) {
|
||||||
if ( !$event->{Emailed} ) {
|
if ( !$Event->{Emailed} ) {
|
||||||
$delete_ok = undef if !sendEmail($filter, $Event);
|
$delete_ok = undef if !sendEmail($filter, $Event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $Config{ZM_OPT_MESSAGE} && $filter->{AutoMessage} ) {
|
if ( $Config{ZM_OPT_MESSAGE} && $filter->{AutoMessage} ) {
|
||||||
if ( !$event->{Messaged} ) {
|
if ( !$Event->{Messaged} ) {
|
||||||
$delete_ok = undef if !sendMessage($filter, $Event);
|
$delete_ok = undef if !sendMessage($filter, $Event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $Config{ZM_OPT_UPLOAD} && $filter->{AutoUpload} ) {
|
if ( $Config{ZM_OPT_UPLOAD} && $filter->{AutoUpload} ) {
|
||||||
if ( !$event->{Uploaded} ) {
|
if ( !$Event->{Uploaded} ) {
|
||||||
$delete_ok = undef if !uploadArchFile($filter, $Event);
|
$delete_ok = undef if !uploadArchFile($filter, $Event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $filter->{AutoExecute} ) {
|
if ( $filter->{AutoExecute} ) {
|
||||||
if ( !$event->{Executed} ) {
|
if ( !$Event->{Executed} ) {
|
||||||
$delete_ok = undef if !executeCommand($filter, $event);
|
$delete_ok = undef if !executeCommand($filter, $Event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $filter->{AutoDelete} ) {
|
if ( $filter->{AutoDelete} ) {
|
||||||
if ( $delete_ok ) {
|
if ( $delete_ok ) {
|
||||||
$Event->delete();
|
$Event->delete();
|
||||||
} else {
|
} else {
|
||||||
Error("Unable toto delete event $event->{Id} as previous operations failed");
|
Error("Unable to delete event $Event->{Id} as previous operations failed");
|
||||||
}
|
}
|
||||||
} # end if AutoDelete
|
} # end if AutoDelete
|
||||||
|
|
||||||
|
@ -364,11 +364,11 @@ sub checkFilter {
|
||||||
|
|
||||||
sub generateVideo {
|
sub generateVideo {
|
||||||
my $filter = shift;
|
my $filter = shift;
|
||||||
my $event = shift;
|
my $Event = shift;
|
||||||
my $phone = shift;
|
my $phone = shift;
|
||||||
|
|
||||||
my $rate = $event->{DefaultRate}/100;
|
my $rate = $Event->{DefaultRate}/100;
|
||||||
my $scale = $event->{DefaultScale}/100;
|
my $scale = $Event->{DefaultScale}/100;
|
||||||
my $format;
|
my $format;
|
||||||
|
|
||||||
my @ffmpeg_formats = split(/\s+/, $Config{ZM_FFMPEG_FORMATS});
|
my @ffmpeg_formats = split(/\s+/, $Config{ZM_FFMPEG_FORMATS});
|
||||||
|
@ -393,7 +393,7 @@ sub generateVideo {
|
||||||
my $command = join('',
|
my $command = join('',
|
||||||
$Config{ZM_PATH_BIN},
|
$Config{ZM_PATH_BIN},
|
||||||
'/zmvideo.pl -e ',
|
'/zmvideo.pl -e ',
|
||||||
$event->{Id},
|
$Event->{Id},
|
||||||
' -r ',
|
' -r ',
|
||||||
$rate,
|
$rate,
|
||||||
' -s ',
|
' -s ',
|
||||||
|
@ -417,8 +417,8 @@ sub generateVideo {
|
||||||
my $sql = 'UPDATE Events SET Videoed = 1 WHERE Id = ?';
|
my $sql = 'UPDATE Events SET Videoed = 1 WHERE Id = ?';
|
||||||
my $sth = $dbh->prepare_cached($sql)
|
my $sth = $dbh->prepare_cached($sql)
|
||||||
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
||||||
my $res = $sth->execute($event->{Id})
|
my $res = $sth->execute($Event->{Id})
|
||||||
or Fatal("Unable toexecute '$sql': ".$dbh->errstr());
|
or Fatal("Unable to execute '$sql': ".$dbh->errstr());
|
||||||
if ( wantarray() ) {
|
if ( wantarray() ) {
|
||||||
return( $format, $output );
|
return( $format, $output );
|
||||||
}
|
}
|
||||||
|
@ -467,15 +467,15 @@ sub generateImage {
|
||||||
|
|
||||||
sub uploadArchFile {
|
sub uploadArchFile {
|
||||||
my $filter = shift;
|
my $filter = shift;
|
||||||
my $event = shift;
|
my $Event = shift;
|
||||||
|
|
||||||
if ( ! $Config{ZM_UPLOAD_HOST} ) {
|
if ( ! $Config{ZM_UPLOAD_HOST} ) {
|
||||||
Error('Cannot upload archive as no upload host defined');
|
Error('Cannot upload archive as no upload host defined');
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $archFile = $event->{MonitorName}.'-'.$event->{Id};
|
my $archFile = $Event->{MonitorName}.'-'.$Event->{Id};
|
||||||
my $archImagePath = $event->Path()
|
my $archImagePath = $Event->Path()
|
||||||
.'/'
|
.'/'
|
||||||
.(
|
.(
|
||||||
( $Config{ZM_UPLOAD_ARCH_ANALYSE} )
|
( $Config{ZM_UPLOAD_ARCH_ANALYSE} )
|
||||||
|
@ -540,7 +540,7 @@ sub uploadArchFile {
|
||||||
return( 0 );
|
return( 0 );
|
||||||
} else {
|
} else {
|
||||||
if ( $Config{ZM_UPLOAD_PROTOCOL} eq 'ftp' ) {
|
if ( $Config{ZM_UPLOAD_PROTOCOL} eq 'ftp' ) {
|
||||||
Info('Uploading to '.$Config{ZM_UPLOAD_HOST}." using FTP");
|
Info('Uploading to '.$Config{ZM_UPLOAD_HOST}.' using FTP');
|
||||||
my $ftp = Net::FTP->new(
|
my $ftp = Net::FTP->new(
|
||||||
$Config{ZM_UPLOAD_HOST},
|
$Config{ZM_UPLOAD_HOST},
|
||||||
Timeout=>$Config{ZM_UPLOAD_TIMEOUT},
|
Timeout=>$Config{ZM_UPLOAD_TIMEOUT},
|
||||||
|
@ -548,24 +548,24 @@ sub uploadArchFile {
|
||||||
Debug=>$Config{ZM_UPLOAD_DEBUG}
|
Debug=>$Config{ZM_UPLOAD_DEBUG}
|
||||||
);
|
);
|
||||||
if ( !$ftp ) {
|
if ( !$ftp ) {
|
||||||
Error("Unable tocreate FTP connection: $@");
|
Error("Unable to create FTP connection: $@");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$ftp->login($Config{ZM_UPLOAD_USER}, $Config{ZM_UPLOAD_PASS})
|
$ftp->login($Config{ZM_UPLOAD_USER}, $Config{ZM_UPLOAD_PASS})
|
||||||
or Error("FTP - Unable tologin");
|
or Error("FTP - Unable to login");
|
||||||
$ftp->binary()
|
$ftp->binary()
|
||||||
or Error("FTP - Unable togo binary");
|
or Error("FTP - Unable to go binary");
|
||||||
$ftp->cwd($Config{ZM_UPLOAD_REM_DIR})
|
$ftp->cwd($Config{ZM_UPLOAD_REM_DIR})
|
||||||
or Error("FTP - Unable tocwd")
|
or Error("FTP - Unable to cwd")
|
||||||
if ( $Config{ZM_UPLOAD_REM_DIR} );
|
if ( $Config{ZM_UPLOAD_REM_DIR} );
|
||||||
$ftp->put( $archLocPath )
|
$ftp->put( $archLocPath )
|
||||||
or Error("FTP - Unable toupload '$archLocPath'");
|
or Error("FTP - Unable to upload '$archLocPath'");
|
||||||
$ftp->quit()
|
$ftp->quit()
|
||||||
or Error("FTP - Unable toquit");
|
or Error("FTP - Unable to quit");
|
||||||
} else {
|
} else {
|
||||||
my $host = $Config{ZM_UPLOAD_HOST};
|
my $host = $Config{ZM_UPLOAD_HOST};
|
||||||
$host .= ':'.$Config{ZM_UPLOAD_PORT} if $Config{ZM_UPLOAD_PORT};
|
$host .= ':'.$Config{ZM_UPLOAD_PORT} if $Config{ZM_UPLOAD_PORT};
|
||||||
Info('Uploading to '.$host." using SFTP\n");
|
Info('Uploading to '.$host.' using SFTP');
|
||||||
my %sftpOptions = (
|
my %sftpOptions = (
|
||||||
host=>$Config{ZM_UPLOAD_HOST}, user=>$Config{ZM_UPLOAD_USER}
|
host=>$Config{ZM_UPLOAD_HOST}, user=>$Config{ZM_UPLOAD_USER}
|
||||||
($Config{ZM_UPLOAD_PASS} ? (password=>$Config{ZM_UPLOAD_PASS}) : ()),
|
($Config{ZM_UPLOAD_PASS} ? (password=>$Config{ZM_UPLOAD_PASS}) : ()),
|
||||||
|
@ -580,7 +580,7 @@ sub uploadArchFile {
|
||||||
$sftpOptions{more} = [@more_ssh_args];
|
$sftpOptions{more} = [@more_ssh_args];
|
||||||
my $sftp = Net::SFTP::Foreign->new($Config{ZM_UPLOAD_HOST}, %sftpOptions);
|
my $sftp = Net::SFTP::Foreign->new($Config{ZM_UPLOAD_HOST}, %sftpOptions);
|
||||||
if ( $sftp->error ) {
|
if ( $sftp->error ) {
|
||||||
Error("Unable tocreate SFTP connection: ".$sftp->error);
|
Error("Unable to create SFTP connection: ".$sftp->error);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$sftp->setcwd($Config{ZM_UPLOAD_REM_DIR})
|
$sftp->setcwd($Config{ZM_UPLOAD_REM_DIR})
|
||||||
|
@ -592,9 +592,9 @@ sub uploadArchFile {
|
||||||
unlink($archLocPath);
|
unlink($archLocPath);
|
||||||
my $sql = 'UPDATE Events SET Uploaded = 1 WHERE Id = ?';
|
my $sql = 'UPDATE Events SET Uploaded = 1 WHERE Id = ?';
|
||||||
my $sth = $dbh->prepare_cached($sql)
|
my $sth = $dbh->prepare_cached($sql)
|
||||||
or Fatal("Unable toprepare '$sql': ".$dbh->errstr());
|
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
||||||
my $res = $sth->execute($event->{Id})
|
my $res = $sth->execute($Event->{Id})
|
||||||
or Fatal("Unable toexecute '$sql': ".$dbh->errstr());
|
or Fatal("Unable to execute '$sql': ".$dbh->errstr());
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} # end sub uploadArchFile
|
} # end sub uploadArchFile
|
||||||
|
@ -622,9 +622,9 @@ sub substituteTags {
|
||||||
WHERE EventId = ? AND Type = 'Alarm'
|
WHERE EventId = ? AND Type = 'Alarm'
|
||||||
ORDER BY FrameId`;
|
ORDER BY FrameId`;
|
||||||
my $sth = $dbh->prepare_cached($sql)
|
my $sth = $dbh->prepare_cached($sql)
|
||||||
or Fatal("Unable toprepare '$sql': ".$dbh->errstr());
|
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
||||||
my $res = $sth->execute($Event->{Id})
|
my $res = $sth->execute($Event->{Id})
|
||||||
or Fatal( "Unable toexecute '$sql': ".$dbh->errstr());
|
or Fatal("Unable to execute '$sql': ".$dbh->errstr());
|
||||||
my $rows = 0;
|
my $rows = 0;
|
||||||
while( my $frame = $sth->fetchrow_hashref() ) {
|
while( my $frame = $sth->fetchrow_hashref() ) {
|
||||||
if ( !$first_alarm_frame ) {
|
if ( !$first_alarm_frame ) {
|
||||||
|
@ -796,7 +796,7 @@ sub sendEmail {
|
||||||
$ssmtp_location = qx('which ssmtp');
|
$ssmtp_location = qx('which ssmtp');
|
||||||
}
|
}
|
||||||
if ( !$ssmtp_location ) {
|
if ( !$ssmtp_location ) {
|
||||||
Debug('Unable tofind ssmtp, trying MIME::Lite->send');
|
Debug('Unable to find ssmtp, trying MIME::Lite->send');
|
||||||
MIME::Lite->send('smtp', $Config{ZM_EMAIL_HOST}, Timeout=>60);
|
MIME::Lite->send('smtp', $Config{ZM_EMAIL_HOST}, Timeout=>60);
|
||||||
$mail->send();
|
$mail->send();
|
||||||
} else {
|
} else {
|
||||||
|
@ -828,16 +828,16 @@ sub sendEmail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if ( $@ ) {
|
if ( $@ ) {
|
||||||
Error("Unable tosend email: $@");
|
Error("Unable to send email: $@");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
Info('Notification email sent');
|
Info('Notification email sent');
|
||||||
}
|
}
|
||||||
my $sql = 'UPDATE Events SET Emailed = 1 WHERE Id = ?';
|
my $sql = 'UPDATE Events SET Emailed = 1 WHERE Id = ?';
|
||||||
my $sth = $dbh->prepare_cached($sql)
|
my $sth = $dbh->prepare_cached($sql)
|
||||||
or Fatal("Unable toprepare '$sql': ".$dbh->errstr());
|
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
||||||
my $res = $sth->execute($Event->{Id})
|
my $res = $sth->execute($Event->{Id})
|
||||||
or Fatal("Unable toexecute '$sql': ".$dbh->errstr());
|
or Fatal("Unable to execute '$sql': ".$dbh->errstr());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -898,7 +898,7 @@ sub sendMessage {
|
||||||
$ssmtp_location = qx('which ssmtp');
|
$ssmtp_location = qx('which ssmtp');
|
||||||
}
|
}
|
||||||
if ( !$ssmtp_location ) {
|
if ( !$ssmtp_location ) {
|
||||||
Debug('Unable tofind ssmtp, trying MIME::Lite->send');
|
Debug('Unable to find ssmtp, trying MIME::Lite->send');
|
||||||
MIME::Lite->send(smtp=>$Config{ZM_EMAIL_HOST}, Timeout=>60);
|
MIME::Lite->send(smtp=>$Config{ZM_EMAIL_HOST}, Timeout=>60);
|
||||||
$mail->send();
|
$mail->send();
|
||||||
} else {
|
} else {
|
||||||
|
@ -933,29 +933,29 @@ sub sendMessage {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if ( $@ ) {
|
if ( $@ ) {
|
||||||
Error("Unable tosend email: $@");
|
Error("Unable to send email: $@");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
Info('Notification message sent');
|
Info('Notification message sent');
|
||||||
}
|
}
|
||||||
my $sql = 'UPDATE Events SET Messaged = 1 WHERE Id = ?';
|
my $sql = 'UPDATE Events SET Messaged = 1 WHERE Id = ?';
|
||||||
my $sth = $dbh->prepare_cached($sql)
|
my $sth = $dbh->prepare_cached($sql)
|
||||||
or Fatal("Unable toprepare '$sql': ".$dbh->errstr());
|
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
||||||
my $res = $sth->execute($Event->{Id})
|
my $res = $sth->execute($Event->{Id})
|
||||||
or Fatal("Unable toexecute '$sql': ".$dbh->errstr());
|
or Fatal("Unable to execute '$sql': ".$dbh->errstr());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} # end sub sendMessage
|
} # end sub sendMessage
|
||||||
|
|
||||||
sub executeCommand {
|
sub executeCommand {
|
||||||
my $filter = shift;
|
my $filter = shift;
|
||||||
my $event = shift;
|
my $Event = shift;
|
||||||
|
|
||||||
my $event_path = $event->Path();
|
my $event_path = $Event->Path();
|
||||||
|
|
||||||
my $command = $filter->{AutoExecuteCmd};
|
my $command = $filter->{AutoExecuteCmd};
|
||||||
$command .= " $event_path";
|
$command .= " $event_path";
|
||||||
$command = substituteTags($command, $filter, $event);
|
$command = substituteTags($command, $filter, $Event);
|
||||||
|
|
||||||
Info("Executing '$command'");
|
Info("Executing '$command'");
|
||||||
my $output = qx($command);
|
my $output = qx($command);
|
||||||
|
@ -971,7 +971,7 @@ sub executeCommand {
|
||||||
my $sql = 'UPDATE Events SET Executed = 1 WHERE Id = ?';
|
my $sql = 'UPDATE Events SET Executed = 1 WHERE Id = ?';
|
||||||
my $sth = $dbh->prepare_cached($sql)
|
my $sth = $dbh->prepare_cached($sql)
|
||||||
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
or Fatal("Unable to prepare '$sql': ".$dbh->errstr());
|
||||||
my $res = $sth->execute( $event->{Id} )
|
my $res = $sth->execute( $Event->{Id} )
|
||||||
or Fatal("Unable to execute '$sql': ".$dbh->errstr());
|
or Fatal("Unable to execute '$sql': ".$dbh->errstr());
|
||||||
}
|
}
|
||||||
return( 1 );
|
return( 1 );
|
||||||
|
|
|
@ -23,7 +23,7 @@ case $i in
|
||||||
shift # past argument=value
|
shift # past argument=value
|
||||||
;;
|
;;
|
||||||
-d=*|--distro=*)
|
-d=*|--distro=*)
|
||||||
DISTRO="${i#*=}"
|
DISTROS="${i#*=}"
|
||||||
shift # past argument=value
|
shift # past argument=value
|
||||||
;;
|
;;
|
||||||
-i=*|--interactive=*)
|
-i=*|--interactive=*)
|
||||||
|
@ -74,11 +74,15 @@ else
|
||||||
echo "Doing $TYPE build"
|
echo "Doing $TYPE build"
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [ "$DISTRO" == "" ]; then
|
if [ "$DISTROS" == "" ]; then
|
||||||
DISTRO=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`;
|
if [ "$RELEASE" != "" ]; then
|
||||||
echo "Defaulting to $DISTRO for distribution";
|
DISTROS="xenial,bionic,trusty"
|
||||||
|
else
|
||||||
|
DISTROS=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`;
|
||||||
|
fi;
|
||||||
|
echo "Defaulting to $DISTROS for distribution";
|
||||||
else
|
else
|
||||||
echo "Building for $DISTRO";
|
echo "Building for $DISTROS";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# Release is a special mode... it uploads to the release ppa and cannot have a snapshot
|
# Release is a special mode... it uploads to the release ppa and cannot have a snapshot
|
||||||
|
@ -116,6 +120,18 @@ else
|
||||||
fi;
|
fi;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PPA="";
|
||||||
|
if [ "$RELEASE" != "" ]; then
|
||||||
|
# We need to use our official tarball for the original source, so grab it and overwrite our generated one.
|
||||||
|
IFS='.' read -r -a VERSION <<< "$RELEASE"
|
||||||
|
PPA="ppa:iconnor/zoneminder-${VERSION[0]}.${VERSION[1]}"
|
||||||
|
else
|
||||||
|
if [ "$BRANCH" == "" ]; then
|
||||||
|
PPA="ppa:iconnor/zoneminder-master";
|
||||||
|
else
|
||||||
|
PPA="ppa:iconnor/zoneminder-$BRANCH";
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
|
||||||
# Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead.
|
# Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead.
|
||||||
if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then
|
if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then
|
||||||
|
@ -154,6 +170,11 @@ if [ "$SNAPSHOT" != "stable" ] && [ "$SNAPSHOT" != "" ]; then
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
DIRECTORY="zoneminder_$VERSION";
|
DIRECTORY="zoneminder_$VERSION";
|
||||||
|
if [ -d "$DIRECTORY.orig" ]; then
|
||||||
|
echo "$DIRECTORY.orig already exists. Please delete it."
|
||||||
|
exit 0;
|
||||||
|
fi;
|
||||||
|
|
||||||
echo "Doing $TYPE release $DIRECTORY";
|
echo "Doing $TYPE release $DIRECTORY";
|
||||||
mv "${GITHUB_FORK}_zoneminder_release" "$DIRECTORY.orig";
|
mv "${GITHUB_FORK}_zoneminder_release" "$DIRECTORY.orig";
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
@ -161,6 +182,7 @@ if [ $? -ne 0 ]; then
|
||||||
echo "Setting up build dir failed.";
|
echo "Setting up build dir failed.";
|
||||||
exit $?;
|
exit $?;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
cd "$DIRECTORY.orig";
|
cd "$DIRECTORY.orig";
|
||||||
|
|
||||||
# Init submodules
|
# Init submodules
|
||||||
|
@ -172,36 +194,45 @@ rm -rf .git
|
||||||
rm .gitignore
|
rm .gitignore
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
tar zcf $DIRECTORY.orig.tar.gz $DIRECTORY.orig
|
if [ ! -e "$DIRECTORY.orig.tar.gz" ]; then
|
||||||
cd $DIRECTORY.orig
|
tar zcf $DIRECTORY.orig.tar.gz $DIRECTORY.orig
|
||||||
|
fi;
|
||||||
|
|
||||||
# Generate Changlog
|
IFS=',' ;for DISTRO in `echo "$DISTROS"`; do
|
||||||
if [ "$DISTRO" == "trusty" ] || [ "$DISTRO" == "precise" ]; then
|
echo "Generating package for $DISTRO";
|
||||||
mv distros/ubuntu1204 debian
|
cd $DIRECTORY.orig
|
||||||
else
|
|
||||||
if [ "$DISTRO" == "wheezy" ]; then
|
if [ -e "debian" ]; then
|
||||||
mv distros/debian debian
|
rm -rf debian
|
||||||
else
|
|
||||||
mv distros/ubuntu1604 debian
|
|
||||||
fi;
|
fi;
|
||||||
fi;
|
|
||||||
|
|
||||||
if [ "$DEBEMAIL" != "" ] && [ "$DEBFULLNAME" != "" ]; then
|
# Generate Changlog
|
||||||
AUTHOR="$DEBFULLNAME <$DEBEMAIL>"
|
if [ "$DISTRO" == "trusty" ] || [ "$DISTRO" == "precise" ]; then
|
||||||
else
|
cp -Rpd distros/ubuntu1204 debian
|
||||||
if [ -z `hostname -d` ] ; then
|
|
||||||
AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`.local>"
|
|
||||||
else
|
else
|
||||||
AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`>"
|
if [ "$DISTRO" == "wheezy" ]; then
|
||||||
|
cp -Rpd distros/debian debian
|
||||||
|
else
|
||||||
|
cp -Rpd distros/ubuntu1604 debian
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if [ "$DEBEMAIL" != "" ] && [ "$DEBFULLNAME" != "" ]; then
|
||||||
|
AUTHOR="$DEBFULLNAME <$DEBEMAIL>"
|
||||||
|
else
|
||||||
|
if [ -z `hostname -d` ] ; then
|
||||||
|
AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`.local>"
|
||||||
|
else
|
||||||
|
AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`>"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$URGENCY" = "" ]; then
|
if [ "$URGENCY" = "" ]; then
|
||||||
URGENCY="medium"
|
URGENCY="medium"
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [ "$SNAPSHOT" == "stable" ]; then
|
if [ "$SNAPSHOT" == "stable" ]; then
|
||||||
cat <<EOF > debian/changelog
|
cat <<EOF > debian/changelog
|
||||||
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
||||||
|
|
||||||
* Release $VERSION
|
* Release $VERSION
|
||||||
|
@ -209,59 +240,92 @@ zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
||||||
-- $AUTHOR $DATE
|
-- $AUTHOR $DATE
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
cat <<EOF > debian/NEWS
|
cat <<EOF > debian/NEWS
|
||||||
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
||||||
|
|
||||||
* Release $VERSION
|
* Release $VERSION
|
||||||
|
|
||||||
-- $AUTHOR $DATE
|
-- $AUTHOR $DATE
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cat <<EOF > debian/changelog
|
cat <<EOF > debian/changelog
|
||||||
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
-- $AUTHOR $DATE
|
-- $AUTHOR $DATE
|
||||||
EOF
|
EOF
|
||||||
cat <<EOF > debian/changelog
|
cat <<EOF > debian/changelog
|
||||||
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
-- $AUTHOR $DATE
|
-- $AUTHOR $DATE
|
||||||
EOF
|
EOF
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [ $TYPE == "binary" ]; then
|
if [ $TYPE == "binary" ]; then
|
||||||
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
|
||||||
sudo apt-get install devscripts equivs
|
|
||||||
sudo mk-build-deps -ir ./debian/control
|
|
||||||
echo "Status: $?"
|
|
||||||
DEBUILD=debuild
|
|
||||||
else
|
|
||||||
if [ $TYPE == "local" ]; then
|
|
||||||
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
||||||
sudo apt-get install devscripts equivs
|
sudo apt-get install devscripts equivs
|
||||||
sudo mk-build-deps -ir ./debian/control
|
sudo mk-build-deps -ir ./debian/control
|
||||||
echo "Status: $?"
|
echo "Status: $?"
|
||||||
DEBUILD="debuild -i -us -uc -b"
|
DEBUILD=debuild
|
||||||
else
|
else
|
||||||
# Source build, don't need build depends.
|
if [ $TYPE == "local" ]; then
|
||||||
DEBUILD="debuild -S -sa"
|
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
||||||
|
sudo apt-get install devscripts equivs
|
||||||
|
sudo mk-build-deps -ir ./debian/control
|
||||||
|
echo "Status: $?"
|
||||||
|
DEBUILD="debuild -i -us -uc -b"
|
||||||
|
else
|
||||||
|
# Source build, don't need build depends.
|
||||||
|
DEBUILD="debuild -S -sa"
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
if [ "$DEBSIGN_KEYID" != "" ]; then
|
||||||
|
DEBUILD="$DEBUILD -k$DEBSIGN_KEYID"
|
||||||
|
fi
|
||||||
|
eval $DEBUILD
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error status code is: $?"
|
||||||
|
echo "Build failed.";
|
||||||
|
exit $?;
|
||||||
fi;
|
fi;
|
||||||
fi;
|
|
||||||
if [ "$DEBSIGN_KEYID" != "" ]; then
|
|
||||||
DEBUILD="$DEBUILD -k$DEBSIGN_KEYID"
|
|
||||||
fi
|
|
||||||
$DEBUILD
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error status code is: $?"
|
|
||||||
echo "Build failed.";
|
|
||||||
exit $?;
|
|
||||||
fi;
|
|
||||||
|
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
|
if [ $TYPE == "binary" ]; then
|
||||||
|
if [ "$INTERACTIVE" != "no" ]; then
|
||||||
|
read -p "Not doing dput since it's a binary release. Do you want to install it? (y/N)"
|
||||||
|
if [[ $REPLY == [yY] ]]; then
|
||||||
|
sudo dpkg -i $DIRECTORY*.deb
|
||||||
|
fi;
|
||||||
|
read -p "Do you want to upload this binary to zmrepo? (y/N)"
|
||||||
|
if [[ $REPLY == [yY] ]]; then
|
||||||
|
if [ "$RELEASE" != "" ]; then
|
||||||
|
scp "zoneminder_${VERSION}-${DISTRO}"* "zoneminder-doc_${VERSION}-${DISTRO}"* "zoneminder-dbg_${VERSION}-${DISTRO}"* "zoneminder_${VERSION}.orig.tar.gz" "zmrepo@zmrepo.connortechnology.com:debian/stable/mini-dinstall/incoming/"
|
||||||
|
else
|
||||||
|
if [ "$BRANCH" == "" ]; then
|
||||||
|
scp "zoneminder_${VERSION}-${DISTRO}"* "zoneminder-doc_${VERSION}-${DISTRO}"* "zoneminder-dbg_${VERSION}-${DISTRO}"* "zoneminder_${VERSION}.orig.tar.gz" "zmrepo@zmrepo.connortechnology.com:debian/master/mini-dinstall/incoming/"
|
||||||
|
else
|
||||||
|
scp "$DIRECTORY-${DISTRO}"* "zoneminder-doc_${VERSION}-${DISTRO}"* "zoneminder-dbg_${VERSION}-${DISTRO}"* "zoneminder_${VERSION}.orig.tar.gz" "zmrepo@zmrepo.connortechnology.com:debian/${BRANCH}/mini-dinstall/incoming/"
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
else
|
||||||
|
SC="zoneminder_${VERSION}-${DISTRO}${PACKAGE_VERSION}_source.changes";
|
||||||
|
|
||||||
|
dput="Y";
|
||||||
|
if [ "$INTERACTIVE" != "no" ]; then
|
||||||
|
read -p "Ready to dput $SC to $PPA ? Y/N...";
|
||||||
|
if [[ "$REPLY" == [yY] ]]; then
|
||||||
|
dput $PPA $SC
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
done; # foreach distro
|
||||||
|
|
||||||
if [ "$INTERACTIVE" != "no" ]; then
|
if [ "$INTERACTIVE" != "no" ]; then
|
||||||
read -p "Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]"
|
read -p "Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]"
|
||||||
[[ $REPLY == [yY] ]] && { mv "$DIRECTORY.orig" zoneminder_release; echo "The checked out copy is preserved in zoneminder_release"; } || { rm -fr "$DIRECTORY.orig"; echo "The checked out copy has been deleted"; }
|
[[ $REPLY == [yY] ]] && { mv "$DIRECTORY.orig" zoneminder_release; echo "The checked out copy is preserved in zoneminder_release"; } || { rm -fr "$DIRECTORY.orig"; echo "The checked out copy has been deleted"; }
|
||||||
|
@ -270,53 +334,4 @@ else
|
||||||
rm -fr "$DIRECTORY.orig"; echo "The checked out copy has been deleted";
|
rm -fr "$DIRECTORY.orig"; echo "The checked out copy has been deleted";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $TYPE == "binary" ]; then
|
|
||||||
if [ "$INTERACTIVE" != "no" ]; then
|
|
||||||
read -p "Not doing dput since it's a binary release. Do you want to install it? (y/N)"
|
|
||||||
if [[ $REPLY == [yY] ]]; then
|
|
||||||
sudo dpkg -i $DIRECTORY*.deb
|
|
||||||
fi;
|
|
||||||
read -p "Do you want to upload this binary to zmrepo? (y/N)"
|
|
||||||
if [[ $REPLY == [yY] ]]; then
|
|
||||||
if [ "$RELEASE" != "" ]; then
|
|
||||||
scp "zoneminder_${VERSION}-${DISTRO}"* "zoneminder-doc_${VERSION}-${DISTRO}"* "zoneminder-dbg_${VERSION}-${DISTRO}"* "zoneminder_${VERSION}.orig.tar.gz" "zmrepo@zmrepo.connortechnology.com:debian/stable/mini-dinstall/incoming/"
|
|
||||||
else
|
|
||||||
if [ "$BRANCH" == "" ]; then
|
|
||||||
scp "zoneminder_${VERSION}-${DISTRO}"* "zoneminder-doc_${VERSION}-${DISTRO}"* "zoneminder-dbg_${VERSION}-${DISTRO}"* "zoneminder_${VERSION}.orig.tar.gz" "zmrepo@zmrepo.connortechnology.com:debian/master/mini-dinstall/incoming/"
|
|
||||||
else
|
|
||||||
scp "$DIRECTORY-${DISTRO}"* "zoneminder-doc_${VERSION}-${DISTRO}"* "zoneminder-dbg_${VERSION}-${DISTRO}"* "zoneminder_${VERSION}.orig.tar.gz" "zmrepo@zmrepo.connortechnology.com:debian/${BRANCH}/mini-dinstall/incoming/"
|
|
||||||
fi;
|
|
||||||
fi;
|
|
||||||
fi;
|
|
||||||
fi;
|
|
||||||
else
|
|
||||||
SC="zoneminder_${VERSION}-${DISTRO}${PACKAGE_VERSION}_source.changes";
|
|
||||||
PPA="";
|
|
||||||
if [ "$RELEASE" != "" ]; then
|
|
||||||
# We need to use our official tarball for the original source, so grab it and overwrite our generated one.
|
|
||||||
if [ ! -e "$RELEASE.tar.gz" ]; then
|
|
||||||
echo "Grabbing official source tarball from github."
|
|
||||||
wget "https://github.com/ZoneMinder/zoneminder/archive/$RELEASE.tar.gz"
|
|
||||||
fi;
|
|
||||||
echo "Overwriting generated zoneminder_${VERSION}.orig.tar.gz with source tarball from github";
|
|
||||||
cp "$RELEASE.tar.gz" "zoneminder_${VERSION}.orig.tar.gz"
|
|
||||||
IFS='.' read -r -a VERSION <<< "$RELEASE"
|
|
||||||
PPA="ppa:iconnor/zoneminder-${VERSION[0]}.${VERSION[1]}"
|
|
||||||
else
|
|
||||||
if [ "$BRANCH" == "" ]; then
|
|
||||||
PPA="ppa:iconnor/zoneminder-master";
|
|
||||||
else
|
|
||||||
PPA="ppa:iconnor/zoneminder-$BRANCH";
|
|
||||||
fi;
|
|
||||||
fi;
|
|
||||||
|
|
||||||
dput="Y";
|
|
||||||
if [ "$INTERACTIVE" != "no" ]; then
|
|
||||||
read -p "Ready to dput $SC to $PPA ? Y/N...";
|
|
||||||
if [[ "$REPLY" == [yY] ]]; then
|
|
||||||
dput $PPA $SC
|
|
||||||
fi;
|
|
||||||
fi;
|
|
||||||
fi;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,27 +101,25 @@ class HostController extends AppController {
|
||||||
$this->loadModel('Monitor');
|
$this->loadModel('Monitor');
|
||||||
|
|
||||||
// If $mid is passed, see if it is valid
|
// If $mid is passed, see if it is valid
|
||||||
if ($mid) {
|
if ( $mid ) {
|
||||||
if (!$this->Monitor->exists($mid)) {
|
if ( !$this->Monitor->exists($mid) ) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$zm_dir_events = $this->Config->find('list', array(
|
$zm_dir_events = ZM_DIR_EVENTS;
|
||||||
'conditions' => array('Name' => 'ZM_DIR_EVENTS'),
|
|
||||||
'fields' => array('Name', 'Value')
|
|
||||||
));
|
|
||||||
$zm_dir_events = $zm_dir_events['ZM_DIR_EVENTS' ];
|
|
||||||
|
|
||||||
// Test to see if $zm_dir_events is relative or absolute
|
// Test to see if $zm_dir_events is relative or absolute
|
||||||
if ('/' === "" || strrpos($zm_dir_events, '/', -strlen($zm_dir_events)) !== TRUE) {
|
#if ('/' === "" || strrpos($zm_dir_events, '/', -strlen($zm_dir_events)) !== TRUE) {
|
||||||
|
if ( substr($zm_dir_events, 0, 1) != '/' ) {
|
||||||
// relative - so add the full path
|
// relative - so add the full path
|
||||||
$zm_dir_events = Configure::read('ZM_PATH_WEB') . '/' . $zm_dir_events;
|
$zm_dir_events = ZM_PATH_WEB . '/' . $zm_dir_events;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mid) {
|
if ( $mid ) {
|
||||||
// Get disk usage for $mid
|
// Get disk usage for $mid
|
||||||
$usage = shell_exec ("du -sh0 $zm_dir_events/$mid | awk '{print $1}'");
|
Logger::Debug("Executing du -s0 $zm_dir_events/$mid | awk '{print $1}'");
|
||||||
|
$usage = shell_exec("du -s0 $zm_dir_events/$mid | awk '{print $1}'");
|
||||||
} else {
|
} else {
|
||||||
$monitors = $this->Monitor->find('all', array(
|
$monitors = $this->Monitor->find('all', array(
|
||||||
'fields' => array('Id', 'Name', 'WebColour')
|
'fields' => array('Id', 'Name', 'WebColour')
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
<?php
|
||||||
|
App::uses('AppController', 'Controller');
|
||||||
|
/**
|
||||||
|
* Storage Controller
|
||||||
|
*
|
||||||
|
* @property Storage $Storage
|
||||||
|
* @property PaginatorComponent $Paginator
|
||||||
|
*/
|
||||||
|
class StorageController extends AppController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Components
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $components = array('Paginator', 'RequestHandler');
|
||||||
|
|
||||||
|
public function beforeFilter() {
|
||||||
|
parent::beforeFilter();
|
||||||
|
global $user;
|
||||||
|
$canView = (!$user) || ($user['System'] != 'None');
|
||||||
|
if ( !$canView ) {
|
||||||
|
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* index method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function index() {
|
||||||
|
$this->Storage->recursive = 0;
|
||||||
|
|
||||||
|
$options = '';
|
||||||
|
$storage_areas = $this->Storage->find('all',$options);
|
||||||
|
$this->set(array(
|
||||||
|
'storage' => $storage_areas,
|
||||||
|
'_serialize' => array('storage')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* view method
|
||||||
|
*
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @param string $id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function view($id = null) {
|
||||||
|
$this->Storage->recursive = 0;
|
||||||
|
if (!$this->Storage->exists($id)) {
|
||||||
|
throw new NotFoundException(__('Invalid storage area'));
|
||||||
|
}
|
||||||
|
$restricted = '';
|
||||||
|
|
||||||
|
$options = array('conditions' => array(
|
||||||
|
array('Storage.' . $this->Storage->primaryKey => $id),
|
||||||
|
$restricted
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$storage = $this->Storage->find('first', $options);
|
||||||
|
$this->set(array(
|
||||||
|
'storage' => $storage,
|
||||||
|
'_serialize' => array('storage')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function add() {
|
||||||
|
if ( $this->request->is('post') ) {
|
||||||
|
|
||||||
|
global $user;
|
||||||
|
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||||
|
if ( !$canEdit ) {
|
||||||
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->Storage->create();
|
||||||
|
if ( $this->Storage->save($this->request->data) ) {
|
||||||
|
# Might be nice to send it a start request
|
||||||
|
#$this->daemonControl($this->Storage->id, 'start', $this->request->data);
|
||||||
|
return $this->flash(__('The storage area has been saved.'), array('action' => 'index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* edit method
|
||||||
|
*
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @param string $id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function edit($id = null) {
|
||||||
|
$this->Storage->id = $id;
|
||||||
|
|
||||||
|
global $user;
|
||||||
|
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||||
|
if ( !$canEdit ) {
|
||||||
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$this->Storage->exists($id) ) {
|
||||||
|
throw new NotFoundException(__('Invalid storage area'));
|
||||||
|
}
|
||||||
|
if ( $this->Storage->save($this->request->data) ) {
|
||||||
|
$message = 'Saved';
|
||||||
|
} else {
|
||||||
|
$message = 'Error';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->set(array(
|
||||||
|
'message' => $message,
|
||||||
|
'_serialize' => array('message')
|
||||||
|
));
|
||||||
|
// - restart this storage area after change
|
||||||
|
#$this->daemonControl($this->Storage->id, 'restart', $this->request->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete method
|
||||||
|
*
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @param string $id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function delete($id = null) {
|
||||||
|
global $user;
|
||||||
|
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||||
|
if ( !$canEdit ) {
|
||||||
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->Storage->id = $id;
|
||||||
|
if ( !$this->Storage->exists() ) {
|
||||||
|
throw new NotFoundException(__('Invalid storage area'));
|
||||||
|
}
|
||||||
|
$this->request->allowMethod('post', 'delete');
|
||||||
|
|
||||||
|
#$this->daemonControl($this->Storage->id, 'stop');
|
||||||
|
|
||||||
|
if ( $this->Storage->delete() ) {
|
||||||
|
return $this->flash(__('The storage area has been deleted.'), array('action' => 'index'));
|
||||||
|
} else {
|
||||||
|
return $this->flash(__('The storage area could not be deleted. Please, try again.'), array('action' => 'index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
.overlayHeader {
|
.overlayHeader {
|
||||||
float: left;
|
float: left;
|
||||||
background-color: #dddddd;
|
background-color: #853131;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-bottom: 1px solid #666666;
|
border-bottom: 1px solid #666666;
|
||||||
color: black;
|
color: black;
|
||||||
|
|
|
@ -547,7 +547,7 @@ private $control_fields = array(
|
||||||
} // end function Source
|
} // end function Source
|
||||||
|
|
||||||
public function Url() {
|
public function Url() {
|
||||||
return $this->Server()->Url() .':'. ( ZM_MIN_STREAMING_PORT ? (ZM_MIN_STREAMING_PORT+$this->Id()) : $_SERVER['SERVER_PORT'] );
|
return $this->Server()->Url( ZM_MIN_STREAMING_PORT ? (ZM_MIN_STREAMING_PORT+$this->Id()) : null );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end class Monitor
|
} // end class Monitor
|
||||||
|
|
|
@ -38,13 +38,18 @@ class Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Url() {
|
public function Url( $port = null ) {
|
||||||
|
$url = ZM_BASE_PROTOCOL . '://';
|
||||||
if ( $this->Id() ) {
|
if ( $this->Id() ) {
|
||||||
return ZM_BASE_PROTOCOL . '://'. $this->Hostname();
|
$url .= $this->Hostname();
|
||||||
} else {
|
} else {
|
||||||
return ZM_BASE_PROTOCOL . '://'. $_SERVER['SERVER_NAME'];
|
$url .= $_SERVER['SERVER_NAME'];
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
if ( $port ) {
|
||||||
|
$url .= ':'.$port;
|
||||||
|
}
|
||||||
|
$url .= $_SERVER['PHP_SELF'];
|
||||||
|
return $url;
|
||||||
}
|
}
|
||||||
public function Hostname() {
|
public function Hostname() {
|
||||||
if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) {
|
if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) {
|
||||||
|
|
|
@ -183,12 +183,13 @@ foreach ( getSkinIncludes('skin.php') as $includeFile )
|
||||||
require_once $includeFile;
|
require_once $includeFile;
|
||||||
|
|
||||||
if ( ZM_OPT_USE_AUTH ) {
|
if ( ZM_OPT_USE_AUTH ) {
|
||||||
if ( ZM_AUTH_HASH_LOGINS ) {
|
if ( ZM_AUTH_HASH_LOGINS && empty($user) && ! empty($_REQUEST['auth']) ) {
|
||||||
if ( empty($user) && ! empty($_REQUEST['auth']) ) {
|
|
||||||
if ( $authUser = getAuthUser($_REQUEST['auth']) ) {
|
if ( $authUser = getAuthUser($_REQUEST['auth']) ) {
|
||||||
userLogin($authUser['Username'], $authUser['Password'], true);
|
userLogin($authUser['Username'], $authUser['Password'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( isset($_REQUEST['username']) and isset($_REQUEST['password']) ) {
|
||||||
|
userLogin($_REQUEST['username'], $_REQUEST['password'], false);
|
||||||
}
|
}
|
||||||
if ( !empty($user) ) {
|
if ( !empty($user) ) {
|
||||||
// generate it once here, while session is open. Value will be cached in session and return when called later on
|
// generate it once here, while session is open. Value will be cached in session and return when called later on
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Disallow: /
|
Disallow: /
|
||||||
|
###
|
Loading…
Reference in New Issue