You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
4.2 KiB
124 lines
4.2 KiB
<?php
|
|
|
|
// require_once( $WDIR . '/inst_lib.php');
|
|
echo "\n\n\nAFTER!!\n\n\n";
|
|
$CMD = `cp -f /srv/etc/ag_nginx/argus_nginx.service /etc/systemd/system/argus_nginx.service`;
|
|
//$CMD = `systemctl daemon-reload`;
|
|
$CMD = `cp -f /srv/etc/nginx/default /etc/nginx/sites-available/default`;
|
|
$CMD = `cp -f /srv/etc/rc.local /etc/rc.local`;
|
|
$CMD = `chown -R www-data:www-data /srv_la/www/web/lib/controller/data/reports`;
|
|
$CMD = `chmod -R 0775 /srv_la/www/web/lib/controller/data/reports`;
|
|
|
|
//Setup MediMTX
|
|
|
|
$CMD = `systemctl stop mediamtx.service`; // just to be sure
|
|
$CMD = `mv -f ./mediamtx /opt/mediamtx`;
|
|
$CMD = `mv -f /opt/mediamtx/mediamtx.service /etc/systemd/system/mediamtx.service`;
|
|
$CMD = `systemctl daemon-reload`;
|
|
$CMD = `systemctl enable mediamtx.service`;
|
|
$CMD = `systemctl enable argus_nginx`;
|
|
//Restore Settings
|
|
function restore_whole_line( $A, $B , $C ){
|
|
$POPIN = array();
|
|
foreach( $C as $Key=>$Value ){
|
|
if( $Key != 'id' ){
|
|
switch( $B ){
|
|
case 'target_filter_train':{
|
|
switch( $Key ){
|
|
//Update DB to 08.01.2026
|
|
case 'MINIMAL_RANGE':{
|
|
$POPIN[]="`MINIMAL_RIGHT_RANGE`='".$Value."'";
|
|
$POPIN[]="`MINIMAL_LEFT_RANGE`='".$Value."'";
|
|
break;
|
|
};
|
|
default:
|
|
$POPIN[]="`".$Key."`='".$Value."'";
|
|
};
|
|
break;
|
|
};
|
|
default:
|
|
$POPIN[]="`".$Key."`='".$Value."'";
|
|
};
|
|
};
|
|
};
|
|
$QS = "UPDATE `{$B}` SET ". implode(",",$POPIN)." WHERE `id`=" . $C['id'];
|
|
out_log( $QS );
|
|
$A->Query( $QS );
|
|
};
|
|
function restore_line( $A, $B , $C ){
|
|
foreach( $C as $Key=>$Value ){
|
|
if( $Key != 'id' ){
|
|
switch( $B ){
|
|
case 'target_filter_train':{
|
|
switch( $Key ){
|
|
//Ignore that field
|
|
case 'OLD_MINIMAL_RANGE':{
|
|
break;
|
|
};
|
|
//Update DB to 08.01.2026
|
|
case 'MINIMAL_RANGE':{
|
|
$P="`MINIMAL_RIGHT_RANGE`='".$Value."'";
|
|
$QS = "UPDATE `{$B}` SET ".$P." WHERE `id`=" . $C['id'];
|
|
out_log( $QS );
|
|
$A->Query( $QS );
|
|
$P="`MINIMAL_LEFT_RANGE`='".$Value."'";
|
|
break;
|
|
};
|
|
default:
|
|
$P="`".$Key."`='".$Value."'";
|
|
};
|
|
break;
|
|
};
|
|
default:
|
|
$P="`".$Key."`='".$Value."'";
|
|
};
|
|
//If Not Ignored Then issue Query
|
|
if( $P!='' ){
|
|
$QS = "UPDATE `{$B}` SET ".$P." WHERE `id`=" . $C['id'];
|
|
out_log( $QS );
|
|
$A->Query( $QS );
|
|
};
|
|
};
|
|
};
|
|
};
|
|
function add_whole_line( $A, $B , $C ){
|
|
$POPIN = array();
|
|
foreach( $C as $Key=>$Value ){
|
|
if( $Key != 'id' ){
|
|
$POPIN[]=$Value;
|
|
$POLE[]=$Key;
|
|
};
|
|
};
|
|
$QS = "INSERT INTO `{$B}`(`".implode("`,`",$POLE )."`) VALUES('". implode("','",$POPIN )."')";
|
|
out_log( $QS );
|
|
$A->Query( $QS );
|
|
;
|
|
if( file_exists('/srv/www/web/lib/controller/data/mysqlitedb.db') ){
|
|
//Run Database Upgrade
|
|
$CMD = `cd /srv/www/web/lib; php ./upgrade_database.php`;
|
|
|
|
if( !class_exists( 'SQLite_DB' ) ){
|
|
require_once( $WDIR . '/SQLite_Class.php');
|
|
};
|
|
out_log("New Database Exists!");
|
|
$INS_TIME_DB = new SQLite_DB('/srv/www/web/lib/controller/data/mysqlitedb.db');
|
|
foreach( $CAMERA_SETTINGS as $CS ){
|
|
restore_line( $INS_TIME_DB, 'cameras', $CS );
|
|
$QS = "UPDATE `nodes` SET `name`='{$CS['name']}' WHERE `type`={$CS['type']} AND `aux_id`={$CS['id']}";
|
|
out_log( $QS );
|
|
$INS_TIME_DB->Query( $QS );
|
|
};
|
|
if( isset( $SENSOR_SETTINGS ) ) foreach( $SENSOR_SETTINGS as $SS ) restore_line( $INS_TIME_DB, 'lrf_sensors', $SS );
|
|
if( isset( $TRAIN_FILTER_SETTINGS ) ) foreach( $TRAIN_FILTER_SETTINGS as $FS ) restore_line( $INS_TIME_DB, 'target_filter_train', $FS );
|
|
if( isset( $BUBBLE_FILTER_SETTINGS ) ) foreach( $BUBBLE_FILTER_SETTINGS as $FS ) restore_line( $INS_TIME_DB, 'target_filter_bubble', $FS );
|
|
if( isset( $FROZEN_BUBBLES ) ) foreach( $FROZEN_BUBBLES as $FS ) add_whole_line( $INS_TIME_DB, 'target_bubbles', $FS );
|
|
if( isset( $DRAW_SETTINGS ) ) foreach( $DRAW_SETTINGS as $DS ) add_whole_line( $INS_TIME_DB, 'lrf_draw', $DS );
|
|
unset( $INS_TIME_DB );
|
|
copy( '/srv/www/web/lib/controller/data/mysqlitedb.db', '/srv/www/distro/lib/data/mysqlitedb.db' );
|
|
} else out_log("New Database Not exists!");
|
|
//Services are managed before
|
|
//$CMD = `systemctl start argus_nginx`;
|
|
//$CMD = `systemctl enable argus_nginx`;
|
|
//$CMD = `systemctl start nginx`;
|
|
$CMD = `reboot`;
|
|
?>
|