|
|
<?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`; mkdir( '/srv/www/module/lib/controller/data/uploads' ); $CMD = `chown -R www-data:www-data /srv/www/module/lib/controller/data/uploads`; $CMD = `chmod -R 0775 /srv/www/module/lib/controller/data/reports`; $CMD = `chown -R www-data:www-data /srv/www/module/lib/controller/data/uploads`; $CMD = `chmod -R 0775 /srv/www/module/lib/controller/data/reports`;
//Setup MediaMTX
$CMD = `systemctl stop mediamtx.service`; // just to be sure
$CMD = `rm -f -R /opt/mediamtx`; $CMD = `mv -f /srv/mediamtx /opt`; $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/module/lib/controller/data/mysqlitedb.db') ){ //Run Database Upgrade
$CMD = `cd /srv/www/module/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/module/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/module/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`;?>
|