Avoid zero division on systems with no swap
This commit is contained in:
parent
90f55ceb3d
commit
5b84027803
|
@ -7,10 +7,22 @@ use POSIX;
|
|||
|
||||
my $TOTAL=`vmstat -s | grep "total memory" | awk '{ print $1 } '`;
|
||||
my $FREE=`vmstat -s | grep "free memory" | awk '{ print $1 } '`;
|
||||
my $FREEP=($FREE/$TOTAL)*100;
|
||||
my $FREEP;
|
||||
eval {
|
||||
$FREEP=($FREE/$TOTAL)*100;
|
||||
};
|
||||
if ($@) {
|
||||
$FREEP = 0;
|
||||
}
|
||||
my $STOTAL=`vmstat -s | grep "total swap" | awk '{ print $1 } '`;
|
||||
my $SUSED=`vmstat -s | grep "free swap" | awk '{ print $1 } '`;
|
||||
my $SFREE=($SUSED/$STOTAL)*100;
|
||||
my $SFREE;
|
||||
eval {
|
||||
$SFREE=($SUSED/$STOTAL)*100;
|
||||
};
|
||||
if ($@) {
|
||||
$SFREE = 0;
|
||||
}
|
||||
|
||||
$SFREE = floor($SFREE);
|
||||
$FREEP = floor($FREEP);
|
||||
|
|
|
@ -56,6 +56,9 @@ function rrmdir($dir) {
|
|||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
else {
|
||||
unlink ($dir);
|
||||
}
|
||||
}
|
||||
|
||||
function update_manager_install_package_step2() {
|
||||
|
@ -606,14 +609,19 @@ function update_manager_starting_update() {
|
|||
"/downloads/last_package.tgz";
|
||||
|
||||
$full_path = $config['attachment_store'] . "/downloads/pandora_console";
|
||||
rrmdir($full_path);
|
||||
|
||||
|
||||
|
||||
$phar = new PharData($path_package);
|
||||
ob_start();
|
||||
$result = system("tar xvzf " . $path_package .
|
||||
" -C " . $config['attachment_store'] . "/downloads/", $none);
|
||||
try {
|
||||
$result = $phar->extractTo($config['attachment_store'] . "/downloads/");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo ' There\'s a problem ... -> ' . $e->getMessage();
|
||||
}
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
rrmdir($path_package);
|
||||
|
||||
if ($result != 0) {
|
||||
db_process_sql_update('tconfig',
|
||||
array('value' => json_encode(
|
||||
|
@ -640,7 +648,9 @@ function update_manager_starting_update() {
|
|||
$full_path,
|
||||
$homedir,
|
||||
array('install.php'));
|
||||
|
||||
|
||||
rrmdir($full_path);
|
||||
|
||||
if (!$result) {
|
||||
db_process_sql_update('tconfig',
|
||||
array('value' => json_encode(
|
||||
|
|
Loading…
Reference in New Issue