1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/zabbix_ynh.git synced 2024-09-03 20:36:14 +02:00

Update _common.sh

This commit is contained in:
ericgaspar 2021-09-11 16:16:22 +02:00
parent 4e790910c4
commit 4c74392321

View file

@ -157,12 +157,12 @@ import_template () {
if [ "$importState" -eq "1" ] if [ "$importState" -eq "1" ]
then then
ynh_print_info --message="YunoHost template imported !" ynh_print_info --message="YunoHost template imported!"
else else
ynh_print_warn --message="YunoHost template not imported !" ynh_print_warn --message="YunoHost template not imported!"
fi fi
else else
ynh_print_warn --message="Admin user cannot connect to the interface !" ynh_print_warn --message="Admin user cannot connect to the interface!"
fi fi
} }
@ -177,9 +177,9 @@ link_template () {
applyTemplate=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.massadd","params":{"hosts":[{"hostid":"'"$zabbixHostID"'"}],"templates":[{"templateid":"'"$zabbixTemplateID"'"}]},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result.hostids[]') applyTemplate=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.massadd","params":{"hosts":[{"hostid":"'"$zabbixHostID"'"}],"templates":[{"templateid":"'"$zabbixTemplateID"'"}]},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result.hostids[]')
if [ "$applyTemplate" -eq "$zabbixHostID" ] if [ "$applyTemplate" -eq "$zabbixHostID" ]
then then
ynh_print_info --message="YunoHost template linked to Zabbix server !" ynh_print_info --message="YunoHost template linked to Zabbix server!"
else else
ynh_print_warn --message="YunoHost template not linked to Zabbix server !" ynh_print_warn --message="YunoHost template not linked to Zabbix server!"
fi fi
} }
@ -189,7 +189,7 @@ check_proc_zabbixserver () {
pgrep zabbix_server >/dev/null pgrep zabbix_server >/dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
ynh_print_info --message="Zabbix server is started !" ynh_print_info --message="Zabbix server is started!"
else else
ynh_print_err --message="Zabbix server not started, try to start it with the YunoHost interface." ynh_print_err --message="Zabbix server not started, try to start it with the YunoHost interface."
ynh_print_err --message="If Zabbix server can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues" ynh_print_err --message="If Zabbix server can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
@ -224,10 +224,10 @@ remove_zabbix_repo(){
# Remove previous Zabbix installation # Remove previous Zabbix installation
# #
remove_previous_zabbix () { remove_previous_zabbix () {
ynh_print_info --message="Previous Zabbix installation will be purged !" ynh_print_info --message="Previous Zabbix installation will be purged!"
apt-get purge zabbix* -y apt-get purge zabbix* -y
ynh_secure_remove --file="/var/cache/apt/archives/zabbix-server-mysql*" ynh_secure_remove --file="/var/cache/apt/archives/zabbix-server-mysql*"
ynh_print_info --message="Previous Zabbix installation purged !" ynh_print_info --message="Previous Zabbix installation purged!"
} }
# Update Zabbix configuration initialisation # Update Zabbix configuration initialisation
@ -241,13 +241,13 @@ update_initZabbixConf () {
cp "../conf/etc_zabbix_web_init.zabbix.conf.php.sh" /etc/zabbix/web/init.zabbix.conf.php.sh cp "../conf/etc_zabbix_web_init.zabbix.conf.php.sh" /etc/zabbix/web/init.zabbix.conf.php.sh
chmod 700 /etc/zabbix/web/init.zabbix.conf.php.sh chmod 700 /etc/zabbix/web/init.zabbix.conf.php.sh
cp "../conf/etc_apt_apt.conf.d_100update_force_init_zabbix_frontend_config" /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config cp "../conf/etc_apt_apt.conf.d_100update_force_init_zabbix_frontend_config" /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config
ynh_print_info --message="Zabbix configuration initialisation updated !" ynh_print_info --message="Zabbix configuration initialisation updated!"
} }
# Delete Zabbix configuration initialisation # Delete Zabbix configuration initialisation
# #
delete_initZabbixConf () { delete_initZabbixConf () {
ynh_print_info --message="Delete Zabbix configuration initialisation !" ynh_print_info --message="Delete Zabbix configuration initialisation!"
if [ -f /etc/zabbix/web/init.zabbix.conf.php.sh ] if [ -f /etc/zabbix/web/init.zabbix.conf.php.sh ]
then then
ynh_secure_remove --file="/etc/zabbix/web/init.zabbix.conf.php.sh" ynh_secure_remove --file="/etc/zabbix/web/init.zabbix.conf.php.sh"
@ -256,7 +256,7 @@ delete_initZabbixConf () {
then then
ynh_secure_remove --file="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config" ynh_secure_remove --file="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
fi fi
ynh_print_info --message="Zabbix configuration initialisation deleted !" ynh_print_info --message="Zabbix configuration initialisation deleted!"
} }
# Patch timeout too short for Zabbix agent if needed # Patch timeout too short for Zabbix agent if needed
@ -268,20 +268,20 @@ change_timeoutAgent () {
ynh_replace_string --match_string="# Timeout=3" --replace_string="Timeout=10" --target_file=/etc/zabbix/zabbix_agentd.conf ynh_replace_string --match_string="# Timeout=3" --replace_string="Timeout=10" --target_file=/etc/zabbix/zabbix_agentd.conf
grep -C 2 "Timeout" /etc/zabbix/zabbix_agentd.conf grep -C 2 "Timeout" /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent systemctl restart zabbix-agent
ynh_print_info --message="Zabbix agent timeout updated !" ynh_print_info --message="Zabbix agent timeout updated!"
fi fi
} }
# Update Zabbix database character set # Update Zabbix database character set
# #
convert_ZabbixDB () { convert_ZabbixDB () {
ynh_print_info --message="Zabbix database character set will be updated !" ynh_print_info --message="Zabbix database character set will be updated!"
$mysqlconn -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;" $mysqlconn -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
for t in $($mysqlconn -BN -e "show tables";) for t in $($mysqlconn -BN -e "show tables";)
do do
$mysqlconn -e "ALTER TABLE $t CONVERT TO character set utf8 collate utf8_bin;" $mysqlconn -e "ALTER TABLE $t CONVERT TO character set utf8 collate utf8_bin;"
done done
ynh_print_info --message="Zabbix database character set has been updated !" ynh_print_info --message="Zabbix database character set has been updated!"
} }
# Add email media type with the YunoHost server mail. # Add email media type with the YunoHost server mail.