--- rpms/smeserver-cacti/contribs10/smeserver-cacti-1.1.19-sme10.patch 2022/07/26 04:35:57 1.2 +++ rpms/smeserver-cacti/contribs10/smeserver-cacti-1.1.19-sme10.patch 2022/07/28 03:53:23 1.14 @@ -1,6 +1,6 @@ diff -Nur --no-dereference smeserver-cacti-1.1.19.old/createlinks smeserver-cacti-1.1.19/createlinks --- smeserver-cacti-1.1.19.old/createlinks 2014-06-16 11:53:01.000000000 -0400 -+++ smeserver-cacti-1.1.19/createlinks 2022-07-26 00:15:21.267000000 -0400 ++++ smeserver-cacti-1.1.19/createlinks 2022-07-27 14:55:50.939000000 -0400 @@ -5,6 +5,7 @@ for my $event (qw( post-upgrade @@ -9,7 +9,7 @@ diff -Nur --no-dereference smeserver-cac )) { templates2events("/etc/cacti/db.php", $event); -@@ -22,3 +23,26 @@ +@@ -22,3 +23,35 @@ } templates2events("/etc/e-smith/sql/init/80cacti", "post-upgrade"); @@ -19,6 +19,7 @@ diff -Nur --no-dereference smeserver-cac + /etc/cacti/db.php + /etc/httpd/conf/httpd.conf + /etc/crontab ++ /etc/my.cnf + /etc/opt/remi/php74/php-fpm.d/www.conf + /etc/e-smith/sql/init/80cacti +)); @@ -26,31 +27,419 @@ diff -Nur --no-dereference smeserver-cac +event_services($event, + 'crond' => 'restart', + 'mysql.init' => 'restart', ++ 'mariadb' => 'restart', + 'httpd-e-smith' => 'sigusr1', + 'php74-php-fpm' => 'reload-or-restart' +); + ++event_actions($event, ++'cacti-conf' => '2', ++'cacti-install' => '94', ++'cacti-ldap' => '95' ++); ++ ++ +#backup ? +#use esmith::Build::Backup qw(:all); +#backup_includes("smeserver-cacti", qw( +# +#)); + +diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/db/configuration/migrate/80cacti smeserver-cacti-1.1.19/root/etc/e-smith/db/configuration/migrate/80cacti +--- smeserver-cacti-1.1.19.old/root/etc/e-smith/db/configuration/migrate/80cacti 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/db/configuration/migrate/80cacti 2022-07-27 14:46:58.425000000 -0400 +@@ -0,0 +1,72 @@ ++{ ++ use MIME::Base64 qw(encode_base64); ++ ++ my $service; ++ my $rec; ++ my $pw; ++ ++ # Store the cacti password in the configuration database (if not already there) ++ $service = 'cacti'; ++ ++ $rec = $DB->get($service) || $DB->new_record($service, {type => 'service'}); ++ ++ $pw = $rec->prop('DbPassword'); ++ ++ ++ if (! $pw) ++ { ++ ++ if ( open( RANDOM, "/dev/urandom" ) ) ++ { ++ my $buf; ++ # 57 bytes is a full line of Base64 coding, and contains ++ # 456 bits of randomness - given a perfectly random /dev/random ++ if ( read( RANDOM, $buf, 57 ) != 57 ) ++ { ++ warn("Short read from /dev/random: $!"); ++ } ++ else ++ { ++ $pw = encode_base64($buf); ++ chomp $pw; ++ } ++ close RANDOM; ++ } ++ else ++ { ++ warn "Could not open /dev/urandom: $!"; ++ } ++ ++ $rec->set_prop('DbPassword', $pw); ++ } ++ $pwa = $rec->prop('AdminPassword'); ++ if (! $pwa) ++ { ++ ++ if ( open( RANDOM, "/dev/urandom" ) ) ++ { ++ my $buf; ++ # 57 bytes is a full line of Base64 coding, and contains ++ # 456 bits of randomness - given a perfectly random /dev/random ++ if ( read( RANDOM, $buf, 15 ) != 15 ) ++ { ++ warn("Short read from /dev/random: $!"); ++ } ++ else ++ { ++ $pwa = encode_base64($buf); ++ chomp $pwa; ++ } ++ close RANDOM; ++ } ++ else ++ { ++ warn "Could not open /dev/urandom: $!"; ++ } ++ ++ $rec->set_prop('AdminPassword', $pwa); ++ } ++ ++ ++ ++} +diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-conf smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-conf +--- smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-conf 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-conf 2022-07-27 14:46:58.891000000 -0400 +@@ -0,0 +1,16 @@ ++#!/bin/bash ++ ++#easy configuration of what is needed for cacti to work correctly ++something=0; ++psomething=0; ++#check if something already set, if not let's do it ++ ++/sbin/e-smith/config getprop mariadb TmpTableSize 1>/dev/null || ( config setprop mariadb TmpTableSize 32M ; echo "setting mariadb TmpTableSize 32M" ; something=1) ++/sbin/e-smith/config getprop mariadb MaxHeapTableSize 1>/dev/null || ( config setprop mariadb MaxHeapTableSize 32M ; echo "setting mariadb MaxHeapTableSize 32M" ; something=1) ++/sbin/e-smith/config getprop mariadb JoinBufferSize 1>/dev/null || ( config setprop mariadb JoinBufferSize 62M ; echo "setting mariadb JoinBufferSize 62M" ; something=1) ++ ++#/sbin/e-smith/config getprop php74 MemoryLimit 1>/dev/null || ( config setprop php74 MemoryLimit 800M ; echo "setting php74 memory_limit 800M" ; psomething=1) ++# install detect cli for php not php74 even if $php_path is set ++ ++#[ $something == 1 ] && /sbin/e-smith/expand-template /etc/my.cnf ++#[ $psomething == 1 ] && /usr/sbin/e-smith/expand-template /etc/opt/remi/php74/php.ini && /usr/bin/systemctl restart php74-php-fpm.service +diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-ldap smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-ldap +--- smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-ldap 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-ldap 2022-07-27 14:46:58.663000000 -0400 +@@ -0,0 +1,44 @@ ++#!/bin/bash ++ ++#use esmith::ConfigDB; ++#use esmith::util; ++#my $cdb = esmith::ConfigDB->open_ro(); ++#my $domain = $cdb->get_value('DomainName'); ++#my $baseDN = esmith::util::ldapBase($cdb->get_value('DomainName')); ++#print $baseDN . "\n"; ++ ++db=$(config getprop cacti DbDatabase || echo 'cacti_sme'); ++user=$(config getprop cacti DbUser || echo 'cacti'); ++pass=$(config getprop cacti DbPassword || echo 'changeme'); ++adminpass=$(config getprop cacti AdminPassword || echo 'changeme'); ++domain=$(config get DomainName) ++DN=$(perl -Mesmith::util -e "print esmith::util::ldapBase(\"$domain\");") ++ ++ ++# set ldap auth with optional group ++#ldap_group_require 'on' or '' ++# then set our admin password ++/usr/bin/mysql < diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/templates/etc/e-smith/sql/init/80cacti smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/e-smith/sql/init/80cacti --- smeserver-cacti-1.1.19.old/root/etc/e-smith/templates/etc/e-smith/sql/init/80cacti 2019-12-11 14:46:28.000000000 -0500 -+++ smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/e-smith/sql/init/80cacti 2022-07-26 00:29:43.464000000 -0400 -@@ -3,7 +3,7 @@ ++++ smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/e-smith/sql/init/80cacti 2022-07-27 14:46:55.114000000 -0400 +@@ -1,22 +1,34 @@ + { +- my $db = $cacti{DbName} || 'cacti_sme'; ++ my $db = $cacti{DbDatabase} || 'cacti_sme'; my $user = $cacti{DbUser} || 'cacti'; my $pass = $cacti{DbPassword} || 'changeme'; $OUT .= </dev/null |/usr/bin/mysql mysql - /usr/bin/mysql $db < /etc/e-smith/db/configuration/migrate/80cacti_sme.sql +- /usr/bin/mysql $db < /etc/e-smith/db/configuration/migrate/80cacti_sme.sql ++ /usr/bin/mysql $db < \$(rpm -ql cacti|grep cacti.sql) ++ #/usr/bin/mysql $db < /etc/e-smith/db/configuration/migrate/80cacti_sme.sql END -} \ Pas de fin de ligne à la fin du fichier @@ -100,7 +489,7 @@ diff -Nur --no-dereference smeserver-cac diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15cacti smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15cacti --- smeserver-cacti-1.1.19.old/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15cacti 1969-12-31 19:00:00.000000000 -0500 -+++ smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15cacti 2022-07-26 00:03:45.335000000 -0400 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15cacti 2022-07-27 14:46:55.335000000 -0400 @@ -0,0 +1,68 @@ +{ + @@ -108,10 +497,10 @@ diff -Nur --no-dereference smeserver-cac + if (($cacti{'status'} || 'disabled') eq 'enabled'){ + my $max_upload_size = ($cacti{MaxUploadSize} || '4096'); + $max_upload_size .= 'M' if ($max_upload_size =~ m/^\d+$/); -+ my $memory_limit = ($cacti{MemoryLimit} || '512M'); ++ my $memory_limit = ($cacti{MemoryLimit} || '5555500M'); + $memory_limit .= 'M' if ($memory_limit =~ m/^\d+$/); + my $open_basedir= $cacti{PHPBaseDir} || ''; -+ $open_basedir = "/usr/share/cacti:/var/lib/cacti:/var/log/cacti.log:/var/lib/php/cacti:/home/e-smith/files/cacti:/dev/urandom:/proc/meminfo:$open_basedir"; ++ $open_basedir = "/tmp/:/share/:/var/log/cacti:/etc/cacti/db.php:/usr/share/cacti:/var/lib/cacti:/var/log/cacti.log:/var/lib/php/cacti:/home/e-smith/files/cacti:/dev/urandom:/proc/meminfo:$open_basedir"; + my $id = 'cacti'; + my $max_children = $cacti{'PHPmaxChildren'} || 20; + my $min_spare_servers = $cacti{'PHPminServers'} || 4; @@ -138,7 +527,7 @@ diff -Nur --no-dereference smeserver-cac +pm.max_requests = $max_requests +php_admin_value[session.save_path] = /var/lib/php/$id/session +php_admin_value[session.gc_maxlifetime] = 86400 -+php_admin_value[opcache.file_cache] = /var/lib/php/$id/opcache ++;php_admin_value[opcache.file_cache] = /var/lib/php/$id/opcache +php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp +php_admin_value[error_log] = /var/log/php/$id/error.log +slowlog = /var/log/php/cacti/slow.log @@ -150,23 +539,104 @@ diff -Nur --no-dereference smeserver-cac +php_admin_value[max_execution_time] = 3600 +php_admin_value[post_max_size] = $max_upload_size +php_admin_value[upload_max_filesize] = $max_upload_size -+php_admin_value[disable_functions] = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd -+php_admin_value[open_basedir] = $open_basedir ++;php_admin_value[disable_functions] = system, show_source, symlink, dl, passthru, phpinfo, escapeshellarg, escapeshellcmd ++;php_admin_value[open_basedir] = $open_basedir +php_admin_flag[allow_url_fopen] = on +php_admin_flag[file_upload] = on -+php_admin_flag[session.cookie_httponly] = on -+php_admin_flag[allow_url_include] = off -+php_admin_value[session.save_handler] = files -+php_admin_flag[output_buffering] = off ++;php_admin_flag[session.cookie_httponly] = on ++;php_admin_flag[allow_url_include] = off ++;php_admin_value[session.save_handler] = files ++;php_admin_flag[output_buffering] = off + +_EOF + + } + else{ -+ $OUT .= '; Nextcloud is disabled'; ++ $OUT .= '; Cacti is disabled'; + } +} +} + + + +diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/templates.metadata/etc/cacti/db.php smeserver-cacti-1.1.19/root/etc/e-smith/templates.metadata/etc/cacti/db.php +--- smeserver-cacti-1.1.19.old/root/etc/e-smith/templates.metadata/etc/cacti/db.php 2014-06-16 11:53:01.000000000 -0400 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/templates.metadata/etc/cacti/db.php 2022-07-26 00:44:20.988000000 -0400 +@@ -1,3 +1,3 @@ +-UID="cacti" ++UID="root" + GID="www" + PERMS=0640 +diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/templates/etc/my.cnf/020cacti smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/my.cnf/020cacti +--- smeserver-cacti-1.1.19.old/root/etc/e-smith/templates/etc/my.cnf/020cacti 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/my.cnf/020cacti 2022-07-27 17:18:19.452000000 -0400 +@@ -0,0 +1,4 @@ ++#for cacti use ++innodb_buffer_pool_size=483M ++innodb_additional_mem_pool_size=80M ++innodb_flush_log_at_trx_commit=2 +diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-install smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-install +--- smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-install 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-install 2022-07-27 23:05:44.866000000 -0400 +@@ -0,0 +1,1666666 @@ ++#!/bin/bash ++ ++# move to cli dir ++cd /usr/share/cacti/cli ++ ++#install ++/usr/bin/php74 install_cacti.php --accept-eula --install --path=php_binary:/usr/bin/php74 & ++ pids=$! ; wait $pid; ++ ++#TODO: ++#--automationmode ++#--automationrange with LAN if server-gateway; or only interface if server only ++#--lang (using an array between cacti option and system language) ++# using this to set ldap ? --ldap:dn:... ++# do we need a --mode=upgrade and a --mode=install ++ +diff -Nur --no-dereference smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-ldap smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-ldap +--- smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-ldap 2022-07-27 22:43:12.847000000 -0400 ++++ smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-ldap 2022-07-27 23:05:44.637000000 -0400 +@@ -19,24 +19,25 @@ + #ldap_group_require 'on' or '' + # then set our admin password + /usr/bin/mysql <,ou=Users,$DN') ; ++REPLACE INTO ${db}.settings VALUES ('auth_method','3') ; ++REPLACE INTO ${db}.settings VALUES ('cn_full_name','cn') ; ++REPLACE INTO ${db}.settings VALUES ('cn_email','mail') ; + ++REPLACE INTO ${db}.settings VALUES ('user_template','3') ON DUPLICATE KEY UPDATE name='user_template'; + + # set password of admin + UPDATE ${db}.user_auth SET email_address='admin@${domain}', must_change_password='',password=md5('$adminpass'), enabled='on' WHERE username='admin' and id='1';