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

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. // require_once( $WDIR . '/inst_lib.php');
  3. echo "\n\n\nAFTER!!\n\n\n";
  4. $CMD = `cp -f /srv/etc/ag_nginx/argus_nginx.service /etc/systemd/system/argus_nginx.service`;
  5. //$CMD = `systemctl daemon-reload`;
  6. $CMD = `cp -f /srv/etc/nginx/default /etc/nginx/sites-available/default`;
  7. $CMD = `cp -f /srv/etc/rc.local /etc/rc.local`;
  8. $CMD = `chown -R www-data:www-data /srv_la/www/web/lib/controller/data/reports`;
  9. $CMD = `chmod -R 0775 /srv_la/www/web/lib/controller/data/reports`;
  10. //Setup MediMTX
  11. $CMD = `systemctl stop mediamtx.service`; // just to be sure
  12. $CMD = `mv -f /srv/mediamtx /opt`;
  13. $CMD = `mv -f /opt/mediamtx/mediamtx.service /etc/systemd/system/mediamtx.service`;
  14. $CMD = `systemctl daemon-reload`;
  15. $CMD = `systemctl enable mediamtx.service`;
  16. $CMD = `systemctl enable argus_nginx`;
  17. //Restore Settings
  18. function restore_whole_line( $A, $B , $C ){
  19. $POPIN = array();
  20. foreach( $C as $Key=>$Value ){
  21. if( $Key != 'id' ){
  22. switch( $B ){
  23. case 'target_filter_train':{
  24. switch( $Key ){
  25. //Update DB to 08.01.2026
  26. case 'MINIMAL_RANGE':{
  27. $POPIN[]="`MINIMAL_RIGHT_RANGE`='".$Value."'";
  28. $POPIN[]="`MINIMAL_LEFT_RANGE`='".$Value."'";
  29. break;
  30. };
  31. default:
  32. $POPIN[]="`".$Key."`='".$Value."'";
  33. };
  34. break;
  35. };
  36. default:
  37. $POPIN[]="`".$Key."`='".$Value."'";
  38. };
  39. };
  40. };
  41. $QS = "UPDATE `{$B}` SET ". implode(",",$POPIN)." WHERE `id`=" . $C['id'];
  42. out_log( $QS );
  43. $A->Query( $QS );
  44. };
  45. function restore_line( $A, $B , $C ){
  46. foreach( $C as $Key=>$Value ){
  47. if( $Key != 'id' ){
  48. switch( $B ){
  49. case 'target_filter_train':{
  50. switch( $Key ){
  51. //Ignore that field
  52. case 'OLD_MINIMAL_RANGE':{
  53. break;
  54. };
  55. //Update DB to 08.01.2026
  56. case 'MINIMAL_RANGE':{
  57. $P="`MINIMAL_RIGHT_RANGE`='".$Value."'";
  58. $QS = "UPDATE `{$B}` SET ".$P." WHERE `id`=" . $C['id'];
  59. out_log( $QS );
  60. $A->Query( $QS );
  61. $P="`MINIMAL_LEFT_RANGE`='".$Value."'";
  62. break;
  63. };
  64. default:
  65. $P="`".$Key."`='".$Value."'";
  66. };
  67. break;
  68. };
  69. default:
  70. $P="`".$Key."`='".$Value."'";
  71. };
  72. //If Not Ignored Then issue Query
  73. if( $P!='' ){
  74. $QS = "UPDATE `{$B}` SET ".$P." WHERE `id`=" . $C['id'];
  75. out_log( $QS );
  76. $A->Query( $QS );
  77. };
  78. };
  79. };
  80. };
  81. function add_whole_line( $A, $B , $C ){
  82. $POPIN = array();
  83. foreach( $C as $Key=>$Value ){
  84. if( $Key != 'id' ){
  85. $POPIN[]=$Value;
  86. $POLE[]=$Key;
  87. };
  88. };
  89. $QS = "INSERT INTO `{$B}`(`".implode("`,`",$POLE )."`) VALUES('". implode("','",$POPIN )."')";
  90. out_log( $QS );
  91. $A->Query( $QS );
  92. };
  93. if( file_exists('/srv/www/web/lib/controller/data/mysqlitedb.db') ){
  94. //Run Database Upgrade
  95. $CMD = `cd /srv/www/web/lib; php ./upgrade_database.php`;
  96. if( !class_exists( 'SQLite_DB' ) ){
  97. require_once( $WDIR . '/SQLite_Class.php');
  98. };
  99. out_log("New Database Exists!");
  100. $INS_TIME_DB = new SQLite_DB('/srv/www/web/lib/controller/data/mysqlitedb.db');
  101. foreach( $CAMERA_SETTINGS as $CS ){
  102. restore_line( $INS_TIME_DB, 'cameras', $CS );
  103. $QS = "UPDATE `nodes` SET `name`='{$CS['name']}' WHERE `type`={$CS['type']} AND `aux_id`={$CS['id']}";
  104. out_log( $QS );
  105. $INS_TIME_DB->Query( $QS );
  106. };
  107. if( isset( $SENSOR_SETTINGS ) ) foreach( $SENSOR_SETTINGS as $SS ) restore_line( $INS_TIME_DB, 'lrf_sensors', $SS );
  108. if( isset( $TRAIN_FILTER_SETTINGS ) ) foreach( $TRAIN_FILTER_SETTINGS as $FS ) restore_line( $INS_TIME_DB, 'target_filter_train', $FS );
  109. if( isset( $BUBBLE_FILTER_SETTINGS ) ) foreach( $BUBBLE_FILTER_SETTINGS as $FS ) restore_line( $INS_TIME_DB, 'target_filter_bubble', $FS );
  110. if( isset( $FROZEN_BUBBLES ) ) foreach( $FROZEN_BUBBLES as $FS ) add_whole_line( $INS_TIME_DB, 'target_bubbles', $FS );
  111. if( isset( $DRAW_SETTINGS ) ) foreach( $DRAW_SETTINGS as $DS ) add_whole_line( $INS_TIME_DB, 'lrf_draw', $DS );
  112. unset( $INS_TIME_DB );
  113. copy( '/srv/www/web/lib/controller/data/mysqlitedb.db', '/srv/www/distro/lib/data/mysqlitedb.db' );
  114. } else out_log("New Database Not exists!");
  115. //Services are managed before
  116. //$CMD = `systemctl start argus_nginx`;
  117. //$CMD = `systemctl enable argus_nginx`;
  118. //$CMD = `systemctl start nginx`;
  119. $CMD = `reboot`;
  120. ?>