add removal of failed downloads, add sh1 check of downloaded packages
This commit is contained in:
parent
0cf21cd263
commit
e32eb33734
|
@ -57,6 +57,16 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
|
|||
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search pattern for packages
|
||||
$pkg_install_status = preg_grep($pkg_pattern, $pkgs_installed); // check install status
|
||||
$pkg_download_status = preg_grep($pkg_pattern, $pkgs_downloaded); // check package download status
|
||||
$pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array);
|
||||
|
||||
$pkg_matches = array_filter($pkgs_github_array, function($a) use ($pkg_pattern) {
|
||||
return preg_grep($pkg_pattern, $a);
|
||||
});
|
||||
|
||||
$pkg_gitname = array_values($pkg_matches)[0]['name'];
|
||||
$pkg_file = $pkg_path.$pkg_gitname;
|
||||
$pkg_url = array_values($pkg_matches)[0]['download_url'];
|
||||
$pkg_sha1 = array_values($pkg_matches)[0]['sha'];
|
||||
|
||||
//check if plugin is dependent on package
|
||||
$plugins = [];
|
||||
|
@ -69,42 +79,30 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
|
|||
logger(substr($plg_msg, 0, -2));
|
||||
}
|
||||
|
||||
if ($pkg_pref == 'yes') {
|
||||
if ($pkg_pref == 'yes') { // if package is selected to be installed
|
||||
// if executing from the wegui check status and download if necessary
|
||||
if ($argd) {
|
||||
if (!$pkg_download_status) {
|
||||
|
||||
$pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array);
|
||||
|
||||
$pkg_matches = array_filter($pkgs_github_array, function($a) use ($pkg_pattern) {
|
||||
return preg_grep($pkg_pattern, $a);
|
||||
});
|
||||
|
||||
$pkg_gitname = array_values($pkg_matches)[0]['name'];
|
||||
$pkg_file = $pkg_path.$pkg_gitname;
|
||||
$pkg_url = array_values($pkg_matches)[0]['download_url'];
|
||||
$pkg_sha1 = array_values($pkg_matches)[0]['sha'];
|
||||
if (!$pkg_download_status) { //if package is not downloaded
|
||||
|
||||
logger('Downloading '.$pkg_gitname.' package...', $argq);
|
||||
|
||||
get_file_from_url($pkg_file, $pkg_url);
|
||||
|
||||
if (file_check_sha1($pkg_file, $pkg_sha1))
|
||||
logger($pkg_gitname.' package downloaded sucessfully!', $argq);
|
||||
else{
|
||||
if(is_file($pkg_file))
|
||||
if (file_check_sha1($pkg_file, $pkg_sha1)){
|
||||
logger($pkg_gitname.' package download sucessful!', $argq);
|
||||
}else{
|
||||
unlink($pkg_file);
|
||||
logger($pkg_gitname.' package download failed!', $argq);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$pkg_install_status) {
|
||||
if (!$pkg_install_status) { // if package is not installed
|
||||
$pkg_msg = 'Installing';
|
||||
$pkg_cmd = 'upgradepkg --install-new '.$pkg_path.$pkg_name.'* 2>&1';
|
||||
}
|
||||
} else if ($pkg_pref == 'no' && $pkg_install_status && $argu) {
|
||||
if($plugins){
|
||||
logger("Unable to uninstall $pkg_name",$argq);
|
||||
logger("$pkg_name in use by another plugin, not uninstalled.",$argq);
|
||||
}else{
|
||||
$pkg_msg = 'Uninstalling';
|
||||
$pkg_cmd = 'removepkg '.$pkg_path.$pkg_name.'* 2>&1';
|
||||
|
@ -119,9 +117,18 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
|
|||
shell_exec($pkg_cmd);
|
||||
//$output = shell_exec($pkg_cmd);
|
||||
//logger($output);
|
||||
} else {
|
||||
if ($pkg_pref == 'yes')
|
||||
logger("$pkg_name package up to date", $argq);
|
||||
}else{
|
||||
if ($pkg_pref == 'yes'){
|
||||
if (file_exists($pkg_file)){
|
||||
if (file_check_sha1($pkg_file, $pkg_sha1))
|
||||
logger($pkg_gitname.' package up to date, checksum ok.', $argq);
|
||||
else{
|
||||
unlink($pkg_file);
|
||||
logger($pkg_gitname.' package checksum failed! package deleted.', $argq);
|
||||
}
|
||||
}else
|
||||
logger($pkg_gitname.' package missing!', $argq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user