Explorar el Código

Update install avoid sed -i

Mickael-Martin hace 6 años
padre
commit
668435d13d
Se han modificado 1 ficheros con 8 adiciones y 23 borrados
  1. 8 23
      scripts/install

+ 8 - 23
scripts/install

@@ -275,32 +275,17 @@ systemctl reload nginx
 ### `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 "<?php
-// Zabbix GUI configuration file.
-global \$DB;
-
-\$DB['TYPE']     = 'MYSQL';
-\$DB['SERVER']   = 'localhost';
-\$DB['PORT']     = '0';
-\$DB['DATABASE'] = '$db_name';
-\$DB['USER']     = '$db_user';
-\$DB['PASSWORD'] = '$db_pwd';
-
-// Schema name. Used for IBM DB2 and PostgreSQL.
-\$DB['SCHEMA'] = '';
-
-\$ZBX_SERVER      = 'localhost';
-\$ZBX_SERVER_PORT = '10051';
-\$ZBX_SERVER_NAME = 'zabbix-server';
-
-\$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;">/usr/share/zabbix/conf/zabbix.conf.php
+confUserPpath=$(find /var/cache/yunohost/ -name "usr_share_zabbix_conf_zabbix.conf.php")
+cp "$confServerPath" /usr/share/zabbix/conf/zabbix.conf.php
+ynh_replace_string --match_string="db_name" --replace_string="$db_name" --target_file=/usr/share/zabbix/conf/zabbix.conf.php
+ynh_replace_string --match_string="db_user" --replace_string="$db_user" --target_file=/usr/share/zabbix/conf/zabbix.conf.php
+ynh_replace_string --match_string="db_pwd" --replace_string="$db_pwd" --target_file=/usr/share/zabbix/conf/zabbix.conf.php
 
 chown -R www-data. /usr/share/zabbix
 
-sed -i "s/DBName=zabbix/DBName=$db_name/g"  /etc/zabbix/zabbix_server.conf
-sed -i "s/DBUser=zabbix/DBUser=$db_user/g"   /etc/zabbix/zabbix_server.conf
-sed -i "126a DBPassword=$db_pwd"  /etc/zabbix/zabbix_server.conf
+ynh_replace_string --match_string="DBName=zabbix" --replace_string="DBName=$db_name" --target_file=/etc/zabbix/zabbix_server.conf
+ynh_replace_string --match_string="DBUser=zabbix" --replace_string="DBUser=$db_user" --target_file=/etc/zabbix/zabbix_server.conf
+ynh_replace_string --match_string="# DBPassword=" --replace_string="# DBPassword=\nDBPassword=$db_pwd" --target_file=/etc/zabbix/zabbix_server.conf
 
 ynh_replace_string --match_string="# Timeout=3" --replace_string="# Timeout=3\nTimeout=10" --target_file=/etc/zabbix/zabbix_agentd.conf