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.

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