1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- $lowerDir = realpath(__DIR__."/../../smartLEDZ");
- $upperDir = realpath(__DIR__."/../../smartLEDZ_Upper");
- $mergedDir = realpath(__DIR__."/../../smartLEDZ_Merged");
- $app_path = $lowerDir;
- $targetDir = $lowerDir;
- if(is_dir($mergedDir)){
- $app_path = $mergedDir;
- $targetDir = $mergedDir;
- }
- if(file_exists($app_path . "/logs/gw_back")){
- unlink($app_path . "/logs/gw_back");
- }
- if(!is_dir($app_path . "/restore")) mkdir($app_path . "/restore");
- $unCmd = sprintf("tar -xvf %s/smartLEDZ_DB_U.tar -C %s/restore", $app_path, $app_path);
- exec($unCmd);
- exec("tar -tf " . $app_path."/smartLEDZ_DB_U.tar", $output);
- if(in_array("overlay/www/smartLEDZ/db/smartLEDZ.db", $output)){
-
- exec(sprintf("cp -r %s/restore/overlay/www/smartLEDZ/* %s", $app_path, $targetDir));
- exec(sprintf("rm -rf %s/restore/overlay", $app_path));
- }else if(in_array("mnt/mmcblk0p1/www/smartLEDZ/db/smartLEDZ.db", $output)){
-
- exec(sprintf("cp -r %s/restore/mnt/mmcblk0p1/www/smartLEDZ/* %s", $app_path, $targetDir));
- exec(sprintf("rm -rf %s/restore/mnt", $app_path));
- }else if(in_array("mnt/mmcblk0p1/www/smartLEDZ_Merged/db/smartLEDZ.db", $output)){
-
- exec(sprintf("cp -r %s/restore/mnt/mmcblk0p1/www/smartLEDZ_Merged/* %s", $app_path, $targetDir));
- exec(sprintf("rm -rf %s/restore/mnt", $app_path));
- }
- exec(sprintf("cp -r %s/db/exec.json.bak %s/db/exec.json", $targetDir, $targetDir));
- file_put_contents($app_path . "/workerman/reload", "");
|