From 538d444e2c3790cd2cfdbabde9a5d9e7d4b2ae7a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 10 Jan 2021 19:39:28 +0100 Subject: [PATCH] Fix --- conf/config.json | 4 ++-- conf/systemd.service | 2 +- scripts/_common.sh | 2 +- scripts/install | 16 +++++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/conf/config.json b/conf/config.json index f0519ea..25715ec 100644 --- a/conf/config.json +++ b/conf/config.json @@ -143,8 +143,8 @@ "IosMinVersion": "" }, "SqlSettings": { - "DriverName": "mysql", - "DataSource": "mysql://__DB_NAME__:__DB_PASS__@tcp(localhost:3306)/__DB_NAME__?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s", + "DriverName": "postgres", + "DataSource": "postgres://__DB_NAME__:__DB_PASS__@localhost:5432/__DB_NAME__?sslmode=disable&connect_timeout=10", "DataSourceReplicas": [], "DataSourceSearchReplicas": [], "MaxIdleConns": 20, diff --git a/conf/systemd.service b/conf/systemd.service index 0a3b276..a3d5a8b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -2,7 +2,7 @@ Description=Mattermost After=network.target After=mysql.service -Requires=mysql.service +Requires=postgresql.service [Service] Type=notify diff --git a/scripts/_common.sh b/scripts/_common.sh index bbb46c4..bd179f8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql apt-transport-https" +pkg_dependencies="postgresql postgresql-contrib" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index f2a667f..b5b2238 100644 --- a/scripts/install +++ b/scripts/install @@ -73,22 +73,24 @@ logs_path="/var/log/$app" #================================================= # INSTALL DEPENDENCIES #================================================= -# ynh_script_progression --message="Installing dependencies..." --weight=10 +ynh_script_progression --message="Installing dependencies..." --weight=10 -# ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_script_progression --message="Creating a MySQL database..." --time --weight=1 +ynh_script_progression --message="Creating a PostgreSQL database..." --time --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -db_pwd=$(ynh_string_random --length=24) +db_pwd=$(ynh_string_random --length=30) ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name -ynh_app_setting_set --app=$app --key=mysqlpwd --value=$db_pwd +ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd + +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #================================================= # CREATE DEDICATED USER @@ -138,7 +140,7 @@ ynh_replace_string --match_string="__DATA__" --replace_string="$data_path" --tar ynh_replace_string --match_string="__FEEDBACK__" --replace_string="no-reply@${domain}" --target_file="$final_path/config/config.json" ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$final_path/config/config.json" -ynh_replace_string --match_string="__USER_PW__" --replace_string="$mattermost_user_password" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__USER_PW__" --replace_string="$(ynh_string_random --length=24)" --target_file="$final_path/config/config.json" ynh_replace_string --match_string="__LOG__" --replace_string="$logs_path" --target_file="$final_path/config/config.json"