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

Update install

This commit is contained in:
Mickael-Martin 2019-01-30 13:54:29 +01:00
parent 32e4130d9c
commit f23f89722e

View file

@ -388,17 +388,17 @@ cp $confUserPpath /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf
cp $bashUserPpath /etc/zabbix/zabbix_agentd.d/yunohost.sh cp $bashUserPpath /etc/zabbix/zabbix_agentd.d/yunohost.sh
chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh
curl -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \
--form enter=Sign+in \ --form enter=Sign+in \
--form name=Admin \ --form name=Admin \
--form password=zabbix \ --form password=zabbix \
"$zabbixFullpath/index.php" "$zabbixFullpath/index.php"
sid=$(curl -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ sid=$(curl-k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \
"$zabbixFullpath/conf.import.php?rules_preset=template" \ "$zabbixFullpath/conf.import.php?rules_preset=template" \
| grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' ) | grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' )
importState=$(curl -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ importState=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \
--form "config=1" \ --form "config=1" \
--form "import_file=@$localpath" \ --form "import_file=@$localpath" \
--form rules[groups][createMissing]=1 \ --form rules[groups][createMissing]=1 \
@ -433,10 +433,10 @@ else
fi fi
#apply template to host #apply template to host
tokenapi=$(curl -s --header "Content-Type: application/json" --request POST --data '{ "jsonrpc": "2.0","method": "user.login","params": {"user": "Admin","password": "zabbix"},"id": 1,"auth": null}' ${zabbixFullpath}/api_jsonrpc.php | jq -r '.result') tokenapi=$(curl -k -s --header "Content-Type: application/json" --request POST --data '{ "jsonrpc": "2.0","method": "user.login","params": {"user": "Admin","password": "zabbix"},"id": 1,"auth": null}' ${zabbixFullpath}/api_jsonrpc.php | jq -r '.result')
zabbixHostID=$(curl -s --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.get","params":{"filter":{"host":["Zabbix server"]}},"auth":"'$tokenapi'","id":1}' ${zabbixFullpath}/api_jsonrpc.php | jq -r '.result[0].hostid') zabbixHostID=$(curl -k -s --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.get","params":{"filter":{"host":["Zabbix server"]}},"auth":"'$tokenapi'","id":1}' ${zabbixFullpath}/api_jsonrpc.php | jq -r '.result[0].hostid')
zabbixTemplateID=$(curl -s --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"template.get","params":{"filter":{"host":["Template Yunohost"]}},"auth":"'$tokenapi'","id":1}' ${zabbixFullpath}/api_jsonrpc.php | jq -r '.result[0].templateid') zabbixTemplateID=$(curl -k -s --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"template.get","params":{"filter":{"host":["Template Yunohost"]}},"auth":"'$tokenapi'","id":1}' ${zabbixFullpath}/api_jsonrpc.php | jq -r '.result[0].templateid')
applyTemplate=$(curl -s --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 -k -s --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" ];then if [ "$applyTemplate" -eq "$zabbixHostID" ];then
ynh_print_info "Template Yunohost linked to Zabbix server !" ynh_print_info "Template Yunohost linked to Zabbix server !"
else else