Projet

Général

Profil

« Précédent | Suivant » 

Révision 1c52509c

Ajouté par Renato Botelho il y a presque 10 ans

Fix #3691, use curl instead of fetch to download update files

Voir les différences:

etc/rc.initial.firmware_update
46 46

  
47 47
echo "\nPlease select an option to continue: ";
48 48

  
49
$pkg_interface = 'console';
49 50
$command = strtoupper(chop(fgets($fp)));
50 51

  
51 52
switch ($command) {
......
69 70
		if($status) {
70 71
			conf_mount_rw();
71 72
			mark_subsystem_dirty('firmware');
72
			if(file_exists("/root/firmware.tgz"))
73
				unlink("/root/firmware.tgz");
74
			echo "\nFetching file size...\n";
75
			$file_size = exec("fetch -s \"$url\"");
76
			$file_size = trim($file_size, "\r");
77
			echo "\nFile size: $file_size\n";
78
			echo "\nFetching file...\n";
79
			exec("fetch -1 -w15 -a -v -o /root/firmware.tgz \"$url\"");
80
			if($file_size <> filesize("/root/firmware.tgz")) {
81
				echo "\nFile size mismatch.  Upgrade cancelled.\n\n";
82
				fclose($fp);
83
				die;
84
			}			
73
			unlink_if_exists("/root/firmware.tgz");
74
			echo "\nFetching file... ";
75
			download_file_with_progress_bar($url, '/root/firmware.tgz');
85 76
			if(!file_exists("/root/firmware.tgz")) {
86 77
				echo "Something went wrong during file transfer.  Exiting.\n\n";
87 78
				fclose($fp);
79
				clear_subsystem_dirty('firmware');
88 80
				die;
89 81
			}
90 82
			$status = does_url_exist("$url.sha256");
91 83
			if($status) { 
92
				echo "\nFetching sha256...\n";
93
				exec("fetch -1 -w15 -a -v -o /root/firmware.tgz.sha256 \"$url.sha256\"");
84
				echo "\nFetching sha256... ";
85
				download_file_with_progress_bar($url . ".sha256", '/root/firmware.tgz.sha256');
86
				echo "\n";
94 87
			} else {
95 88
				echo "\n\nWARNING.\n";
96 89
				echo "\nCould not locate a sha256 file.  We cannot verify the download once completed.\n\n";
......
103 96
				echo "Downloaded file sha256: $file_sha256\n";
104 97
				if($source_sha256 <> $file_sha256) {
105 98
					echo "\n\nsha256 checksum does not match.  Cancelling upgrade.\n\n";
106
					exec("rm -f /root/*.sha256");
99
					unlink_if_exists("/root/firmware.tgz.sha256");
107 100
					fclose($fp);
101
					clear_subsystem_dirty('firmware');
108 102
					die -1;
109 103
				}
110 104
				echo "\nsha256 checksum matches.\n";
111
				exec("rm -f /root/*.sha256");
105
				unlink_if_exists("/root/firmware.tgz.sha256");
112 106
			}
113 107
			if(strstr($url,"bdiff")) {
114 108
				echo "Binary DIFF upgrade file detected...\n";
......
120 114
				$type = "normal";
121 115
			}
122 116
			do_upgrade("/root/firmware.tgz", $type);
117
			clear_subsystem_dirty('firmware');
123 118
			exit;
124 119
		}
125 120
	case "2":
......
136 131
		if(file_exists($path)) {
137 132
			mark_subsystem_dirty('firmware');
138 133
			do_upgrade($path, $type);
134
			clear_subsystem_dirty('firmware');
139 135
		} else {
140 136
			echo "\nCould not find file.\n\n";
141 137
			fclose($fp);

Formats disponibles : Unified diff