1 |
diff -Nur --no-dereference smeserver-cacti-1.1.19.old/createlinks smeserver-cacti-1.1.19/createlinks |
diff -Nur --no-dereference smeserver-cacti-1.1.19.old/createlinks smeserver-cacti-1.1.19/createlinks |
2 |
--- smeserver-cacti-1.1.19.old/createlinks 2014-06-16 11:53:01.000000000 -0400 |
--- 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 |
|
|
@@ -5,6 +5,7 @@ |
|
|
for my $event (qw( |
|
|
post-upgrade |
|
|
bootstrap-console-save |
|
|
+ console-save |
|
|
)) |
|
|
{ |
|
|
templates2events("/etc/cacti/db.php", $event); |
|
|
@@ -22,3 +23,26 @@ |
|
|
} |
|
|
|
|
|
templates2events("/etc/e-smith/sql/init/80cacti", "post-upgrade"); |
|
|
+ |
|
|
+my $event="smeserver-cacti-update"; |
|
|
+event_templates($event, qw( |
|
|
+ /etc/cacti/db.php |
|
|
+ /etc/httpd/conf/httpd.conf |
|
|
+ /etc/crontab |
|
|
+ /etc/opt/remi/php74/php-fpm.d/www.conf |
|
|
+ /etc/e-smith/sql/init/80cacti |
|
|
+)); |
|
|
+ |
|
|
+event_services($event, |
|
|
+ 'crond' => 'restart', |
|
|
+ 'mysql.init' => 'restart', |
|
|
+ 'httpd-e-smith' => 'sigusr1', |
|
|
+ 'php74-php-fpm' => 'reload-or-restart' |
|
|
+); |
|
|
+ |
|
|
+#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-26 00:51:52.311000000 -0400 |
|
|
@@ -0,0 +1,45 @@ |
|
|
+{ |
|
|
+ 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); |
|
|
+ } |
|
|
+ |
|
|
+ |
|
|
+ |
|
|
+} |
|
|
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 |
|
|
@@ -0,0 +1,68 @@ |
|
|
+{ |
|
|
+ |
|
|
+if ($PHP_VERSION eq '74'){ |
|
|
+ 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'); |
|
|
+ $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"; |
|
|
+ my $id = 'cacti'; |
|
|
+ my $max_children = $cacti{'PHPmaxChildren'} || 20; |
|
|
+ my $min_spare_servers = $cacti{'PHPminServers'} || 4; |
|
|
+ my $start_servers = $cacti{'PHPstartServers'} || 6; |
|
|
+ my $max_spare_servers = $cacti{'PHPmaxServers'} || 8; |
|
|
+ my $max_requests = $cacti{'PHPmaxRequests'} || 1000; |
|
|
+ $min_spare_servers = ( $min_spare_servers > $max_spare_servers ) ? printf("%.0f",$max_spare_servers/2) : $min_spare_servers; |
|
|
+ $start_servers = ( $start_servers > $max_spare_servers ) ? printf("%.0f", $max_spare_servers /2 + $min_spare_servers/2 ) : $start_servers; |
|
|
+ |
|
|
+ $OUT .=<<_EOF; |
|
|
+ |
|
|
+[php$PHP_VERSION-$id] |
|
|
+user = www |
|
|
+group = www |
|
|
+listen.owner = root |
|
|
+listen.group = www |
|
|
+listen.mode = 0660 |
|
|
+listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock |
|
|
+pm = dynamic |
|
|
+pm.max_children = $max_children |
|
|
+pm.start_servers = $start_servers |
|
|
+pm.min_spare_servers = $min_spare_servers |
|
|
+pm.max_spare_servers = $max_spare_servers |
|
|
+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[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 |
|
|
+php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f php@{ $DomainName } |
|
|
+php_admin_flag[display_errors] = off |
|
|
+php_admin_flag[log_errors] = on |
|
|
+php_admin_value[error_log] = syslog |
|
|
+php_admin_value[memory_limit] = $memory_limit |
|
|
+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_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 |
|
|
+ |
|
|
+_EOF |
|
|
+ |
|
|
+ } |
|
|
+ else{ |
|
|
+ $OUT .= '; Nextcloud is disabled'; |
|
|
+ } |
|
|
+} |
|
|
+} |
|
|
+ |
|
|
+ |
|
|
+ |
|
|
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 |
|
3 |
+++ smeserver-cacti-1.1.19/createlinks 2022-07-27 14:55:50.939000000 -0400 |
+++ smeserver-cacti-1.1.19/createlinks 2022-07-27 14:55:50.939000000 -0400 |
4 |
@@ -5,6 +5,7 @@ |
@@ -5,6 +5,7 @@ |
5 |
for my $event (qw( |
for my $event (qw( |
9 |
)) |
)) |
10 |
{ |
{ |
11 |
templates2events("/etc/cacti/db.php", $event); |
templates2events("/etc/cacti/db.php", $event); |
12 |
@@ -22,3 +23,32 @@ |
@@ -22,3 +23,35 @@ |
13 |
} |
} |
14 |
|
|
15 |
templates2events("/etc/e-smith/sql/init/80cacti", "post-upgrade"); |
templates2events("/etc/e-smith/sql/init/80cacti", "post-upgrade"); |
19 |
+ /etc/cacti/db.php |
+ /etc/cacti/db.php |
20 |
+ /etc/httpd/conf/httpd.conf |
+ /etc/httpd/conf/httpd.conf |
21 |
+ /etc/crontab |
+ /etc/crontab |
22 |
|
+ /etc/my.cnf |
23 |
+ /etc/opt/remi/php74/php-fpm.d/www.conf |
+ /etc/opt/remi/php74/php-fpm.d/www.conf |
24 |
+ /etc/e-smith/sql/init/80cacti |
+ /etc/e-smith/sql/init/80cacti |
25 |
+)); |
+)); |
27 |
+event_services($event, |
+event_services($event, |
28 |
+ 'crond' => 'restart', |
+ 'crond' => 'restart', |
29 |
+ 'mysql.init' => 'restart', |
+ 'mysql.init' => 'restart', |
30 |
|
+ 'mariadb' => 'restart', |
31 |
+ 'httpd-e-smith' => 'sigusr1', |
+ 'httpd-e-smith' => 'sigusr1', |
32 |
+ 'php74-php-fpm' => 'reload-or-restart' |
+ 'php74-php-fpm' => 'reload-or-restart' |
33 |
+); |
+); |
34 |
+ |
+ |
35 |
+event_actions($event, |
+event_actions($event, |
36 |
+'cacti-conf' => '50', |
+'cacti-conf' => '2', |
37 |
|
+'cacti-install' => '94', |
38 |
+'cacti-ldap' => '95' |
+'cacti-ldap' => '95' |
39 |
+); |
+); |
40 |
+ |
+ |
139 |
+#/sbin/e-smith/config getprop php74 MemoryLimit 1>/dev/null || ( config setprop php74 MemoryLimit 800M ; echo "setting php74 memory_limit 800M" ; psomething=1) |
+#/sbin/e-smith/config getprop php74 MemoryLimit 1>/dev/null || ( config setprop php74 MemoryLimit 800M ; echo "setting php74 memory_limit 800M" ; psomething=1) |
140 |
+# install detect cli for php not php74 even if $php_path is set |
+# install detect cli for php not php74 even if $php_path is set |
141 |
+ |
+ |
142 |
+[ $something == 1 ] && /usr/sbin/e-smith/expand-template /etc/my.cnf && /usr/bin/systemctl restart mariadb.service |
+#[ $something == 1 ] && /sbin/e-smith/expand-template /etc/my.cnf |
143 |
+#[ $psomething == 1 ] && /usr/sbin/e-smith/expand-template /etc/opt/remi/php74/php.ini && /usr/bin/systemctl restart php74-php-fpm.service |
+#[ $psomething == 1 ] && /usr/sbin/e-smith/expand-template /etc/opt/remi/php74/php.ini && /usr/bin/systemctl restart php74-php-fpm.service |
144 |
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 |
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 |
145 |
--- 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.old/root/etc/e-smith/events/actions/cacti-ldap 1969-12-31 19:00:00.000000000 -0500 |
427 |
fi |
fi |
428 |
/usr/bin/mysql <<EOF |
/usr/bin/mysql <<EOF |
429 |
- CREATE DATABASE $db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; |
- CREATE DATABASE $db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; |
430 |
+ CREATE DATABASE $db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8_unicode_ci; |
+ CREATE DATABASE $db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
431 |
use $db; |
use $db; |
432 |
use mysql; |
use mysql; |
433 |
GRANT ALL PRIVILEGES ON $db.* TO $user\@localhost |
GRANT ALL PRIVILEGES ON $db.* TO $user\@localhost |
567 |
+UID="root" |
+UID="root" |
568 |
GID="www" |
GID="www" |
569 |
PERMS=0640 |
PERMS=0640 |
570 |
|
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 |
571 |
|
--- smeserver-cacti-1.1.19.old/root/etc/e-smith/templates/etc/my.cnf/020cacti 1969-12-31 19:00:00.000000000 -0500 |
572 |
|
+++ smeserver-cacti-1.1.19/root/etc/e-smith/templates/etc/my.cnf/020cacti 2022-07-27 17:18:19.452000000 -0400 |
573 |
|
@@ -0,0 +1,4 @@ |
574 |
|
+#for cacti use |
575 |
|
+innodb_buffer_pool_size=483M |
576 |
|
+innodb_additional_mem_pool_size=80M |
577 |
|
+innodb_flush_log_at_trx_commit=2 |
578 |
|
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 |
579 |
|
--- smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-install 1969-12-31 19:00:00.000000000 -0500 |
580 |
|
+++ smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-install 2022-07-28 00:00:45.319000000 -0400 |
581 |
|
@@ -0,0 +1,17 @@ |
582 |
|
+#!/bin/bash |
583 |
|
+ |
584 |
|
+# move to cli dir |
585 |
|
+cd /usr/share/cacti/cli |
586 |
|
+ |
587 |
|
+#install, we put away, it seems that inside the event it just do not work |
588 |
|
+/usr/bin/php74 install_cacti.php --accept-eula --install --path=php_binary:/usr/bin/php74 & |
589 |
|
+pids=$! ; wait $pid; |
590 |
|
+ |
591 |
|
+ |
592 |
|
+#TODO: |
593 |
|
+#--automationmode |
594 |
|
+#--automationrange with LAN if server-gateway; or only interface if server only |
595 |
|
+#--lang (using an array between cacti option and system language) |
596 |
|
+# using this to set ldap ? --ldap:dn:... |
597 |
|
+# do we need a --mode=upgrade and a --mode=install |
598 |
|
+ |
599 |
|
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 |
600 |
|
--- smeserver-cacti-1.1.19.old/root/etc/e-smith/events/actions/cacti-ldap 2022-07-27 22:43:12.847000000 -0400 |
601 |
|
+++ smeserver-cacti-1.1.19/root/etc/e-smith/events/actions/cacti-ldap 2022-07-27 23:58:46.807000000 -0400 |
602 |
|
@@ -19,24 +19,25 @@ |
603 |
|
#ldap_group_require 'on' or '' |
604 |
|
# then set our admin password |
605 |
|
/usr/bin/mysql <<EOF |
606 |
|
-UPDATE ${db}.settings SET value='memberUid' WHERE name='ldap_group_attrib'; |
607 |
|
-UPDATE ${db}.settings SET value='uid=cactigroup,ou=Groups,$DN' WHERE name='ldap_group_dn'; |
608 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_group_attrib','memberUid') ; |
609 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_group_dn','uid=cactigroup,ou=Groups,$DN') ; |
610 |
|
|
611 |
|
-UPDATE ${db}.settings SET value='0' WHERE name='ldap_tls_certificate'; |
612 |
|
-UPDATE ${db}.settings SET value='3' WHERE name='ldap_version'; |
613 |
|
-UPDATE ${db}.settings SET value='localhost' WHERE name='ldap_server'; |
614 |
|
-UPDATE ${db}.settings SET value='objectClass=inetOrgPerson' WHERE name='ldap_search_filter'; |
615 |
|
-UPDATE ${db}.settings SET value='ou=Users,$DN' WHERE name='ldap_search_base'; |
616 |
|
-UPDATE ${db}.settings SET value='0' WHERE name='ldap_referrals'; |
617 |
|
-UPDATE ${db}.settings SET value='636' WHERE name='ldap_port_ssl'; |
618 |
|
-UPDATE ${db}.settings SET value='389' WHERE name='ldap_port'; |
619 |
|
-UPDATE ${db}.settings SET value='0' WHERE name='ldap_mode'; |
620 |
|
-UPDATE ${db}.settings SET value='0' WHERE name='ldap_encryption'; |
621 |
|
-UPDATE ${db}.settings SET value='uid=<username>,ou=Users,$DN' WHERE name='ldap_dn'; |
622 |
|
-UPDATE ${db}.settings SET value='3' WHERE name='auth_method'; |
623 |
|
-UPDATE ${db}.settings SET value='cn' WHERE name='cn_full_name'; |
624 |
|
-UPDATE ${db}.settings SET value='mail' WHERE name='cn_email'; |
625 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_tls_certificate','0') ; |
626 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_version','3') ; |
627 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_server','localhost') ; |
628 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_search_filter','objectClass=inetOrgPerson') ; |
629 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_search_base','ou=Users,$DN') ; |
630 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_referrals','0') ; |
631 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_port_ssl','636') ; |
632 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_port','389') ; |
633 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_mode','0') ; |
634 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_encryption','0') ; |
635 |
|
+REPLACE INTO ${db}.settings VALUES ('ldap_dn','uid=<username>,ou=Users,$DN') ; |
636 |
|
+REPLACE INTO ${db}.settings VALUES ('auth_method','3') ; |
637 |
|
+REPLACE INTO ${db}.settings VALUES ('cn_full_name','cn') ; |
638 |
|
+REPLACE INTO ${db}.settings VALUES ('cn_email','mail') ; |
639 |
|
|
640 |
|
+REPLACE INTO ${db}.settings VALUES ('user_template','3'); |
641 |
|
|
642 |
|
# set password of admin |
643 |
|
UPDATE ${db}.user_auth SET email_address='admin@${domain}', must_change_password='',password=md5('$adminpass'), enabled='on' WHERE username='admin' and id='1'; |