mirror of
https://github.com/YunoHost-Apps/zabbix_ynh.git
synced 2024-09-03 20:36:14 +02:00
add comments and condition on fail login
This commit is contained in:
parent
bf46febf87
commit
50510fba45
1 changed files with 57 additions and 51 deletions
|
@ -57,6 +57,7 @@ ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Get infos from manifest"
|
||||||
|
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
ynh_app_setting_set "$app" domain "$domain"
|
||||||
ynh_app_setting_set "$app" path "$path_url"
|
ynh_app_setting_set "$app" path "$path_url"
|
||||||
|
@ -94,6 +95,7 @@ ynh_app_setting_set "$app" language "$language"
|
||||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
|
ynh_print_info "Install dependencies"
|
||||||
|
|
||||||
wget "https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb"
|
wget "https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb"
|
||||||
dpkg -i zabbix-release_*.deb
|
dpkg -i zabbix-release_*.deb
|
||||||
|
@ -123,6 +125,7 @@ rm "$final_path/conf/zabbix.conf.php"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A MYSQL DATABASE
|
# CREATE A MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Create and add default data in db"
|
||||||
|
|
||||||
### Use these lines if you need a database for the application.
|
### Use these lines if you need a database for the application.
|
||||||
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
|
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
|
||||||
|
@ -187,6 +190,8 @@ ynh_app_setting_set "$app" final_path "$final_path"
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
#ynh_setup_source "$final_path"
|
#ynh_setup_source "$final_path"
|
||||||
|
|
||||||
|
ynh_print_info "Generate web config"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -273,18 +278,13 @@ systemctl reload nginx
|
||||||
# Installation with curl
|
# Installation with curl
|
||||||
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||||
|
|
||||||
# Remove the public access
|
|
||||||
if [ "$is_public" -eq 0 ]
|
|
||||||
then
|
|
||||||
ynh_app_setting_delete "$app" skipped_uris
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
### `ynh_replace_string` is used to replace a string in a file.
|
### `ynh_replace_string` is used to replace a string in a file.
|
||||||
### (It's compatible with sed regular expressions syntax)
|
### (It's compatible with sed regular expressions syntax)
|
||||||
|
ynh_print_info "Generate zabbix config files"
|
||||||
|
|
||||||
echo "<?php
|
echo "<?php
|
||||||
// Zabbix GUI configuration file.
|
// Zabbix GUI configuration file.
|
||||||
|
@ -389,6 +389,7 @@ yunohost app ssowatconf
|
||||||
#=================================================
|
#=================================================
|
||||||
# Import Yunohost template
|
# Import Yunohost template
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "Import yunohost template"
|
||||||
zabbixFullpath=https://$domain$path_url
|
zabbixFullpath=https://$domain$path_url
|
||||||
localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml")
|
localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml")
|
||||||
sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix")
|
sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix")
|
||||||
|
@ -408,6 +409,7 @@ curl -L -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \
|
||||||
--form "password=zabbix" \
|
--form "password=zabbix" \
|
||||||
"$zabbixFullpath/index.php"
|
"$zabbixFullpath/index.php"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ];then
|
||||||
sid=$(curl -k -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})(?=")' )
|
||||||
|
@ -446,6 +448,7 @@ else
|
||||||
ynh_print_warn "Template Yunohost not imported !"
|
ynh_print_warn "Template Yunohost not imported !"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#apply template to host
|
#apply template to host
|
||||||
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')
|
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 -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')
|
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')
|
||||||
|
@ -456,12 +459,15 @@ if [ "$applyTemplate" -eq "$zabbixHostID" ];then
|
||||||
else
|
else
|
||||||
ynh_print_warn "Template Yunohost no linked to Zabbix server !"
|
ynh_print_warn "Template Yunohost no linked to Zabbix server !"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
ynh_print_warn "Template Yunohost not imported ! (cannot connect admin)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# disable default admin
|
# disable default admin
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info "disable default admin"
|
||||||
lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`")
|
lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`")
|
||||||
lastid=$((lastid + 1 ))
|
lastid=$((lastid + 1 ))
|
||||||
mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);"
|
mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);"
|
||||||
|
|
Loading…
Add table
Reference in a new issue