Commit 629b2e91 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

restore /etc/elphel393 dir from nand

parent d51ebeb0
...@@ -148,17 +148,38 @@ function backup(){ ...@@ -148,17 +148,38 @@ function backup(){
exec("umount $UBI_MNT"); exec("umount $UBI_MNT");
if (is_dir($UBI_MNT)) rmdir($UBI_MNT); if (is_dir($UBI_MNT)) rmdir($UBI_MNT);
exec("ubidetach /dev/ubi_ctrl -m 4"); exec("ubidetach /dev/ubi_ctrl -m 4");
}else{ }else{
//booted from nand //booted from nand
exec("tar -czvf var/$BKP_NAME -C ${BKP_DIR} ."); exec("tar -czvf var/$BKP_NAME -C ${BKP_DIR} .");
} }
}
function send_backup(){
global $BKP_NAME;
header("Content-Type: application/octet-stream"); header("Content-Type: application/octet-stream");
header('Content-Disposition: attachment; filename='.$BKP_NAME); header('Content-Disposition: attachment; filename='.$BKP_NAME);
print(file_get_contents("var/$BKP_NAME")); print(file_get_contents("var/$BKP_NAME"));
} }
function restore_backup(){
global $NAND_PATH;
global $UBI_MNT;
global $BKP_NAME;
global $BKP_DIR;
if (!is_dir($NAND_PATH)){
exec("flash_unlock /dev/mtd4");
exec("ubiattach /dev/ubi_ctrl -m 4");
if (!is_dir($UBI_MNT)) mkdir($UBI_MNT);
exec("mount -t ubifs -o ro /dev/ubi0_0 $UBI_MNT");
exec("tar -C ${UBI_MNT}${BKP_DIR} -xzpf var/$BKP_NAME");
exec("sync");
exec("umount $UBI_MNT");
if (is_dir($UBI_MNT)) rmdir($UBI_MNT);
exec("ubidetach /dev/ubi_ctrl -m 4");
}
}
function remove(){ function remove(){
global $UPDATE_DIR; global $UPDATE_DIR;
exec("rm -rf $UPDATE_DIR/*; sync"); exec("rm -rf $UPDATE_DIR/*; sync");
...@@ -175,10 +196,13 @@ else if (isset($argv[1])) ...@@ -175,10 +196,13 @@ else if (isset($argv[1]))
switch($cmd){ switch($cmd){
case "flash": case "flash":
$flash_list = verify(false); $flash_list = verify(false);
backup();
nandflash($flash_list); nandflash($flash_list);
restore_backup();
break; break;
case "backup": case "backup":
backup(); backup();
send_backup();
break; break;
case "remove": case "remove":
remove(); remove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment