From a74911a5e376e1660bc3c850f60c65447c1ab82c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 21 Feb 2019 20:41:49 +0100 Subject: [PATCH 01/66] change quote for posix validation --- scripts/install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index f4cac42..8a2f0e4 100644 --- a/scripts/install +++ b/scripts/install @@ -452,10 +452,10 @@ else fi #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') -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 -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 -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[]') +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') +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 -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 ynh_print_info "Template Yunohost linked to Zabbix server !" else From 165a8d84016429daa71da8155aef88d8c2f1fcea Mon Sep 17 00:00:00 2001 From: root Date: Thu, 21 Feb 2019 20:43:42 +0100 Subject: [PATCH 02/66] add double quote for posix validation --- scripts/upgrade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 02173a4..bd4f7f8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -131,10 +131,10 @@ else fi #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') -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 -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 -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[]') +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') +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 -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 ynh_print_info "Template Yunohost linked to Zabbix server !" else From 42b4e9ac19076c68ff284f32e911c043f3df1e76 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 25 Feb 2019 09:57:09 +0100 Subject: [PATCH 03/66] Fix manifest for : *Cleanup YEP as possible *Make zabbix private by default --- manifest.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 04cd064..ef43492 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Zabbix pour Yunohost" }, "version": "2.0", - "url": "https://framagit.org/Mickael-Martin/zabbix_ynh", + "url": "https://www.zabbix.com", "license": "free", "maintainer": { "name": "Mickael Martin", @@ -61,10 +61,11 @@ "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, - "default": true + "default": false }, { "name": "language", + "type": "string", "ask": { "en": "Choose the application language", "fr": "Choisissez la langue de l'application" From b2487c77fe3d1a20eb6104575a4380606d316ed6 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 25 Feb 2019 14:25:29 +0100 Subject: [PATCH 04/66] add shebangs --- scripts/install | 3 ++- scripts/restore | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 8a2f0e4..cc6ebc1 100644 --- a/scripts/install +++ b/scripts/install @@ -1,4 +1,5 @@ -#================================================= +#!/bin/bash +##================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS diff --git a/scripts/restore b/scripts/restore index 2bc111d..f8514e2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,3 +1,4 @@ +#!/bin/bash #================================================= # GENERIC START #================================================= From be5a0042234b729db003e381762df46d4ca23900 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 25 Feb 2019 15:26:23 +0100 Subject: [PATCH 05/66] make script compatible with shellcheck (package not tested actually) --- scripts/backup | 2 +- scripts/install | 147 ++++++++++++++++++++++++------------------------ scripts/remove | 12 ++-- scripts/restore | 22 ++++---- scripts/upgrade | 114 ++++++++++++++++++------------------- 5 files changed, 149 insertions(+), 148 deletions(-) diff --git a/scripts/backup b/scripts/backup index 300cbbb..e644781 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source ../settings/scripts/_common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/install b/scripts/install index cc6ebc1..e166aef 100644 --- a/scripts/install +++ b/scripts/install @@ -19,11 +19,11 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN -is_public=$YNH_APP_ARG_IS_PUBLIC -language=$YNH_APP_ARG_LANGUAGE +domain="$YNH_APP_ARG_DOMAIN" +path_url="$YNH_APP_ARG_PATH" +admin="$YNH_APP_ARG_ADMIN" +is_public="$YNH_APP_ARG_IS_PUBLIC" +language="$YNH_APP_ARG_LANGUAGE" ### If it's a multi-instance app, meaning it can be installed several times independently ### The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -35,7 +35,7 @@ language=$YNH_APP_ARG_LANGUAGE ### The app instance name is probably what interests you most, since this is ### guaranteed to be unique. This is a good unique identifier to define installation path, ### db names, ... -app=$YNH_APP_INSTANCE_NAME +app="$YNH_APP_INSTANCE_NAME" #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -47,22 +47,22 @@ final_path=/var/www/zabbix test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path "$path_url") # Check web path availability -ynh_webpath_available $domain $path_url +ynh_webpath_available "$domain" "$path_url" # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register "$app" "$domain" "$path_url" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app language $language +ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" path "$path_url" +ynh_app_setting_set "$app" admin "$admin" +ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set "$app" language "$language" #================================================= # STANDARD MODIFICATIONS @@ -103,7 +103,7 @@ ynh_package_update ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype zabbix-server-mysql zabbix-agent jq yunohost service add snmpd -d "Management of SNMP Daemon" DEBIAN_FRONTEND=noninteractive apt-get -y download zabbix-frontend-php -ar x *.deb +ar x ./*.deb tar xzf control.tar.gz sed -i 's/apache2 | httpd, //' control tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control @@ -117,8 +117,8 @@ DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend sed -i "s/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g" /etc/locale.gen locale-gen -ln -s /usr/share/zabbix $final_path -rm $final_path/conf/zabbix.conf.php +ln -s /usr/share/zabbix "$final_path" +rm "$final_path/conf/zabbix.conf.php" #================================================= # CREATE A MYSQL DATABASE @@ -133,46 +133,47 @@ rm $final_path/conf/zabbix.conf.php ### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script ### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script -db_name=$(ynh_sanitize_dbid $app) -db_user=$db_name -ynh_app_setting_set $app db_name $db_name -ynh_app_setting_set $app db_user $db_user -ynh_mysql_setup_db $db_user $db_name +declare db_pwd +db_name=$(ynh_sanitize_dbid "$app") +db_user="$db_name" +ynh_app_setting_set "$app" db_name "$db_name" +ynh_app_setting_set "$app" db_user "$db_user" +ynh_mysql_setup_db "$db_user" "$db_name" -zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u$db_user -p$db_pwd $db_name +zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u"$db_user" -p"$db_pwd" "$db_name" #sso integration -mysql -u$db_user -p$db_pwd $db_name -e "UPDATE \`config\` SET \`http_auth_enabled\` = '1', \`http_login_form\` = '1' WHERE \`config\`.\`configid\` = 1;" +mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "UPDATE \`config\` SET \`http_auth_enabled\` = '1', \`http_login_form\` = '1' WHERE \`config\`.\`configid\` = 1;" -if [ $language == "fr" ];then +if [ "$language" == "fr" ];then lang="fr_FR" else lang="en_GB" fi #admin creation -surname=$(ynh_user_get_info $admin lastname) -name=$(ynh_user_get_info $admin firstname) +surname=$(ynh_user_get_info "$admin" lastname) +name=$(ynh_user_get_info "$admin" firstname) -mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users\` (\`userid\`,\`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES (3,'"$admin"', '"$admin"', '"$admin"', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '"$lang"', '30s', 3, 'default', 0, '', 0, 50);" -mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) VALUES (5, 7, 3);" +mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users\` (\`userid\`,\`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES (3,'$admin', '$admin', '$admin', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 3, 'default', 0, '', 0, 50);" +mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) VALUES (5, 7, 3);" #users creation in zabbix database i=4 -for u in $(ynh_user_list); +for user in $(ynh_user_list); do - if [ "$u" != "$admin" ];then - surname=$(ynh_user_get_info $u lastname) - name=$(ynh_user_get_info $u firstname) - mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ("$i",'"$u"', '"$name"', '"$surname"', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '"$lang"', '30s', 1, 'default', 0, '', 0, 50);" - i=$(($i+1)) + if [ "$user" != "$admin" ];then + surname=$(ynh_user_get_info "$user" lastname) + name=$(ynh_user_get_info "$user" firstname) + mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ($i,'$user', '$name', '$surname', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 1, 'default', 0, '', 0, 50);" + i=$((i+1)) fi done #disable default guest -lastid=$(mysql -u$db_user -p$db_pwd $db_name -BN -e "SELECT max(id) from \`users_groups\`") -lastid=$(($lastid + 1 )) -mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" +lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") +lastid=$(("$lastid" + 1 )) +mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -182,7 +183,7 @@ mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\` , \ ### downloaded from an upstream source, like a git repository. ### `ynh_setup_source` use the file conf/app.src -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set "$app" final_path "$final_path" # Download, check integrity, uncompress and patch the source from app.src #ynh_setup_source "$final_path" @@ -273,9 +274,9 @@ systemctl reload nginx #ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3" # Remove the public access -if [ $is_public -eq 0 ] +if [ "$is_public" -eq 0 ] then - ynh_app_setting_delete $app skipped_uris + ynh_app_setting_delete "$app" skipped_uris fi #================================================= @@ -292,9 +293,9 @@ global \$DB; \$DB['TYPE'] = 'MYSQL'; \$DB['SERVER'] = 'localhost'; \$DB['PORT'] = '0'; -\$DB['DATABASE'] = '"$db_name"'; -\$DB['USER'] = '"$db_user"'; -\$DB['PASSWORD'] = '"$db_pwd"'; +\$DB['DATABASE'] = '$db_name'; +\$DB['USER'] = '$db_user'; +\$DB['PASSWORD'] = '$db_pwd'; // Schema name. Used for IBM DB2 and PostgreSQL. \$DB['SCHEMA'] = ''; @@ -376,10 +377,10 @@ yunohost service add zabbix-agent -d "Management of Zabbix Agent" #================================================= # Make app public if necessary -if [ $is_public -eq 1 ] +if [ "$is_public" -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + ynh_app_setting_set "$app" unprotected_uris "/" fi #================================================= @@ -401,17 +402,17 @@ sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix") confUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_userP_yunohost.conf") bashUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_yunohost.sh") -cp $sudoUserPpath /etc/sudoers.d/zabbix -cp $confUserPpath /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf -cp $bashUserPpath /etc/zabbix/zabbix_agentd.d/yunohost.sh +cp "$sudoUserPpath" /etc/sudoers.d/zabbix +cp "$confUserPpath" /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf +cp "$bashUserPpath" /etc/zabbix/zabbix_agentd.d/yunohost.sh chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh systemctl restart zabbix-agent curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ - --form enter=Sign+in \ - --form name=Admin \ - --form password=zabbix \ + --form "enter=Sign+in" \ + --form "name=Admin" \ + --form "password=zabbix" \ "$zabbixFullpath/index.php" sid=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ @@ -421,24 +422,24 @@ sid=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ importState=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ --form "config=1" \ --form "import_file=@$localpath" \ - --form rules[groups][createMissing]=1 \ - --form rules[templates][updateExisting]=1 \ - --form rules[templates][createMissing]=1 \ - --form rules[templateScreens][updateExisting]=1 \ - --form rules[templateScreens][createMissing]=1 \ - --form rules[templateLinkage][createMissing]=1 \ - --form rules[applications][createMissing]=1 \ - --form rules[items][updateExisting]=1 \ - --form rules[items][createMissing]=1 \ - --form rules[discoveryRules][updateExisting]=1 \ - --form rules[discoveryRules][createMissing]=1 \ - --form rules[triggers][updateExisting]=1 \ - --form rules[triggers][createMissing]=1 \ - --form rules[graphs][updateExisting]=1 \ - --form rules[graphs][createMissing]=1 \ - --form rules[httptests][updateExisting]=1 \ - --form rules[httptests][createMissing]=1 \ - --form rules[valueMaps][createMissing]=1 \ + --form "rules[groups][createMissing]=1" \ + --form "rules[templates][updateExisting]=1" \ + --form "rules[templates][createMissing]=1" \ + --form "rules[templateScreens][updateExisting]=1" \ + --form "rules[templateScreens][createMissing]=1" \ + --form "rules[templateLinkage][createMissing]=1" \ + --form "rules[applications][createMissing]=1" \ + --form "rules[items][updateExisting]=1" \ + --form "rules[items][createMissing]=1" \ + --form "rules[discoveryRules][updateExisting]=1" \ + --form "rules[discoveryRules][createMissing]=1" \ + --form "rules[triggers][updateExisting]=1" \ + --form "rules[triggers][createMissing]=1" \ + --form "rules[graphs][updateExisting]=1" \ + --form "rules[graphs][createMissing]=1" \ + --form "rules[httptests][updateExisting]=1" \ + --form "rules[httptests][createMissing]=1" \ + --form "rules[valueMaps][createMissing]=1" \ --form "import=Import" \ --form "backurl=templates.php" \ --form "form_refresh=1" \ @@ -468,6 +469,6 @@ fi # disable default admin #================================================= -lastid=$(mysql -u$db_user -p$db_pwd $db_name -BN -e "SELECT max(id) from \`users_groups\`") -lastid=$(($lastid + 1 )) -mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" +lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") +lastid=$((lastid + 1 )) +mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" diff --git a/scripts/remove b/scripts/remove index 83a8bcd..579bf84 100644 --- a/scripts/remove +++ b/scripts/remove @@ -15,11 +15,11 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) -db_name=$(ynh_app_setting_get $app db_name) +#domain=$(ynh_app_setting_get "$app" domain) #not used +port=$(ynh_app_setting_get "$app" port) +db_name=$(ynh_app_setting_get "$app" db_name) db_user=$db_name -final_path=$(ynh_app_setting_get $app final_path) +#final_path=$(ynh_app_setting_get "$app" final_path) #not used #================================================= # STANDARD REMOVE @@ -73,7 +73,7 @@ rm /var/www/zabbix #================================================= # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db $db_user $db_name +ynh_mysql_remove_db "$db_user" "$db_name" #================================================= # REMOVE NGINX CONFIGURATION @@ -102,7 +102,7 @@ ynh_remove_logrotate if yunohost firewall list | grep -q "\- $port$" then echo "Close port $port" >&2 - yunohost firewall disallow TCP $port 2>&1 + yunohost firewall disallow TCP "$port" 2>&1 fi #================================================= diff --git a/scripts/restore b/scripts/restore index f8514e2..88af793 100644 --- a/scripts/restore +++ b/scripts/restore @@ -5,7 +5,7 @@ # IMPORT GENERIC HELPERS #================================================= -#source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -40,10 +40,10 @@ rm -fr $final_path #================================================= domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) +#path_url=$(ynh_app_setting_get $app path) #not used +#admin=$(ynh_app_setting_get $app admin) #not used is_public=$(ynh_app_setting_get $app is_public) -language=$(ynh_app_setting_get $app language) +#language=$(ynh_app_setting_get $app language) #not used #================================================= # INSTALL DEPENDENCIES @@ -57,9 +57,9 @@ ynh_package_update ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype zabbix-server-mysql zabbix-agent yunohost service add snmpd -d "Management of SNMP Daemon" DEBIAN_FRONTEND=noninteractive apt-get -y download zabbix-frontend-php -ar x *.deb +ar x ./*.deb tar xzf control.tar.gz -sed -i 's/apache2 | httpd, //' control +ynh_replace_string "apache2 | httpd, " "" control tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control ar rcs zabbix-frontend-php+stretch_all-noapache2.deb debian-binary control.tar.gz data.tar.xz @@ -68,7 +68,7 @@ dpkg -i zabbix-frontend-php+stretch_all-noapache2.deb rm -fr zabbix-*.deb DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php -sed -i "s/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g" /etc/locale.gen +ynh_replace_string "# fr_FR.UTF-8 UTF-8" "fr_FR.UTF-8 UTF-8" /etc/locale.gen locale-gen ln -s /usr/share/zabbix /var/www/zabbix @@ -105,7 +105,7 @@ yunohost app ssowatconf systemctl reload nginx # Remove the public access -if [ $is_public -eq 0 ] +if [ "$is_public" -eq 0 ] then ynh_app_setting_delete $app skipped_uris fi @@ -118,8 +118,8 @@ db_name=$(ynh_app_setting_get $app db_name) db_user=$(ynh_app_setting_get $app db_user) db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_user $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +ynh_mysql_setup_db "$db_user" "$db_name" "$db_pwd" +ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql #================================================= # Restore configs files @@ -160,7 +160,7 @@ systemctl enable zabbix-server && systemctl start zabbix-server #================================================= # Make app public if necessary -if [ $is_public -eq 1 ] +if [ "$is_public" -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set $app unprotected_uris "/" diff --git a/scripts/upgrade b/scripts/upgrade index bd4f7f8..0462e30 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,15 +15,15 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME trustedversion="1:4.0.4-1+stretch" -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get $app final_path) -language=$(ynh_app_setting_get $app language) -db_name=$(ynh_app_setting_get $app db_name) -db_user=$(ynh_app_setting_get $app db_user) -db_pwd=$(ynh_app_setting_get $app mysqlpwd) +domain=$(ynh_app_setting_get "$app" domain) +path_url=$(ynh_app_setting_get "$app" path) +#admin=$(ynh_app_setting_get "$app" admin) #not used +is_public=$(ynh_app_setting_get "$app" is_public) +final_path=$(ynh_app_setting_get "$app" final_path) +#language=$(ynh_app_setting_get "$app" language) #not used +db_name=$(ynh_app_setting_get "$app" db_name) +db_user=$(ynh_app_setting_get "$app" db_user) +db_pwd=$(ynh_app_setting_get "$app" mysqlpwd) #================================================= @@ -32,34 +32,34 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd) # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 + ynh_app_setting_set "$app" is_public 1 is_public=1 elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 + ynh_app_setting_set "$app" is_public 0 is_public=0 fi # If db_name doesn't exist, create it -if [ -z $db_name ]; then - db_name=$(ynh_sanitize_dbid $app) - ynh_app_setting_set $app db_name $db_name +if [ -z "$db_name" ]; then + db_name=$(ynh_sanitize_dbid "$app") + ynh_app_setting_set "$app" db_name "$db_name" fi # If final_path doesn't exist, create it -if [ -z $final_path ]; then +if [ -z "$final_path" ]; then final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path + ynh_app_setting_set "$app" final_path "$final_path" fi #================================================= # Enable default admin temporaly #================================================= -haveDefaultAdminDisabled=$(mysql -BN -u$db_user -p$db_pwd $db_name -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") +haveDefaultAdminDisabled=$(mysql -BN -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") if [ "$haveDefaultAdminDisabled" -eq 1 ] ;then ynh_print_info "Enable default admin" #enable default admin temporaly - mysql -u$db_user -p$db_pwd $db_name -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" + mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" else ynh_print_info "default admin already enabled" fi @@ -69,7 +69,7 @@ fi #================================================= ynh_print_info "Import Yunohost template" #disable sso temporaly -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set "$app" unprotected_uris "/" systemctl reload nginx yunohost app ssowatconf @@ -79,17 +79,17 @@ sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix") confUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_userP_yunohost.conf") bashUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_yunohost.sh") -cp $sudoUserPpath /etc/sudoers.d/zabbix -cp $confUserPpath /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf -cp $bashUserPpath /etc/zabbix/zabbix_agentd.d/yunohost.sh +cp "$sudoUserPpath" /etc/sudoers.d/zabbix +cp "$confUserPpath" /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf +cp "$bashUserPpath" /etc/zabbix/zabbix_agentd.d/yunohost.sh chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh systemctl restart zabbix-agent curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ - --form enter=Sign+in \ - --form name=Admin \ - --form password=zabbix \ + --form "enter=Sign+in" \ + --form "name=Admin" \ + --form "password=zabbix" \ "$zabbixFullpath/index.php" sid=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ @@ -99,24 +99,24 @@ sid=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ importState=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ --form "config=1" \ --form "import_file=@$localpath" \ - --form rules[groups][createMissing]=1 \ - --form rules[templates][updateExisting]=1 \ - --form rules[templates][createMissing]=1 \ - --form rules[templateScreens][updateExisting]=1 \ - --form rules[templateScreens][createMissing]=1 \ - --form rules[templateLinkage][createMissing]=1 \ - --form rules[applications][createMissing]=1 \ - --form rules[items][updateExisting]=1 \ - --form rules[items][createMissing]=1 \ - --form rules[discoveryRules][updateExisting]=1 \ - --form rules[discoveryRules][createMissing]=1 \ - --form rules[triggers][updateExisting]=1 \ - --form rules[triggers][createMissing]=1 \ - --form rules[graphs][updateExisting]=1 \ - --form rules[graphs][createMissing]=1 \ - --form rules[httptests][updateExisting]=1 \ - --form rules[httptests][createMissing]=1 \ - --form rules[valueMaps][createMissing]=1 \ + --form "rules[groups][createMissing]=1" \ + --form "rules[templates][updateExisting]=1" \ + --form "rules[templates][createMissing]=1" \ + --form "rules[templateScreens][updateExisting]=1" \ + --form "rules[templateScreens][createMissing]=1" \ + --form "rules[templateLinkage][createMissing]=1" \ + --form "rules[applications][createMissing]=1" \ + --form "rules[items][updateExisting]=1" \ + --form "rules[items][createMissing]=1" \ + --form "rules[discoveryRules][updateExisting]=1" \ + --form "rules[discoveryRules][createMissing]=1" \ + --form "rules[triggers][updateExisting]=1" \ + --form "rules[triggers][createMissing]=1" \ + --form "rules[graphs][updateExisting]=1" \ + --form "rules[graphs][createMissing]=1" \ + --form "rules[httptests][updateExisting]=1" \ + --form "rules[httptests][createMissing]=1" \ + --form "rules[valueMaps][createMissing]=1" \ --form "import=Import" \ --form "backurl=templates.php" \ --form "form_refresh=1" \ @@ -145,14 +145,14 @@ fi #================================================= # Disable default admin for security issue #================================================= -haveDefaultAdminDisabled=$(mysql -BN -u$db_user -p$db_pwd $db_name -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") +haveDefaultAdminDisabled=$(mysql -BN -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") if [ "$haveDefaultAdminDisabled" -eq 0 ] ;then ynh_print_info "Disable default admin" #disable default admin - lastid=$(mysql -u$db_user -p$db_pwd $db_name -BN -e "SELECT max(id) from \`users_groups\`") - lastid=$(($lastid + 1 )) - mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" + lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") + lastid=$((lastid + 1 )) + mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" else ynh_print_info "default admin already disabled" fi @@ -161,14 +161,14 @@ fi #================================================= # Disable default guest for security issue #================================================= -haveDefaultGuestDisabled=$(mysql -BN -u$db_user -p$db_pwd $db_name -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9") +haveDefaultGuestDisabled=$(mysql -BN -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9") if [ "$haveDefaultGuestDisabled" -eq 0 ] ;then echo "Disable default guest" #disable default guest - lastid=$(mysql -u$db_user -p$db_pwd $db_name -BN -e "SELECT max(id) from \`users_groups\`") - lastid=$(($lastid + 1 )) - mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" + lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") + lastid=$((lastid + 1 )) + mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" else echo "default guest already disabled" fi @@ -178,7 +178,7 @@ fi #================================================= # Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path "$path_url") #================================================= # STANDARD UPGRADE STEPS @@ -201,7 +201,7 @@ zabbixagentCandidateVersion=$(apt-cache policy zabbix-agent | grep -Po "Candidat if [ "$trustedversion" == "$zabbixServerCandidateVersion" ] then - if [ "$zabbixServerInstalledVersion" != "$zabbixServerCandidateVersion" -o "$zabbixFrontendInstalledVersion" != "$zabbixFrontendCandidateVersion" -o "$zabbixagentInstalledVersion" != "$zabbixagentCandidateVersion" ] + if [ "$zabbixServerInstalledVersion" != "$zabbixServerCandidateVersion" ] || [ "$zabbixFrontendInstalledVersion" != "$zabbixFrontendCandidateVersion" ] || [ "$zabbixagentInstalledVersion" != "$zabbixagentCandidateVersion" ] then #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -221,9 +221,9 @@ then DEBIAN_FRONTEND=noninteractive apt-mark unhold zabbix-server-mysql zabbix-frontend-php DEBIAN_FRONTEND=noninteractive apt-get -y download zabbix-frontend-php - ar x *.deb + ar x ./*.deb tar xzf control.tar.gz - sed -i 's/apache2 | httpd, //' control + ynh_replace_string "apache2 | httpd, " "" control tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control ar rcs zabbix-frontend-php+stretch_all-noapache2.deb debian-binary control.tar.gz data.tar.xz dpkg -i zabbix-frontend-php+stretch_all-noapache2.deb @@ -252,9 +252,9 @@ ynh_print_info "re-enable SSOWAT" if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + ynh_app_setting_set "$app" unprotected_uris "/" else - ynh_app_setting_set $app unprotected_uris "" + ynh_app_setting_set "$app" unprotected_uris "" fi systemctl reload nginx From 6063938fa454b2d2e964a1e8d3899951d9d3c665 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 25 Feb 2019 15:52:29 +0100 Subject: [PATCH 06/66] change rules public --- scripts/install | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index e166aef..fe36002 100644 --- a/scripts/install +++ b/scripts/install @@ -372,16 +372,6 @@ yunohost service add zabbix-agent -d "Management of Zabbix Agent" #yunohost service add NAME_INIT.D --log "/var/log/FILE.log" -#================================================= -# SETUP SSOWAT -#================================================= - -# Make app public if necessary -if [ "$is_public" -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" -fi #================================================= # RELOAD NGINX AND PHP-FPM @@ -472,3 +462,24 @@ fi lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") lastid=$((lastid + 1 )) mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" + +#================================================= +# SETUP SSOWAT +#================================================= + +# Make app public if necessary +if [ "$is_public" -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set "$app" unprotected_uris "/" +fi +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= + +systemctl reload nginx +systemctl reload php7.0-fpm + +# Reload SSOwat config +yunohost app ssowatconf + From 91a232473d6a696bf608a90ae771270a1f3326a4 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 25 Feb 2019 20:23:29 +0100 Subject: [PATCH 07/66] restore source ../settings/scripts/_common.sh --- scripts/backup | 2 +- scripts/restore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index e644781..300cbbb 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/restore b/scripts/restore index 88af793..3bdab07 100644 --- a/scripts/restore +++ b/scripts/restore @@ -5,7 +5,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= From c6d7bd2efb22299f5401213a01547da0876e9768 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 25 Feb 2019 20:32:18 +0100 Subject: [PATCH 08/66] try to make zabbix publi just to import template --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index fe36002..3998dd5 100644 --- a/scripts/install +++ b/scripts/install @@ -372,6 +372,9 @@ yunohost service add zabbix-agent -d "Management of Zabbix Agent" #yunohost service add NAME_INIT.D --log "/var/log/FILE.log" +# Make app public if for importing template +# unprotected_uris allows SSO credentials to be passed anyway +ynh_app_setting_set "$app" unprotected_uris "/" #================================================= # RELOAD NGINX AND PHP-FPM From 59be110f9b34355f8c0a54de376f7bf4375fc7c3 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 25 Feb 2019 20:41:28 +0100 Subject: [PATCH 09/66] renable private mode after import template --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 3998dd5..5394ced 100644 --- a/scripts/install +++ b/scripts/install @@ -470,11 +470,11 @@ mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id # SETUP SSOWAT #================================================= -# Make app public if necessary -if [ "$is_public" -eq 1 ] +# Make app private if necessary +if [ "$is_public" -eq 0 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" + ynh_app_setting_delete "$app" unprotected_uris fi #================================================= # RELOAD NGINX AND PHP-FPM From 131ed10a163f075968e29034f135b476cf4496a4 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 25 Feb 2019 20:50:26 +0100 Subject: [PATCH 10/66] make same change as install : make private by default --- scripts/upgrade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0462e30..b81e321 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -248,13 +248,13 @@ fi # RE-ENABLE SSOWAT #================================================= ynh_print_info "re-enable SSOWAT" -# Make app public if necessary -if [ $is_public -eq 1 ] +# Make app private if necessary +if [ $is_public -eq 0 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" + ynh_app_setting_delete "$app" unprotected_uris else - ynh_app_setting_set "$app" unprotected_uris "" + ynh_app_setting_set "$app" unprotected_uris "/" fi systemctl reload nginx From 5c7ea7131933083784a9a0d20b81735fc5dd56a9 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Wed, 27 Feb 2019 11:29:44 +0100 Subject: [PATCH 11/66] follow auth curl --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index b81e321..b3cc62b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -86,7 +86,7 @@ chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh systemctl restart zabbix-agent -curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ +curl -L -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ --form "enter=Sign+in" \ --form "name=Admin" \ --form "password=zabbix" \ From bf46febf87b25501e64a0e41af45f060e7982e44 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Wed, 27 Feb 2019 11:30:15 +0100 Subject: [PATCH 12/66] follow auth curl --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 5394ced..23cfdb8 100644 --- a/scripts/install +++ b/scripts/install @@ -402,7 +402,7 @@ chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh systemctl restart zabbix-agent -curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ +curl -L -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ --form "enter=Sign+in" \ --form "name=Admin" \ --form "password=zabbix" \ From 50510fba45cd34c81b1dc63143dfd2d78366caaa Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Wed, 27 Feb 2019 11:44:26 +0100 Subject: [PATCH 13/66] add comments and condition on fail login --- scripts/install | 108 +++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 51 deletions(-) diff --git a/scripts/install b/scripts/install index 23cfdb8..9946f34 100644 --- a/scripts/install +++ b/scripts/install @@ -57,6 +57,7 @@ ynh_webpath_register "$app" "$domain" "$path_url" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Get infos from manifest" ynh_app_setting_set "$app" domain "$domain" 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 ### - As well as the section "REINSTALL DEPENDENCIES" in the restore 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" dpkg -i zabbix-release_*.deb @@ -123,6 +125,7 @@ rm "$final_path/conf/zabbix.conf.php" #================================================= # 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. ### `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 #ynh_setup_source "$final_path" +ynh_print_info "Generate web config" + #================================================= # NGINX CONFIGURATION #================================================= @@ -273,18 +278,13 @@ systemctl reload nginx # Installation with curl #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 #================================================= ### `ynh_replace_string` is used to replace a string in a file. ### (It's compatible with sed regular expressions syntax) +ynh_print_info "Generate zabbix config files" echo " Date: Wed, 27 Feb 2019 16:55:35 +0100 Subject: [PATCH 14/66] precise information about curl for dns resolution for package_check --- scripts/install | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index 9946f34..7577b1d 100644 --- a/scripts/install +++ b/scripts/install @@ -402,19 +402,20 @@ cp "$bashUserPpath" /etc/zabbix/zabbix_agentd.d/yunohost.sh chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh systemctl restart zabbix-agent +curlOptions="-k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt --resolve $domain:443:127.0.0.1" -curl -L -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ +curl -L $curlOptions \ --form "enter=Sign+in" \ --form "name=Admin" \ --form "password=zabbix" \ "$zabbixFullpath/index.php" if [ $? -eq 0 ];then - sid=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ + sid=$(curl $curlOptions \ "$zabbixFullpath/conf.import.php?rules_preset=template" \ | grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' ) - importState=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ + importState=$(curl $curlOptions \ --form "config=1" \ --form "import_file=@$localpath" \ --form "rules[groups][createMissing]=1" \ @@ -450,10 +451,10 @@ if [ $? -eq 0 ];then #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') - 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 -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 -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[]') + tokenapi=$(curl -k -s --resolve $domain:443:127.0.0.1 --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 --resolve $domain:443:127.0.0.1 --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 -k -s --resolve $domain:443:127.0.0.1 --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 -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" ];then ynh_print_info "Template Yunohost linked to Zabbix server !" else @@ -470,7 +471,7 @@ fi 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=$((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);" #================================================= # SETUP SSOWAT From a7c83e3ad46b8be4621cf730eafe8a93902578a7 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 09:41:18 +0100 Subject: [PATCH 15/66] generate functions and globals vars --- scripts/install | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 7577b1d..5a1cce4 100644 --- a/scripts/install +++ b/scripts/install @@ -143,10 +143,12 @@ ynh_app_setting_set "$app" db_name "$db_name" ynh_app_setting_set "$app" db_user "$db_user" ynh_mysql_setup_db "$db_user" "$db_name" -zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u"$db_user" -p"$db_pwd" "$db_name" +export mysqlconn="mysql -u $db_user -p $db_pwd $db_name" + +zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | $mysqlconn #sso integration -mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "UPDATE \`config\` SET \`http_auth_enabled\` = '1', \`http_login_form\` = '1' WHERE \`config\`.\`configid\` = 1;" +$mysqlconn -e "UPDATE \`config\` SET \`http_auth_enabled\` = '1', \`http_login_form\` = '1' WHERE \`config\`.\`configid\` = 1;" if [ "$language" == "fr" ];then lang="fr_FR" @@ -158,8 +160,8 @@ fi surname=$(ynh_user_get_info "$admin" lastname) name=$(ynh_user_get_info "$admin" firstname) -mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users\` (\`userid\`,\`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES (3,'$admin', '$admin', '$admin', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 3, 'default', 0, '', 0, 50);" -mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) VALUES (5, 7, 3);" +$mysqlconn -e "INSERT INTO \`users\` (\`userid\`,\`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES (3,'$admin', '$admin', '$admin', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 3, 'default', 0, '', 0, 50);" +$mysqlconn -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) VALUES (5, 7, 3);" #users creation in zabbix database i=4 @@ -168,15 +170,12 @@ do if [ "$user" != "$admin" ];then surname=$(ynh_user_get_info "$user" lastname) name=$(ynh_user_get_info "$user" firstname) - mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ($i,'$user', '$name', '$surname', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 1, 'default', 0, '', 0, 50);" + $mysqlconn -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ($i,'$user', '$name', '$surname', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 1, 'default', 0, '', 0, 50);" i=$((i+1)) fi done -#disable default guest -lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") -lastid=$(("$lastid" + 1 )) -mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" +disable_guest_user() #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -469,9 +468,7 @@ fi # 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=$((lastid + 1 )) -#mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" +disable_admin_user() #================================================= # SETUP SSOWAT From b1d5fa71e041112279c7c460224ae8e66ca7e726 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 09:50:11 +0100 Subject: [PATCH 16/66] add functions --- scripts/_common.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index bb04a03..8e8c2d2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,4 +10,44 @@ ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name +} + +#Zabbix part +#===================GET GUEST DEFAULT USER STATE============== +#return 0 if enable, else 1 +get_state_guest_user(){ + return $($mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9") +} + +#================ DISABLE DEFAULT ZABBIX USER GUEST =================== + +disable_guest_user(){ + if [ get_state_guest_user -eq 0 ];then + lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`") + lastid=$(("$lastid" + 1 )) + $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" + fi +} + +#===================GET ADMIN DEFAULT USER STATE============== +#return 0 if enable, else 1 +get_state_admin_user(){ + return $($mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") +} + +#================ DISABLE DEFAULT ADMIN USER =================== +disable_admin_user(){ + if [ get_state_admin_user -eq 0 ] ;then + lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`") + lastid=$((lastid + 1 )) + $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" + fi +} + +enable_admin_user(){ + if [ get_state_admin_user -eq 1 ] ;then + ynh_print_info "Enable default admin" + #enable default admin temporaly + mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" + fi } \ No newline at end of file From 6de436bf765a1c4111c7dbc4547f68dc62cb6fd8 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 09:57:56 +0100 Subject: [PATCH 17/66] Update upgrade --- scripts/upgrade | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index b3cc62b..da64139 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,18 +51,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set "$app" final_path "$final_path" fi +export mysqlconn="mysql -u $db_user -p $db_pwd $db_name" + #================================================= # Enable default admin temporaly #================================================= -haveDefaultAdminDisabled=$(mysql -BN -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") - -if [ "$haveDefaultAdminDisabled" -eq 1 ] ;then - ynh_print_info "Enable default admin" - #enable default admin temporaly - mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" -else - ynh_print_info "default admin already enabled" -fi +enable_admin_user #================================================= # Import Yunohost template @@ -145,33 +139,14 @@ fi #================================================= # Disable default admin for security issue #================================================= -haveDefaultAdminDisabled=$(mysql -BN -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") - -if [ "$haveDefaultAdminDisabled" -eq 0 ] ;then - ynh_print_info "Disable default admin" - #disable default admin - lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") - lastid=$((lastid + 1 )) - mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" -else - ynh_print_info "default admin already disabled" -fi - +ynh_print_info "disable default admin" +disable_admin_user #================================================= # Disable default guest for security issue #================================================= -haveDefaultGuestDisabled=$(mysql -BN -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9") - -if [ "$haveDefaultGuestDisabled" -eq 0 ] ;then - echo "Disable default guest" - #disable default guest - lastid=$(mysql -u"$db_user" -p"$db_pwd" "$db_name" -BN -e "SELECT max(id) from \`users_groups\`") - lastid=$((lastid + 1 )) - mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" -else - echo "default guest already disabled" -fi +ynh_print_info "disable default guest" +disable_guest_user #================================================= # CHECK THE PATH From 1e4df9c341065bdb4144689df8e62a8a4df57b57 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 10:14:25 +0100 Subject: [PATCH 18/66] Update _common.sh --- scripts/_common.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8e8c2d2..5c95379 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -41,6 +41,11 @@ disable_admin_user(){ lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`") lastid=$((lastid + 1 )) $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" + ynh_print_info "Default admin disabled" + + else + ynh_print_info "Default admin already disabled" + fi } @@ -48,6 +53,9 @@ enable_admin_user(){ if [ get_state_admin_user -eq 1 ] ;then ynh_print_info "Enable default admin" #enable default admin temporaly - mysql -u"$db_user" -p"$db_pwd" "$db_name" -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" + $mysqlconn -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" + ynh_print_info "Default admin enabled" + else + ynh_print_info "Default admin already enable" fi } \ No newline at end of file From ab86edb18a2dea4cb87c88fea70307c24d09f0d7 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 10:18:53 +0100 Subject: [PATCH 19/66] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 5a1cce4..2303677 100644 --- a/scripts/install +++ b/scripts/install @@ -19,8 +19,8 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain="$YNH_APP_ARG_DOMAIN" -path_url="$YNH_APP_ARG_PATH" +export domain="$YNH_APP_ARG_DOMAIN" +export path_url="$YNH_APP_ARG_PATH" admin="$YNH_APP_ARG_ADMIN" is_public="$YNH_APP_ARG_IS_PUBLIC" language="$YNH_APP_ARG_LANGUAGE" From 59607d69f2596d940effee3c7854946bf0a58154 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 10:19:54 +0100 Subject: [PATCH 20/66] Update upgrade --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index da64139..a78e804 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,8 +15,8 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME trustedversion="1:4.0.4-1+stretch" -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path) +export domain=$(ynh_app_setting_get "$app" domain) +export path_url=$(ynh_app_setting_get "$app" path) #admin=$(ynh_app_setting_get "$app" admin) #not used is_public=$(ynh_app_setting_get "$app" is_public) final_path=$(ynh_app_setting_get "$app" final_path) From bc99d2261f6aa1d133c424457f713313ecf6fa1f Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 10:21:26 +0100 Subject: [PATCH 21/66] Update upgrade --- scripts/upgrade | 80 ++++--------------------------------------------- 1 file changed, 5 insertions(+), 75 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index a78e804..8797bfe 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -61,91 +61,21 @@ enable_admin_user #================================================= # Import Yunohost template #================================================= -ynh_print_info "Import Yunohost template" -#disable sso temporaly -ynh_app_setting_set "$app" unprotected_uris "/" -systemctl reload nginx -yunohost app ssowatconf - -zabbixFullpath=https://$domain$path_url -localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml") -sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix") -confUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_userP_yunohost.conf") -bashUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_yunohost.sh") - -cp "$sudoUserPpath" /etc/sudoers.d/zabbix -cp "$confUserPpath" /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf -cp "$bashUserPpath" /etc/zabbix/zabbix_agentd.d/yunohost.sh -chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh - -systemctl restart zabbix-agent - -curl -L -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ - --form "enter=Sign+in" \ - --form "name=Admin" \ - --form "password=zabbix" \ - "$zabbixFullpath/index.php" - -sid=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ - "$zabbixFullpath/conf.import.php?rules_preset=template" \ - | grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' ) - -importState=$(curl -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt \ - --form "config=1" \ - --form "import_file=@$localpath" \ - --form "rules[groups][createMissing]=1" \ - --form "rules[templates][updateExisting]=1" \ - --form "rules[templates][createMissing]=1" \ - --form "rules[templateScreens][updateExisting]=1" \ - --form "rules[templateScreens][createMissing]=1" \ - --form "rules[templateLinkage][createMissing]=1" \ - --form "rules[applications][createMissing]=1" \ - --form "rules[items][updateExisting]=1" \ - --form "rules[items][createMissing]=1" \ - --form "rules[discoveryRules][updateExisting]=1" \ - --form "rules[discoveryRules][createMissing]=1" \ - --form "rules[triggers][updateExisting]=1" \ - --form "rules[triggers][createMissing]=1" \ - --form "rules[graphs][updateExisting]=1" \ - --form "rules[graphs][createMissing]=1" \ - --form "rules[httptests][updateExisting]=1" \ - --form "rules[httptests][createMissing]=1" \ - --form "rules[valueMaps][createMissing]=1" \ - --form "import=Import" \ - --form "backurl=templates.php" \ - --form "form_refresh=1" \ - --form "sid=${sid}" \ \ - "${zabbixFullpath}/conf.import.php?rules_preset=template" \ - | grep -c "Imported successfully") - -if [ "$importState" -eq "1" ];then - ynh_print_info "Template Yunohost imported !" -else - ynh_print_warn "Template Yunohost not imported !" -fi - -#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') -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 -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 -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 - ynh_print_info "Template Yunohost linked to Zabbix server !" -else - ynh_print_warn "Template Yunohost no linked to Zabbix server !" -fi +import_template +#================================================= +# Link Yunohost template to the ZAbbix Server Host +#================================================= +link_template #================================================= # Disable default admin for security issue #================================================= -ynh_print_info "disable default admin" disable_admin_user #================================================= # Disable default guest for security issue #================================================= -ynh_print_info "disable default guest" disable_guest_user #================================================= From 1a2e768a1c59bd739f1be7c6f89e26715cb68613 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 10:23:24 +0100 Subject: [PATCH 22/66] Update install (function import,link template) --- scripts/install | 80 ++++--------------------------------------------- 1 file changed, 5 insertions(+), 75 deletions(-) diff --git a/scripts/install b/scripts/install index 2303677..5541ee2 100644 --- a/scripts/install +++ b/scripts/install @@ -388,86 +388,16 @@ yunohost app ssowatconf #================================================= # Import Yunohost template #================================================= -ynh_print_info "Import yunohost template" -zabbixFullpath=https://$domain$path_url -localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml") -sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix") -confUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_userP_yunohost.conf") -bashUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_yunohost.sh") - -cp "$sudoUserPpath" /etc/sudoers.d/zabbix -cp "$confUserPpath" /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf -cp "$bashUserPpath" /etc/zabbix/zabbix_agentd.d/yunohost.sh -chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh - -systemctl restart zabbix-agent -curlOptions="-k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt --resolve $domain:443:127.0.0.1" - -curl -L $curlOptions \ - --form "enter=Sign+in" \ - --form "name=Admin" \ - --form "password=zabbix" \ - "$zabbixFullpath/index.php" - -if [ $? -eq 0 ];then - sid=$(curl $curlOptions \ - "$zabbixFullpath/conf.import.php?rules_preset=template" \ - | grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' ) - - importState=$(curl $curlOptions \ - --form "config=1" \ - --form "import_file=@$localpath" \ - --form "rules[groups][createMissing]=1" \ - --form "rules[templates][updateExisting]=1" \ - --form "rules[templates][createMissing]=1" \ - --form "rules[templateScreens][updateExisting]=1" \ - --form "rules[templateScreens][createMissing]=1" \ - --form "rules[templateLinkage][createMissing]=1" \ - --form "rules[applications][createMissing]=1" \ - --form "rules[items][updateExisting]=1" \ - --form "rules[items][createMissing]=1" \ - --form "rules[discoveryRules][updateExisting]=1" \ - --form "rules[discoveryRules][createMissing]=1" \ - --form "rules[triggers][updateExisting]=1" \ - --form "rules[triggers][createMissing]=1" \ - --form "rules[graphs][updateExisting]=1" \ - --form "rules[graphs][createMissing]=1" \ - --form "rules[httptests][updateExisting]=1" \ - --form "rules[httptests][createMissing]=1" \ - --form "rules[valueMaps][createMissing]=1" \ - --form "import=Import" \ - --form "backurl=templates.php" \ - --form "form_refresh=1" \ - --form "sid=${sid}" \ \ - "${zabbixFullpath}/conf.import.php?rules_preset=template" \ - | grep -c "Imported successfully") - - if [ "$importState" -eq "1" ];then - ynh_print_info "Template Yunohost imported !" - else - ynh_print_warn "Template Yunohost not imported !" - fi - - - #apply template to host - tokenapi=$(curl -k -s --resolve $domain:443:127.0.0.1 --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 --resolve $domain:443:127.0.0.1 --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 -k -s --resolve $domain:443:127.0.0.1 --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 -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" ];then - ynh_print_info "Template Yunohost linked to Zabbix server !" - else - ynh_print_warn "Template Yunohost no linked to Zabbix server !" - fi -else - ynh_print_warn "Template Yunohost not imported ! (cannot connect admin)" -fi +import_template +#================================================= +# Link Yunohost template to the ZAbbix Server Host +#================================================= +link_template #================================================= # disable default admin #================================================= -ynh_print_info "disable default admin" disable_admin_user() #================================================= From 2a0d4e1db06956468ece23fecfc0aa235a8c890e Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 10:27:39 +0100 Subject: [PATCH 23/66] add function add template and link --- scripts/_common.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 5c95379..6bcc699 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -58,4 +58,83 @@ enable_admin_user(){ else ynh_print_info "Default admin already enable" fi +} + +import_template(){ + ynh_print_info "Import yunohost template" + zabbixFullpath=https://$domain$path_url + localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml") + sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix") + confUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_userP_yunohost.conf") + bashUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_yunohost.sh") + + cp "$sudoUserPpath" /etc/sudoers.d/zabbix + cp "$confUserPpath" /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf + cp "$bashUserPpath" /etc/zabbix/zabbix_agentd.d/yunohost.sh + chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh + + systemctl restart zabbix-agent + curlOptions="-k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt --resolve $domain:443:127.0.0.1" + + curl -L $curlOptions \ + --form "enter=Sign+in" \ + --form "name=Admin" \ + --form "password=zabbix" \ + "$zabbixFullpath/index.php" + + if [ $? -eq 0 ];then + sid=$(curl $curlOptions \ + "$zabbixFullpath/conf.import.php?rules_preset=template" \ + | grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' ) + + importState=$(curl $curlOptions \ + --form "config=1" \ + --form "import_file=@$localpath" \ + --form "rules[groups][createMissing]=1" \ + --form "rules[templates][updateExisting]=1" \ + --form "rules[templates][createMissing]=1" \ + --form "rules[templateScreens][updateExisting]=1" \ + --form "rules[templateScreens][createMissing]=1" \ + --form "rules[templateLinkage][createMissing]=1" \ + --form "rules[applications][createMissing]=1" \ + --form "rules[items][updateExisting]=1" \ + --form "rules[items][createMissing]=1" \ + --form "rules[discoveryRules][updateExisting]=1" \ + --form "rules[discoveryRules][createMissing]=1" \ + --form "rules[triggers][updateExisting]=1" \ + --form "rules[triggers][createMissing]=1" \ + --form "rules[graphs][updateExisting]=1" \ + --form "rules[graphs][createMissing]=1" \ + --form "rules[httptests][updateExisting]=1" \ + --form "rules[httptests][createMissing]=1" \ + --form "rules[valueMaps][createMissing]=1" \ + --form "import=Import" \ + --form "backurl=templates.php" \ + --form "form_refresh=1" \ + --form "sid=${sid}" \ \ + "${zabbixFullpath}/conf.import.php?rules_preset=template" \ + | grep -c "Imported successfully") + + if [ "$importState" -eq "1" ];then + ynh_print_info "Template Yunohost imported !" + else + ynh_print_warn "Template Yunohost not imported !" + fi + else + ynh_print_warn "Admin user cannot connect interface !" + fi +} + +link_template(){ + #apply template to host + tokenapi=$(curl -k -s --resolve $domain:443:127.0.0.1 --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 --resolve $domain:443:127.0.0.1 --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 -k -s --resolve $domain:443:127.0.0.1 --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 -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" ];then + ynh_print_info "Template Yunohost linked to Zabbix server !" + else + ynh_print_warn "Template Yunohost no linked to Zabbix server !" + fi + } \ No newline at end of file From 884ef8f0a87bef875ddf62f3680b3e22eeb1b1bb Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:01:31 +0100 Subject: [PATCH 24/66] Update install ynh_abort_if_errors --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 5541ee2..79cf515 100644 --- a/scripts/install +++ b/scripts/install @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST From d37399a48cab80ccd4760f2bc7f1b2eb5092dc98 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:04:50 +0100 Subject: [PATCH 25/66] fix mysqlconn --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 79cf515..ecd38d2 100644 --- a/scripts/install +++ b/scripts/install @@ -143,7 +143,7 @@ ynh_app_setting_set "$app" db_name "$db_name" ynh_app_setting_set "$app" db_user "$db_user" ynh_mysql_setup_db "$db_user" "$db_name" -export mysqlconn="mysql -u $db_user -p $db_pwd $db_name" +export mysqlconn="mysql -u$db_user -p$db_pwd $db_name" zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | $mysqlconn From f08b962df8c1f466a7b36651c8417c4361d39c4e Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:08:30 +0100 Subject: [PATCH 26/66] check functions --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index ecd38d2..ed2083f 100644 --- a/scripts/install +++ b/scripts/install @@ -175,7 +175,7 @@ do fi done -disable_guest_user() +disable_guest_user #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -398,7 +398,7 @@ link_template #================================================= # disable default admin #================================================= -disable_admin_user() +disable_admin_user #================================================= # SETUP SSOWAT From c72d148043ef7ad45e20d99d8052081ef5e030ef Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:12:47 +0100 Subject: [PATCH 27/66] Update _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6bcc699..6819758 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -32,7 +32,7 @@ disable_guest_user(){ #===================GET ADMIN DEFAULT USER STATE============== #return 0 if enable, else 1 get_state_admin_user(){ - return $($mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9") + return $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9" } #================ DISABLE DEFAULT ADMIN USER =================== From 3c82944f1180d6a6afdb437a7006029f0e3ef5a5 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:18:17 +0100 Subject: [PATCH 28/66] Update _common.sh --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6819758..1cb3466 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,7 +16,7 @@ ynh_delete_file_checksum () { #===================GET GUEST DEFAULT USER STATE============== #return 0 if enable, else 1 get_state_guest_user(){ - return $($mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9") + $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9" } #================ DISABLE DEFAULT ZABBIX USER GUEST =================== @@ -32,7 +32,7 @@ disable_guest_user(){ #===================GET ADMIN DEFAULT USER STATE============== #return 0 if enable, else 1 get_state_admin_user(){ - return $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9" + $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9" } #================ DISABLE DEFAULT ADMIN USER =================== From f6f063177453bd0dabac97964e9c8b8ed5408b4a Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:27:25 +0100 Subject: [PATCH 29/66] Update _common.sh --- scripts/_common.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 1cb3466..52ee149 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,13 +16,13 @@ ynh_delete_file_checksum () { #===================GET GUEST DEFAULT USER STATE============== #return 0 if enable, else 1 get_state_guest_user(){ - $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9" + return $($mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9") } #================ DISABLE DEFAULT ZABBIX USER GUEST =================== disable_guest_user(){ - if [ get_state_guest_user -eq 0 ];then + if [ get_state_guest_user = "0" ];then lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`") lastid=$(("$lastid" + 1 )) $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" @@ -32,12 +32,12 @@ disable_guest_user(){ #===================GET ADMIN DEFAULT USER STATE============== #return 0 if enable, else 1 get_state_admin_user(){ - $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9" + return $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9" } #================ DISABLE DEFAULT ADMIN USER =================== disable_admin_user(){ - if [ get_state_admin_user -eq 0 ] ;then + if [ get_state_admin_user = "0" ] ;then lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`") lastid=$((lastid + 1 )) $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" @@ -50,7 +50,7 @@ disable_admin_user(){ } enable_admin_user(){ - if [ get_state_admin_user -eq 1 ] ;then + if [ get_state_admin_user = "1" ] ;then ynh_print_info "Enable default admin" #enable default admin temporaly $mysqlconn -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" From 78ec23008b6788ce896e7e93bab4dac4e1bed956 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:30:54 +0100 Subject: [PATCH 30/66] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd1a450..d3815ec 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,17 @@ Do not change admin password. * The Zabbix server port is not opened by default for external monitoring (active agent). * Install or update apply a template yunohost on the host "Zabbix-server" (127.0.0.1) for basic monitoring for Yunohost. * If you want more information about Yunohost in the template, please open an issue on git. +* This package install non-free (pinning for just snmp-mibs-downloader) and Zabbix repo (for last Zabbix stable version). **More information on the documentation page:** https://yunohost.org/packaging_apps ## LICENSE GNU AFFERO GENERAL PUBLIC LICENSE Version 3 - got to https://framagit.org/Mickael-Martin/zabbix_ynh/blob/master/LICENSE +snmp-mibs-downloader use this licence : https://metadata.ftp-master.debian.org/changelogs/non-free/s/snmp-mibs-downloader/snmp-mibs-downloader_1.1+nmu1_copyright + ## Links * Report a bug: https://framagit.org/Mickael-Martin/zabbix_ynh/issues From 5730e054ebac2c00d39243c01647c1152a7693dd Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:36:17 +0100 Subject: [PATCH 31/66] Update manifest.json to add non-free option --- manifest.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index ef43492..a418f5a 100644 --- a/manifest.json +++ b/manifest.json @@ -65,7 +65,7 @@ }, { "name": "language", - "type": "string", + "type": "string", "ask": { "en": "Choose the application language", "fr": "Choisissez la langue de l'application" @@ -73,6 +73,15 @@ "choices": ["fr", "en"], "default": "en" } + { + "name": "accept_licence_non-free", + "type": "boolean", + "ask": { + "en": "This app can use non-free repo to install snmp-mibs-downloader package (help on OID resultion), do you want install this package ?", + "fr": "Cette application peut utiliser le repo non-free pour installer snmp-mibs-downloader (qui aide à la résolution des OID), souhaitez vous installez ce packet ?" + }, + "default": false + } ] } } From 5192e1e7f05a2ad81971818fa1a42c6bcb5966fa Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:37:21 +0100 Subject: [PATCH 32/66] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a418f5a..7157f24 100644 --- a/manifest.json +++ b/manifest.json @@ -72,7 +72,7 @@ }, "choices": ["fr", "en"], "default": "en" - } + }, { "name": "accept_licence_non-free", "type": "boolean", From 1ef40b18e50551c4356959c73495ae9a435ce075 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:38:30 +0100 Subject: [PATCH 33/66] Revert "Update README.md" This reverts commit 78ec23008b6788ce896e7e93bab4dac4e1bed956 --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d3815ec..fd1a450 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,14 @@ Do not change admin password. * The Zabbix server port is not opened by default for external monitoring (active agent). * Install or update apply a template yunohost on the host "Zabbix-server" (127.0.0.1) for basic monitoring for Yunohost. * If you want more information about Yunohost in the template, please open an issue on git. -* This package install non-free (pinning for just snmp-mibs-downloader) and Zabbix repo (for last Zabbix stable version). **More information on the documentation page:** https://yunohost.org/packaging_apps ## LICENSE GNU AFFERO GENERAL PUBLIC LICENSE Version 3 -got to https://framagit.org/Mickael-Martin/zabbix_ynh/blob/master/LICENSE -snmp-mibs-downloader use this licence : https://metadata.ftp-master.debian.org/changelogs/non-free/s/snmp-mibs-downloader/snmp-mibs-downloader_1.1+nmu1_copyright +got to https://framagit.org/Mickael-Martin/zabbix_ynh/blob/master/LICENSE ## Links From 39905d8268ccfbf360fe7b6ef55b12620d5b8ce8 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:41:25 +0100 Subject: [PATCH 34/66] Update manifest.json --- manifest.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/manifest.json b/manifest.json index 7157f24..4816e75 100644 --- a/manifest.json +++ b/manifest.json @@ -72,15 +72,6 @@ }, "choices": ["fr", "en"], "default": "en" - }, - { - "name": "accept_licence_non-free", - "type": "boolean", - "ask": { - "en": "This app can use non-free repo to install snmp-mibs-downloader package (help on OID resultion), do you want install this package ?", - "fr": "Cette application peut utiliser le repo non-free pour installer snmp-mibs-downloader (qui aide à la résolution des OID), souhaitez vous installez ce packet ?" - }, - "default": false } ] } From 755ec37db53f9d6e819a1e144f3614b66087a326 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 11:42:18 +0100 Subject: [PATCH 35/66] Update _common.sh --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 52ee149..38f2362 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,7 +16,7 @@ ynh_delete_file_checksum () { #===================GET GUEST DEFAULT USER STATE============== #return 0 if enable, else 1 get_state_guest_user(){ - return $($mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9") + $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=2 and usrgrpid=9" } #================ DISABLE DEFAULT ZABBIX USER GUEST =================== @@ -32,7 +32,7 @@ disable_guest_user(){ #===================GET ADMIN DEFAULT USER STATE============== #return 0 if enable, else 1 get_state_admin_user(){ - return $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9" + $mysqlconn -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9" } #================ DISABLE DEFAULT ADMIN USER =================== From ae54783519f5520363c10d352c71edc6543dd1f7 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 19:30:25 +0100 Subject: [PATCH 36/66] Update manifest.json snmp downloader non-free --- manifest.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/manifest.json b/manifest.json index 4816e75..53317e3 100644 --- a/manifest.json +++ b/manifest.json @@ -72,6 +72,19 @@ }, "choices": ["fr", "en"], "default": "en" + }, + { + "name": "add_nonfree", + "type": "boolean", + "ask": { + "en": "This application can install snmp-mibs-downloader from non-free repository to resolve many OID by default, do you want install this package ?", + "fr": "Cette application peut installer snmp-mibs-downloader depuis le dépôt non-free afin de resoudre de nombreux OID par defaut, souhaitez vous installer ce package ?" + }, + "help": { + "en" : "Zabbix works without problem without the package snmp-mibs-downloader, however it help to resolve OIDs to comprehensive strings. If you make the choice of installing it, the pinning method is used", + "fr" : "Zabbix peut fonctionner sans le paquet snmp-mibs-downloader, cependant il aide à faire la résolution des OIDs en chaines de caractères compréhensibles. Si vous faites le choix de l'installer, il sera installé par méthode 'pinning'" + }, + "default": false } ] } From e870de8e7de9f35df6e8be5b10738e903dfa98bb Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Fri, 1 Mar 2019 19:37:23 +0100 Subject: [PATCH 37/66] Update install (adjust apt install) --- scripts/install | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/install b/scripts/install index ed2083f..de3e325 100644 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,7 @@ export path_url="$YNH_APP_ARG_PATH" admin="$YNH_APP_ARG_ADMIN" is_public="$YNH_APP_ARG_IS_PUBLIC" language="$YNH_APP_ARG_LANGUAGE" +nonfree="$YNH_APP_ARG_ADD_NONFREE" ### If it's a multi-instance app, meaning it can be installed several times independently ### The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -100,20 +101,19 @@ 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" dpkg -i zabbix-release_*.deb rm zabbix-release_*.deb -echo "deb http://deb.debian.org/debian stretch non-free" >/etc/apt/sources.list.d/non-free.list + +if [ $nonfree ];then + echo "deb http://deb.debian.org/debian stretch non-free" >/etc/apt/sources.list.d/non-free.list +fi ynh_package_update -ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype zabbix-server-mysql zabbix-agent jq -yunohost service add snmpd -d "Management of SNMP Daemon" -DEBIAN_FRONTEND=noninteractive apt-get -y download zabbix-frontend-php -ar x ./*.deb -tar xzf control.tar.gz -sed -i 's/apache2 | httpd, //' control -tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control -ar rcs zabbix-frontend-php+stretch_all-noapache2.deb debian-binary control.tar.gz data.tar.xz +if [ $nonfree ];then + ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype jq +else + ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq -dpkg -i zabbix-frontend-php+stretch_all-noapache2.deb +fi -rm -fr zabbix-*.deb +ynh_package_install zabbix-server-mysql zabbix-agent zabbix-frontend-php DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php sed -i "s/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g" /etc/locale.gen From 78a46c13715fcf52e4a82ea28ac2bf2105d78996 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 10:52:53 +0100 Subject: [PATCH 38/66] Add new directory --- sources/extra_files/app/preferences.d/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sources/extra_files/app/preferences.d/.gitkeep diff --git a/sources/extra_files/app/preferences.d/.gitkeep b/sources/extra_files/app/preferences.d/.gitkeep new file mode 100644 index 0000000..e69de29 From 3bc33e56d86caed35a6b4d1e2e7fd9bef09b8bb0 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 10:54:11 +0100 Subject: [PATCH 39/66] add file preferences to disable all packages non-free --- sources/extra_files/app/preferences.d/non-free_policy | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sources/extra_files/app/preferences.d/non-free_policy diff --git a/sources/extra_files/app/preferences.d/non-free_policy b/sources/extra_files/app/preferences.d/non-free_policy new file mode 100644 index 0000000..4353574 --- /dev/null +++ b/sources/extra_files/app/preferences.d/non-free_policy @@ -0,0 +1,4 @@ +Explanation: Disable packages from non-free tree by default (Zabbix app install with non-free option enable) +Package: * +Pin: release o=Debian,a=stable,l=Debian,c=non-free +Pin-Priority: -1 \ No newline at end of file From 5ffae31be541f666f73006049d7ffe45906984cd Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 10:56:16 +0100 Subject: [PATCH 40/66] Add file to add snmp-mibs-downloader from non-free --- .../app/preferences.d/snmp-mibs-downloader_nonfree | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree diff --git a/sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree b/sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree new file mode 100644 index 0000000..1fb7921 --- /dev/null +++ b/sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree @@ -0,0 +1,4 @@ +Explanation: Enable package snmp-mibs-downloader from non-free tree (Zabbix app install with non-free option enable) +Package: snmp-mibs-downloader +Pin: release o=Debian,a=stable,l=Debian,c=non-free +Pin-Priority: 600 \ No newline at end of file From 10e35a6e9edb6de45eadd0c041a2d724b94ef22d Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 11:03:55 +0100 Subject: [PATCH 41/66] nonfree setup --- scripts/install | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index de3e325..29c8d6f 100644 --- a/scripts/install +++ b/scripts/install @@ -96,15 +96,22 @@ ynh_app_setting_set "$app" language "$language" ### - Remove the section "REMOVE DEPENDENCIES" in the remove script ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script -ynh_print_info "Install dependencies" +ynh_print_info "Install Zabbix repository" 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 rm zabbix-release_*.deb +ynh_print_info "Install non-free repository with pinning" if [ $nonfree ];then echo "deb http://deb.debian.org/debian stretch non-free" >/etc/apt/sources.list.d/non-free.list + nonfreefilerepo=$(find /var/cache/yunohost/ -name "non-free_policy") + packagenonfreefilerepo=$(find /var/cache/yunohost/ -name "snmp-mibs-downloader_nonfree") + cp $nonfreefilerepo /etc/apt/preferences.d/ + cp $packagenonfreefilerepo /etc/apt/preferences.d/ fi + +ynh_print_info "Update and install dependencies" ynh_package_update if [ $nonfree ];then ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype jq From 12a85212cb09f75de16b76ecf7600a08b9d77105 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 11:07:16 +0100 Subject: [PATCH 42/66] Update backup to include nonfree repo (pinning) --- scripts/backup | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/backup b/scripts/backup index 300cbbb..745ff1b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,8 @@ app="zabbix" final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) +nonfree=$(ynh_app_setting_get $app nonfree) + #================================================= # STANDARD BACKUP STEPS @@ -69,4 +71,8 @@ ynh_mysql_dump_db "$db_name" > db.sql #================================================= # SPECIFIC BACKUP #================================================= +if [ $nonfree ];then + ynh_backup /etc/apt/sources.list.d/non-free.list + ynh_backup /etc/apt/preferences.d +fi From 33c39b0e9b6585b54e56cc49a943df2995bb3e33 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 11:10:35 +0100 Subject: [PATCH 43/66] Update restore (add pinning for nonfree) --- scripts/restore | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/scripts/restore b/scripts/restore index 3bdab07..db08fa9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,33 +44,42 @@ domain=$(ynh_app_setting_get $app domain) #admin=$(ynh_app_setting_get $app admin) #not used is_public=$(ynh_app_setting_get $app is_public) #language=$(ynh_app_setting_get $app language) #not used +nonfree=$(ynh_app_setting_get $app nonfree) + #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_print_info "Install Zabbix repository" + 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 rm zabbix-release_*.deb -echo "deb http://deb.debian.org/debian stretch non-free" >/etc/apt/sources.list.d/non-free.list + +ynh_print_info "Install non-free repository with pinning" +if [ $nonfree ];then + ynh_restore_file "/etc/apt/sources.list.d/non-free.list" + ynh_restore_file "/etc/apt/preferences.d" + +fi + +ynh_print_info "Update and install dependencies" ynh_package_update -ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype zabbix-server-mysql zabbix-agent -yunohost service add snmpd -d "Management of SNMP Daemon" -DEBIAN_FRONTEND=noninteractive apt-get -y download zabbix-frontend-php -ar x ./*.deb -tar xzf control.tar.gz -ynh_replace_string "apache2 | httpd, " "" control -tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control -ar rcs zabbix-frontend-php+stretch_all-noapache2.deb debian-binary control.tar.gz data.tar.xz +if [ $nonfree ];then + ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype jq +else + ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq -dpkg -i zabbix-frontend-php+stretch_all-noapache2.deb +fi -rm -fr zabbix-*.deb +ynh_package_install zabbix-server-mysql zabbix-agent zabbix-frontend-php DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php -ynh_replace_string "# fr_FR.UTF-8 UTF-8" "fr_FR.UTF-8 UTF-8" /etc/locale.gen +sed -i "s/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g" /etc/locale.gen locale-gen + ln -s /usr/share/zabbix /var/www/zabbix rm $final_path/conf/zabbix.conf.php @@ -136,9 +145,6 @@ ynh_restore_file "/etc/zabbix" systemctl enable zabbix-server && systemctl start zabbix-server - - - #================================================= # SETUP LOGROTATE #================================================= From 7cd8454b0ea152c734efcc9dd9134c8c3b66d5e2 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 13:50:37 +0100 Subject: [PATCH 44/66] Update upgrade for pinning install (nonfree) --- scripts/upgrade | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 8797bfe..c019f92 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ final_path=$(ynh_app_setting_get "$app" final_path) db_name=$(ynh_app_setting_get "$app" db_name) db_user=$(ynh_app_setting_get "$app" db_user) db_pwd=$(ynh_app_setting_get "$app" mysqlpwd) +nonfree=$(ynh_app_setting_get "$app" nonfree) #================================================= @@ -125,16 +126,28 @@ then cp -p /usr/share/zabbix/conf/zabbix.conf.php /tmp/ DEBIAN_FRONTEND=noninteractive apt-mark unhold zabbix-server-mysql zabbix-frontend-php - DEBIAN_FRONTEND=noninteractive apt-get -y download zabbix-frontend-php - ar x ./*.deb - tar xzf control.tar.gz - ynh_replace_string "apache2 | httpd, " "" control - tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control - ar rcs zabbix-frontend-php+stretch_all-noapache2.deb debian-binary control.tar.gz data.tar.xz - dpkg -i zabbix-frontend-php+stretch_all-noapache2.deb - rm -fr zabbix-*.deb - apt-get -y --only-upgrade install zabbix-server-mysql zabbix-agent - DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php + + ynh_print_info "Install non-free repository with pinning" + if [ $nonfree ];then + echo "deb http://deb.debian.org/debian stretch non-free" >/etc/apt/sources.list.d/non-free.list + nonfreefilerepo=$(find /var/cache/yunohost/ -name "non-free_policy") + packagenonfreefilerepo=$(find /var/cache/yunohost/ -name "snmp-mibs-downloader_nonfree") + cp $nonfreefilerepo /etc/apt/preferences.d/ + cp $packagenonfreefilerepo /etc/apt/preferences.d/ + fi + + ynh_print_info "Update and install dependencies" + ynh_package_update + if [ $nonfree ];then + ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype jq + else + ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq + + fi + + ynh_package_install zabbix-server-mysql zabbix-agent zabbix-frontend-php + DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php + rm /usr/share/zabbix/conf/zabbix.conf.php cp -rpf /tmp/zabbix /etc/ From 134afaa556adee2d7de3e306d907f6ada42ae9e3 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 13:53:24 +0100 Subject: [PATCH 45/66] Update upgrade to 1:4.0.5-1+stretch zabbix version --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c019f92..eb8eb09 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= app=$YNH_APP_INSTANCE_NAME -trustedversion="1:4.0.4-1+stretch" +trustedversion="1:4.0.5-1+stretch" export domain=$(ynh_app_setting_get "$app" domain) export path_url=$(ynh_app_setting_get "$app" path) #admin=$(ynh_app_setting_get "$app" admin) #not used From 7b574df3b672f90c8c3b1a29ef638b756bb4bb91 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 5 Mar 2019 14:03:27 +0100 Subject: [PATCH 46/66] add compatibility for all languages. --- scripts/upgrade | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index eb8eb09..fbe4a00 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -95,14 +95,14 @@ ynh_package_update #REMOVE DUPLICATE LOG ENTRY IN LOGROTATE PATCH IF NEEDED ynh_remove_logrotate -zabbixServerInstalledVersion=$(apt-cache policy zabbix-server-mysql | grep -Po "Installed: \K(.*)") -zabbixServerCandidateVersion=$(apt-cache policy zabbix-server-mysql | grep -Po "Candidate: \K(.*)") +zabbixServerInstalledVersion=$(apt-cache policy zabbix-server-mysql | sed -n '2p' | grep -Po ".*: \K(.*)") +zabbixServerCandidateVersion=$(apt-cache policy zabbix-server-mysql | sed -n '3p' | grep -Po ".*: \K(.*)") -zabbixFrontendInstalledVersion=$(apt-cache policy zabbix-frontend-php | grep -Po "Installed: \K(.*)") -zabbixFrontendCandidateVersion=$(apt-cache policy zabbix-frontend-php | grep -Po "Candidate: \K(.*)") +zabbixFrontendInstalledVersion=$(apt-cache policy zabbix-frontend-php | sed -n '2p' | grep -Po ".*: \K(.*)") +zabbixFrontendCandidateVersion=$(apt-cache policy zabbix-frontend-php | sed -n '3p' | grep -Po ".*: \K(.*)") -zabbixagentInstalledVersion=$(apt-cache policy zabbix-agent | grep -Po "Installed: \K(.*)") -zabbixagentCandidateVersion=$(apt-cache policy zabbix-agent | grep -Po "Candidate: \K(.*)") +zabbixagentInstalledVersion=$(apt-cache policy zabbix-agent | sed -n '2p' | grep -Po ".*: \K(.*)") +zabbixagentCandidateVersion=$(apt-cache policy zabbix-agent | sed -n '3p' | grep -Po ".*: \K(.*)") if [ "$trustedversion" == "$zabbixServerCandidateVersion" ] then From 25be1100322d2f2b4af4066cdfcb4bc947818abd Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 12:21:54 +0100 Subject: [PATCH 47/66] removing nonfree part --- manifest.json | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/manifest.json b/manifest.json index 53317e3..4816e75 100644 --- a/manifest.json +++ b/manifest.json @@ -72,19 +72,6 @@ }, "choices": ["fr", "en"], "default": "en" - }, - { - "name": "add_nonfree", - "type": "boolean", - "ask": { - "en": "This application can install snmp-mibs-downloader from non-free repository to resolve many OID by default, do you want install this package ?", - "fr": "Cette application peut installer snmp-mibs-downloader depuis le dépôt non-free afin de resoudre de nombreux OID par defaut, souhaitez vous installer ce package ?" - }, - "help": { - "en" : "Zabbix works without problem without the package snmp-mibs-downloader, however it help to resolve OIDs to comprehensive strings. If you make the choice of installing it, the pinning method is used", - "fr" : "Zabbix peut fonctionner sans le paquet snmp-mibs-downloader, cependant il aide à faire la résolution des OIDs en chaines de caractères compréhensibles. Si vous faites le choix de l'installer, il sera installé par méthode 'pinning'" - }, - "default": false } ] } From 06a52c20ae319cb0b8a41ccd7acaae0f806682d0 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 12:22:50 +0100 Subject: [PATCH 48/66] removing nonfree part --- scripts/install | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/scripts/install b/scripts/install index 29c8d6f..df2f530 100644 --- a/scripts/install +++ b/scripts/install @@ -24,7 +24,6 @@ export path_url="$YNH_APP_ARG_PATH" admin="$YNH_APP_ARG_ADMIN" is_public="$YNH_APP_ARG_IS_PUBLIC" language="$YNH_APP_ARG_LANGUAGE" -nonfree="$YNH_APP_ARG_ADD_NONFREE" ### If it's a multi-instance app, meaning it can be installed several times independently ### The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -102,23 +101,9 @@ wget "https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbi dpkg -i zabbix-release_*.deb rm zabbix-release_*.deb -ynh_print_info "Install non-free repository with pinning" -if [ $nonfree ];then - echo "deb http://deb.debian.org/debian stretch non-free" >/etc/apt/sources.list.d/non-free.list - nonfreefilerepo=$(find /var/cache/yunohost/ -name "non-free_policy") - packagenonfreefilerepo=$(find /var/cache/yunohost/ -name "snmp-mibs-downloader_nonfree") - cp $nonfreefilerepo /etc/apt/preferences.d/ - cp $packagenonfreefilerepo /etc/apt/preferences.d/ -fi - ynh_print_info "Update and install dependencies" ynh_package_update -if [ $nonfree ];then - ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype jq -else - ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq - -fi +ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq ynh_package_install zabbix-server-mysql zabbix-agent zabbix-frontend-php DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php From ff3e0bd359c1c37c0b85bcad1ae5dd8c7ee237b8 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 12:33:25 +0100 Subject: [PATCH 49/66] remove old (v1) nonfree part --- scripts/upgrade | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index fbe4a00..138b580 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,8 +24,6 @@ final_path=$(ynh_app_setting_get "$app" final_path) db_name=$(ynh_app_setting_get "$app" db_name) db_user=$(ynh_app_setting_get "$app" db_user) db_pwd=$(ynh_app_setting_get "$app" mysqlpwd) -nonfree=$(ynh_app_setting_get "$app" nonfree) - #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -86,6 +84,12 @@ disable_guest_user # Normalize the URL path syntax path_url=$(ynh_normalize_url_path "$path_url") +#REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1) +nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free) +if [ $(echo $nonfreepackagelist | wc -l) -eq 1 ] && [ $(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader") -eq 1 ] ;then + rm /etc/apt/sources.list.d/non-free.list +fi + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -126,25 +130,10 @@ then cp -p /usr/share/zabbix/conf/zabbix.conf.php /tmp/ DEBIAN_FRONTEND=noninteractive apt-mark unhold zabbix-server-mysql zabbix-frontend-php - - ynh_print_info "Install non-free repository with pinning" - if [ $nonfree ];then - echo "deb http://deb.debian.org/debian stretch non-free" >/etc/apt/sources.list.d/non-free.list - nonfreefilerepo=$(find /var/cache/yunohost/ -name "non-free_policy") - packagenonfreefilerepo=$(find /var/cache/yunohost/ -name "snmp-mibs-downloader_nonfree") - cp $nonfreefilerepo /etc/apt/preferences.d/ - cp $packagenonfreefilerepo /etc/apt/preferences.d/ - fi - + ynh_print_info "Update and install dependencies" ynh_package_update - if [ $nonfree ];then - ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd snmp-mibs-downloader libjs-prototype jq - else - ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq - - fi - + ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq ynh_package_install zabbix-server-mysql zabbix-agent zabbix-frontend-php DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php From 486b6754b499139db71208d163992374f8f8b565 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 12:49:51 +0100 Subject: [PATCH 50/66] add details of imported template yunohost --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd1a450..58de2be 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Do not change admin password. * Do not change the default admin user password. The user is disabled juste after the install but used to update templates. * The Zabbix server port is not opened by default for external monitoring (active agent). -* Install or update apply a template yunohost on the host "Zabbix-server" (127.0.0.1) for basic monitoring for Yunohost. +* A Yunohost template is imported and linked to the host "Zabbix-server" (127.0.0.1) for basic monitoring for Yunohost. * If you want more information about Yunohost in the template, please open an issue on git. **More information on the documentation page:** From 325eef7214621680e961a44958bf07dadcbec01f Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 12:57:36 +0100 Subject: [PATCH 51/66] mysql str --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 138b580..e8c3e97 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,7 +50,7 @@ if [ -z "$final_path" ]; then ynh_app_setting_set "$app" final_path "$final_path" fi -export mysqlconn="mysql -u $db_user -p $db_pwd $db_name" +export mysqlconn="mysql -u$db_user -p$db_pwd $db_name" #================================================= # Enable default admin temporaly From 3289cd3faf81e3e4092d0016364ab7e58266ed4a Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 13:14:48 +0100 Subject: [PATCH 52/66] Update _common.sh if condition broken --- scripts/_common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 38f2362..79bf17b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,7 +22,7 @@ get_state_guest_user(){ #================ DISABLE DEFAULT ZABBIX USER GUEST =================== disable_guest_user(){ - if [ get_state_guest_user = "0" ];then + if [ $(get_state_guest_user) = "0" ];then lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`") lastid=$(("$lastid" + 1 )) $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);" @@ -37,7 +37,7 @@ get_state_admin_user(){ #================ DISABLE DEFAULT ADMIN USER =================== disable_admin_user(){ - if [ get_state_admin_user = "0" ] ;then + if [ $(get_state_admin_user) = "0" ] ;then lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`") lastid=$((lastid + 1 )) $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);" @@ -50,7 +50,7 @@ disable_admin_user(){ } enable_admin_user(){ - if [ get_state_admin_user = "1" ] ;then + if [ $(get_state_admin_user) = "1" ] ;then ynh_print_info "Enable default admin" #enable default admin temporaly $mysqlconn -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;" From b5c354a5912587967025e23ad9cd368f2a6603a4 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 13:41:23 +0100 Subject: [PATCH 53/66] removing dependencies snmp-mibs-downloader --- scripts/upgrade | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index e8c3e97..94885f6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,7 +87,11 @@ path_url=$(ynh_normalize_url_path "$path_url") #REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1) nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free) if [ $(echo $nonfreepackagelist | wc -l) -eq 1 ] && [ $(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader") -eq 1 ] ;then - rm /etc/apt/sources.list.d/non-free.list + ynh_print_info "Removing snmp-mibs-downloader (non-free package)" + sed -i.$(date "+%m%d%y") 's/ snmp-mibs-downloader,//g' /var/lib/dpkg/status + DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader + if [ -f /etc/apt/sources.list.d/non-free.list ];then + ynh_secure_remove /etc/apt/sources.list.d/non-free.list fi #================================================= From 77fb6333e4127ab8776985b18dddbb0d045a87aa Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 13:45:28 +0100 Subject: [PATCH 54/66] close broken condition --- scripts/upgrade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 94885f6..695370a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -91,7 +91,8 @@ if [ $(echo $nonfreepackagelist | wc -l) -eq 1 ] && [ $(echo $nonfreepackagelist sed -i.$(date "+%m%d%y") 's/ snmp-mibs-downloader,//g' /var/lib/dpkg/status DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader if [ -f /etc/apt/sources.list.d/non-free.list ];then - ynh_secure_remove /etc/apt/sources.list.d/non-free.list + ynh_secure_remove /etc/apt/sources.list.d/non-free.list + fi fi #================================================= From 04a320adf942ab3f5ab89cceb6242b5cba606965 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 13:46:45 +0100 Subject: [PATCH 55/66] add yes to purge --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 695370a..666b60a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -89,7 +89,7 @@ nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-fre if [ $(echo $nonfreepackagelist | wc -l) -eq 1 ] && [ $(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader") -eq 1 ] ;then ynh_print_info "Removing snmp-mibs-downloader (non-free package)" sed -i.$(date "+%m%d%y") 's/ snmp-mibs-downloader,//g' /var/lib/dpkg/status - DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader + DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader -y if [ -f /etc/apt/sources.list.d/non-free.list ];then ynh_secure_remove /etc/apt/sources.list.d/non-free.list fi From 3b6a8dd7290d81f37b0a668fcddb71f69e05fbdd Mon Sep 17 00:00:00 2001 From: root Date: Thu, 7 Mar 2019 13:01:01 +0100 Subject: [PATCH 56/66] remove nonfree part --- sources/extra_files/app/preferences.d/.gitkeep | 0 sources/extra_files/app/preferences.d/non-free_policy | 4 ---- .../app/preferences.d/snmp-mibs-downloader_nonfree | 4 ---- 3 files changed, 8 deletions(-) delete mode 100644 sources/extra_files/app/preferences.d/.gitkeep delete mode 100644 sources/extra_files/app/preferences.d/non-free_policy delete mode 100644 sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree diff --git a/sources/extra_files/app/preferences.d/.gitkeep b/sources/extra_files/app/preferences.d/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/sources/extra_files/app/preferences.d/non-free_policy b/sources/extra_files/app/preferences.d/non-free_policy deleted file mode 100644 index 4353574..0000000 --- a/sources/extra_files/app/preferences.d/non-free_policy +++ /dev/null @@ -1,4 +0,0 @@ -Explanation: Disable packages from non-free tree by default (Zabbix app install with non-free option enable) -Package: * -Pin: release o=Debian,a=stable,l=Debian,c=non-free -Pin-Priority: -1 \ No newline at end of file diff --git a/sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree b/sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree deleted file mode 100644 index 1fb7921..0000000 --- a/sources/extra_files/app/preferences.d/snmp-mibs-downloader_nonfree +++ /dev/null @@ -1,4 +0,0 @@ -Explanation: Enable package snmp-mibs-downloader from non-free tree (Zabbix app install with non-free option enable) -Package: snmp-mibs-downloader -Pin: release o=Debian,a=stable,l=Debian,c=non-free -Pin-Priority: 600 \ No newline at end of file From 935c44c82bd71da086d90cff222a62fa133c0b14 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 15:09:37 +0100 Subject: [PATCH 57/66] Update Template_Yunohost.xml --- sources/extra_files/app/Template_Yunohost.xml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sources/extra_files/app/Template_Yunohost.xml b/sources/extra_files/app/Template_Yunohost.xml index ef98bcf..ddd4f30 100644 --- a/sources/extra_files/app/Template_Yunohost.xml +++ b/sources/extra_files/app/Template_Yunohost.xml @@ -1,7 +1,7 @@ 4.0 - 2019-01-31T12:45:57Z + 2019-03-07T14:08:51Z Templates/Applications @@ -12,7 +12,7 @@ Template Yunohost cat /etc/sudoers.d/zabbix -zabbix ALL=(root) NOPASSWD: /etc/zabbix/zabbix_agentd.d/yunohost.sh +zabbix ALL=(ALL) NOPASSWD: /etc/zabbix/zabbix_agentd.d/yunohost.sh cat /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf UserParameter=yunohost.users.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.users.discover @@ -23,8 +23,8 @@ UserParameter=yunohost.services.discover,sudo /etc/zabbix/zabbix_agentd.d/yunoho UserParameter=yunohost.service.status[*],sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.service.status "$1" UserParameter=yunohost.backups.number,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.backups.number UserParameter=yunohost.backups.ageoflastbackup,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.backups.ageoflastbackup -UserParameter=yunohost.ports.tcp.discovery,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.tcp.discovery -UserParameter=yunohost.ports.udp.discovery,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.udp.discovery +UserParameter=yunohost.ports.tcp.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.tcp.discovery +UserParameter=yunohost.ports.udp.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.udp.discovery UserParameter=yunohost.migrations.lastinstalled,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.migrations.lastinstalled UserParameter=yunohost.migrations.lastavailable,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.migrations.lastavailable @@ -130,7 +130,7 @@ fi yunohost.backups.ageoflastbackup - 1d + 1d;h10m45 90d 365d 0 @@ -189,7 +189,7 @@ fi yunohost.backups.number - 1d + 1d;h11 90d 365d 0 @@ -248,7 +248,7 @@ fi yunohost.migrations.lastavailable - 1d + 1d;h10m50 90d 365d 0 @@ -307,7 +307,7 @@ fi yunohost.migrations.lastinstalled - 1d + 1d;h10m55 90d 365d 0 @@ -368,7 +368,7 @@ fi yunohost.domains.discover - 1d + 1d;h10 0 @@ -632,7 +632,7 @@ fi yunohost.ports.tcp.discover - 1d + 1d;h9m30 0 @@ -766,7 +766,7 @@ fi yunohost.ports.udp.discover - 1d + 1d;h9m45 0 @@ -900,7 +900,7 @@ fi yunohost.services.discover - 1d + 1d;h10m15 0 @@ -1146,7 +1146,7 @@ fi yunohost.users.discover - 1d + 1d;h10m30 0 @@ -1410,4 +1410,4 @@ fi - + \ No newline at end of file From a629d0b684bc5be0a1c45acdc0aa9826ac0383ce Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 15:15:27 +0100 Subject: [PATCH 58/66] disable ssowat --- scripts/upgrade | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 666b60a..a470569 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -52,6 +52,12 @@ fi export mysqlconn="mysql -u$db_user -p$db_pwd $db_name" +#================================================= +# DISABLED SSOWAT +#================================================= +ynh_print_info "disable SSOWAT temporaly" +ynh_app_setting_set "$app" unprotected_uris "/" + #================================================= # Enable default admin temporaly #================================================= From 498b984730785c95594debe37a7f4eb22af2788c Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Thu, 7 Mar 2019 15:16:26 +0100 Subject: [PATCH 59/66] systemctl reload nginx yunohost app ssowatconf after disabling ssowat --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index a470569..e7e0cab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,6 +57,8 @@ export mysqlconn="mysql -u$db_user -p$db_pwd $db_name" #================================================= ynh_print_info "disable SSOWAT temporaly" ynh_app_setting_set "$app" unprotected_uris "/" +systemctl reload nginx +yunohost app ssowatconf #================================================= # Enable default admin temporaly From ef0b8c9ad226c6b996bf0a01d150bfb97084102b Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 26 Mar 2019 09:27:49 +0100 Subject: [PATCH 60/66] Update install with ynh_install_extra_repo --- scripts/install | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index df2f530..f164c21 100644 --- a/scripts/install +++ b/scripts/install @@ -96,13 +96,9 @@ ynh_app_setting_set "$app" language "$language" ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_print_info "Install Zabbix repository" - -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 -rm zabbix-release_*.deb +ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian" --key="https://repo.zabbix.com/zabbix/4.0/debian/dists/stretch/Release.gpg" ynh_print_info "Update and install dependencies" -ynh_package_update ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq ynh_package_install zabbix-server-mysql zabbix-agent zabbix-frontend-php From 4832d25c6e160429ea21fc304d853c9da1836e77 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 26 Mar 2019 09:45:11 +0100 Subject: [PATCH 61/66] add helper experimental ynh_add_secure_repos__2 --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index f164c21..231ec27 100644 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,7 @@ source _common.sh source /usr/share/yunohost/helpers +curl -o /usr/share/yunohost/helpers.d/ynh_add_secure_repos__2 https://raw.githubusercontent.com/YunoHost-Apps/Experimental_helpers/master/ynh_add_secure_repos/ynh_add_secure_repos__2 #================================================= # MANAGE SCRIPT FAILURE From c59ffc2a6f407d93c6858d9257ea7a9fd08708e5 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 26 Mar 2019 09:49:29 +0100 Subject: [PATCH 62/66] no comment... --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 231ec27..33870c9 100644 --- a/scripts/install +++ b/scripts/install @@ -6,8 +6,8 @@ #================================================= source _common.sh +curl -o /usr/share/yunohost/helpers.d/ynh_add_secure_repos__2 https://raw.githubusercontent.com/YunoHost-Apps/Experimental_helpers/master/ynh_add_secure_repos/ynh_add_secure_repos__2 source /usr/share/yunohost/helpers -curl -o /usr/share/yunohost/helpers.d/ynh_add_secure_repos__2 https://raw.githubusercontent.com/YunoHost-Apps/Experimental_helpers/master/ynh_add_secure_repos/ynh_add_secure_repos__2 #================================================= # MANAGE SCRIPT FAILURE From 4ab488d3fdb288d7bd0cf99744d0057e2b168194 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 26 Mar 2019 09:55:47 +0100 Subject: [PATCH 63/66] change args for ynh_install_extra_repo --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 33870c9..ca76443 100644 --- a/scripts/install +++ b/scripts/install @@ -97,7 +97,7 @@ ynh_app_setting_set "$app" language "$language" ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_print_info "Install Zabbix repository" -ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian" --key="https://repo.zabbix.com/zabbix/4.0/debian/dists/stretch/Release.gpg" +ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian $(lsb_release -sc) main" --key="https://repo.zabbix.com/zabbix/4.0/debian/dists/stretch/Release.gpg" ynh_print_info "Update and install dependencies" ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq From 01474d2dbddbfa2f49d3a2f8fdf60484a771d568 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 26 Mar 2019 09:59:14 +0100 Subject: [PATCH 64/66] Update key apt --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index ca76443..2ada506 100644 --- a/scripts/install +++ b/scripts/install @@ -97,7 +97,7 @@ ynh_app_setting_set "$app" language "$language" ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_print_info "Install Zabbix repository" -ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian $(lsb_release -sc) main" --key="https://repo.zabbix.com/zabbix/4.0/debian/dists/stretch/Release.gpg" +ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian $(lsb_release -sc) main" --key="https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2%2Bstretch.dsc" ynh_print_info "Update and install dependencies" ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq From bd073b13287656fb8ed48c3792ad472d40793fee Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 26 Mar 2019 10:03:03 +0100 Subject: [PATCH 65/66] Update key gpg --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2ada506..22b79e8 100644 --- a/scripts/install +++ b/scripts/install @@ -97,7 +97,7 @@ ynh_app_setting_set "$app" language "$language" ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_print_info "Install Zabbix repository" -ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian $(lsb_release -sc) main" --key="https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2%2Bstretch.dsc" +ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian $(lsb_release -sc) main" --key="http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX" ynh_print_info "Update and install dependencies" ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq From 87cfe22bb7e7d7a335a31fa8a109e038e523e826 Mon Sep 17 00:00:00 2001 From: Mickael-Martin Date: Tue, 26 Mar 2019 10:06:01 +0100 Subject: [PATCH 66/66] Update install key --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 22b79e8..498633b 100644 --- a/scripts/install +++ b/scripts/install @@ -97,7 +97,7 @@ ynh_app_setting_set "$app" language "$language" ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_print_info "Install Zabbix repository" -ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian $(lsb_release -sc) main" --key="http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX" +ynh_install_extra_repo --repo="http://repo.zabbix.com/zabbix/4.0/debian $(lsb_release -sc) main" --key="https://repo.zabbix.com/zabbix-official-repo.key" ynh_print_info "Update and install dependencies" ynh_install_app_dependencies libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.0 php-bcmath php7.0-bcmath ttf-dejavu-core php7.0-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq