54 lines
2.4 KiB
Plaintext
54 lines
2.4 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
# move to cli dir
|
||
|
cd /usr/share/cacti/cli
|
||
|
|
||
|
#install, we put away, it fails in the temp event in yum at first, so here is a dirty hack
|
||
|
/usr/bin/php install_cacti.php &
|
||
|
pids=$!; sleep 3; kill -9 $pids;
|
||
|
/usr/bin/php install_cacti.php --accept-eula --install || exit 0
|
||
|
|
||
|
#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
|
||
|
|
||
|
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 '': user will enable if needed.
|
||
|
# then set our admin password
|
||
|
/usr/bin/mysql <<EOF
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_group_attrib','memberUid') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_group_dn','uid=cactigroup,ou=Groups,$DN') ;
|
||
|
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_tls_certificate','0') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_version','3') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_server','localhost') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_search_filter','objectClass=inetOrgPerson') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_search_base','ou=Users,$DN') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_referrals','0') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_port_ssl','636') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_port','389') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_mode','0') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_encryption','0') ;
|
||
|
REPLACE INTO ${db}.settings VALUES ('ldap_dn','uid=<username>,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 ('path_php_binary','/usr/bin/php74') ;
|
||
|
|
||
|
REPLACE INTO ${db}.settings VALUES ('user_template','3');
|
||
|
|
||
|
# 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';
|
||
|
EOF
|
||
|
|