mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Send to PHP 71/Python2 support branch
This commit is contained in:
34
daily.php
34
daily.php
@@ -172,15 +172,13 @@ if ($options['f'] === 'handle_notifiable') {
|
||||
}
|
||||
} elseif ($options['t'] === 'phpver') {
|
||||
$error_title = 'Error: PHP version too low';
|
||||
$warn_title = 'Warning: PHP version too low';
|
||||
remove_notification($warn_title); // remove warning
|
||||
|
||||
// if update is not set to false and version is min or newer
|
||||
if (Config::get('update') && $options['r']) {
|
||||
if ($options['r'] === 'php53') {
|
||||
$phpver = '5.6.4';
|
||||
$eol_date = 'January 10th, 2018';
|
||||
} elseif ($options['r'] === 'php56') {
|
||||
} elseif ($options['r'] === 'php56' || $options['r'] === 'php71') {
|
||||
$phpver = Php::PHP_MIN_VERSION;
|
||||
$eol_date = Php::PHP_MIN_VERSION_DATE;
|
||||
}
|
||||
@@ -195,6 +193,32 @@ if ($options['f'] === 'handle_notifiable') {
|
||||
}
|
||||
}
|
||||
|
||||
remove_notification($error_title);
|
||||
exit(0);
|
||||
} elseif ($options['t'] === 'pythonver') {
|
||||
$error_title = 'Error: Python requirements not met';
|
||||
|
||||
// if update is not set to false and version is min or newer
|
||||
if (Config::get('update') && $options['r']) {
|
||||
if ($options['r'] === 'python3-missing') {
|
||||
new_notification(
|
||||
$error_title,
|
||||
"Python 3 is required to run LibreNMS as of May, 2020. You need to install Python 3 to continue to receive updates. If you do not install Python 3 and required packages, LibreNMS will continue to function but stop receiving bug fixes and updates.",
|
||||
2,
|
||||
'daily.sh'
|
||||
);
|
||||
exit(1);
|
||||
} elseif ($options['r'] === 'python3-deps') {
|
||||
new_notification(
|
||||
$error_title,
|
||||
"Python 3 dependencies are missing. You need to install them via pip3 install -r requirements.txt or system packages to continue to receive updates. If you do not install Python 3 and required packages, LibreNMS will continue to function but stop receiving bug fixes and updates.",
|
||||
2,
|
||||
'daily.sh'
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
remove_notification($error_title);
|
||||
exit(0);
|
||||
}
|
||||
@@ -219,7 +243,7 @@ if ($options['f'] === 'bill_data') {
|
||||
$table = 'bill_data';
|
||||
$sql = "DELETE bill_data
|
||||
FROM bill_data
|
||||
INNER JOIN (SELECT bill_id,
|
||||
INNER JOIN (SELECT bill_id,
|
||||
SUBDATE(
|
||||
SUBDATE(
|
||||
ADDDATE(
|
||||
@@ -242,7 +266,7 @@ if ($options['f'] === 'alert_log') {
|
||||
WHERE alerts.state=0 AND alert_log.time_logged < DATE_SUB(NOW(),INTERVAL ? DAY)
|
||||
";
|
||||
lock_and_purge_query($table, $sql, $msg);
|
||||
|
||||
|
||||
# alert_log older than $config['alert_log_purge'] days match now only the alert_log of active alerts
|
||||
# in case of flapping of an alert, many entries are kept in alert_log
|
||||
# we want only to keep the last alert_log that contains the alert details
|
||||
|
||||
69
daily.sh
69
daily.sh
@@ -120,31 +120,61 @@ set_notifiable_result() {
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Check the PHP version and branch and switch to the appropriate branch
|
||||
# Check the PHP and Python version and branch and switch to the appropriate branch
|
||||
# Returns:
|
||||
# Exit-Code: 0 >= min ver, 1 < min ver
|
||||
#######################################
|
||||
check_php_ver() {
|
||||
check_dependencies() {
|
||||
local branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
scripts/check_requirements.py > /dev/null 2>&1 || pip3 install -r requirements.txt > /dev/null 2>&1
|
||||
|
||||
local ver_56=$(php -r "echo (int)version_compare(PHP_VERSION, '5.6.4', '<');")
|
||||
local ver_71=$(php -r "echo (int)version_compare(PHP_VERSION, '7.1.3', '<');")
|
||||
if [[ "$branch" == "php53" ]] && [[ "$ver_56" == "0" ]]; then
|
||||
status_run "Supported PHP version, switched back to master branch." 'git checkout master'
|
||||
branch="master"
|
||||
elif [[ "$branch" == "php56" ]] && [[ "$ver_71" == "0" ]]; then
|
||||
status_run "Supported PHP version, switched back to master branch." 'git checkout master'
|
||||
branch="master"
|
||||
elif [[ "$branch" != "php53" ]] && [[ "$ver_56" == "1" ]]; then
|
||||
status_run "Unsupported PHP version, switched to php53 branch." 'git checkout php53'
|
||||
branch="php53"
|
||||
elif [[ "$branch" != "php56" ]] && [[ "$ver_71" == "1" ]]; then
|
||||
status_run "Unsupported PHP version, switched to php56 branch." 'git checkout php56'
|
||||
branch="php56"
|
||||
local ver_72=$(php -r "echo (int)version_compare(PHP_VERSION, '7.2.5', '<');")
|
||||
local python3=$(python3 -c "import sys;print(int(sys.version_info < (3, 5)))" 2> /dev/null)
|
||||
local python_deps=$(scripts/check_requirements.py > /dev/null 2>&1; echo $?)
|
||||
local phpver="master"
|
||||
local pythonver="master"
|
||||
|
||||
local old_branches="php53 php56 php71-python2"
|
||||
if [[ " $old_branches " =~ " $branch " ]] && [[ "$ver_72" == "0" && "$python3" == "0" && "$python_deps" == "0" ]]; then
|
||||
status_run "Supported PHP and Python version, switched back to master branch." 'git checkout master'
|
||||
elif [[ "$ver_56" != "0" ]]; then
|
||||
phpver="php53"
|
||||
if [[ "$branch" != "php53" ]]; then
|
||||
status_run "Unsupported PHP version, switched to php53 branch." 'git checkout php53'
|
||||
fi
|
||||
elif [[ "$ver_71" != "0" ]]; then
|
||||
phpver="php56"
|
||||
if [[ "$branch" != "php56" ]]; then
|
||||
status_run "Unsupported PHP version, switched to php56 branch." 'git checkout php56'
|
||||
fi
|
||||
elif [[ "$ver_72" != "0" || "$python3" != "0" || "$python_deps" != "0" ]]; then
|
||||
local msg=""
|
||||
if [[ "$ver_72" != "0" ]]; then
|
||||
msg="Unsupported PHP version, $msg"
|
||||
phpver="php71"
|
||||
fi
|
||||
if [[ "$python3" != "0" ]]; then
|
||||
msg="python3 is not available, $msg"
|
||||
pythonver="python3-missing"
|
||||
elif [[ "$python_deps" != "0" ]]; then
|
||||
msg="Python 3 dependencies missing, $msg"
|
||||
pythonver="python3-deps"
|
||||
fi
|
||||
|
||||
if [[ "$branch" != "php71-python2" ]]; then
|
||||
status_run "${msg}switched to php71-python2 branch." 'git checkout php71-python2'
|
||||
fi
|
||||
fi
|
||||
|
||||
set_notifiable_result phpver ${branch}
|
||||
set_notifiable_result phpver ${phpver}
|
||||
set_notifiable_result pythonver ${pythonver}
|
||||
|
||||
return ${ver_res};
|
||||
if [[ "$phpver" == "master" && "$pythonver" == "master" ]]; then
|
||||
return 0;
|
||||
fi
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +222,7 @@ main () {
|
||||
exit
|
||||
fi
|
||||
|
||||
check_php_ver
|
||||
check_dependencies
|
||||
php_ver_ret=$?
|
||||
|
||||
# make sure the vendor directory is clean
|
||||
@@ -234,6 +264,9 @@ main () {
|
||||
status_run 'Cleaning up DB' "$DAILY_SCRIPT cleanup"
|
||||
;;
|
||||
post-pull)
|
||||
# re-check dependencies after pull with the new code
|
||||
check_dependencies
|
||||
|
||||
# Check for missing vendor dir
|
||||
if [ ! -f vendor/autoload.php ]; then
|
||||
git checkout 609676a9f8d72da081c61f82967e1d16defc0c4e -- vendor/
|
||||
@@ -244,7 +277,7 @@ main () {
|
||||
|
||||
# Check if we need to revert (Must be in post pull so we can update it)
|
||||
if [[ "$old_version" != "$new_version" ]]; then
|
||||
check_php_ver # check php version and switch branches
|
||||
check_dependencies # check php and python version and switch branches
|
||||
|
||||
# new_version may be incorrect if we just switch branches... ignoring that detail
|
||||
status_run "Updated from $old_version to $new_version" ''
|
||||
|
||||
Reference in New Issue
Block a user