diff --git a/README.md b/README.md index cc474ad..de942cd 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The YunoHost team uses [Weblate](https://weblate.org) for its community: http:// Weblate [recommands PostgreSQL](https://docs.weblate.org/en/latest/admin/install.html#database-setup-for-weblate), but YunoHost uses Mysql. -You should make sure to change this settings in your mysql config file: +Carefull, this script modify your mysql config file: * set global innodb_file_format = BARRACUDA; * set global innodb_large_prefix = ON; diff --git a/conf/settings.py b/conf/settings.py index 3324c87..b327858 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -52,7 +52,7 @@ DATABASES = { # Additional database options 'OPTIONS': { # In case of older MySQL server which has default MariaDB - 'init_command': "SET storage_engine=INNODB; SET sql_mode='STRICT_TRANS_TABLES'", + # 'init_command': "SET storage_engine=INNODB; ", # If your server supports it, see Unicode issues above 'charset': 'utf8mb4', } @@ -62,7 +62,7 @@ DATABASES = { BASE_DIR = '__FINALPATH__' # Data directory -DATA_DIR = os.path.join(BASE_DIR, '..', 'data') +DATA_DIR = os.path.join(BASE_DIR, 'data') # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/conf/weblate.cnf b/conf/weblate.cnf new file mode 100644 index 0000000..1239643 --- /dev/null +++ b/conf/weblate.cnf @@ -0,0 +1,4 @@ +[mysqld] +innodb_large_prefix=on +innodb_file_format=barracuda +innodb_file_per_table=on diff --git a/scripts/backup b/scripts/backup index 8189b9c..1eb88fe 100755 --- a/scripts/backup +++ b/scripts/backup @@ -53,6 +53,8 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/etc/nginx/conf ynh_mysql_dump_db "$db_name" > db.sql ynh_backup "db.sql" "${backup_dir}/db.sql" +ynh_backup "/etc/mysql/conf.d/$app.cnf" "${backup_dir}/etc/mysql/conf.d/$app.cnf" + #================================================= # SPECIFIC BACKUP #================================================= diff --git a/scripts/install b/scripts/install index 82186af..0df9be5 100755 --- a/scripts/install +++ b/scripts/install @@ -88,8 +88,9 @@ ynh_mysql_setup_db $db_name $db_name # https://docs.weblate.org/en/latest/admin/install.html#unicode-issues-in-mysql # http://mechanics.flite.com/blog/2014/07/29/using-innodb-large-prefix-to-avoid-error-1071/ ynh_mysql_execute_as_root "ALTER DATABASE $db_name CHARACTER SET utf8mb4;" -ynh_mysql_execute_as_root "set global innodb_file_format = BARRACUDA;" -ynh_mysql_execute_as_root "set global innodb_large_prefix = ON;" + +cp ../conf/weblate.cnf /etc/mysql/conf.d/$app.cnf +systemctl restart mysql #================================================= # NGINX CONFIGURATION @@ -149,7 +150,6 @@ virtualenv ${final_path}/venv # https://docs.weblate.org/en/latest/admin/install.html#installation # TODO: use --extra-search-dir=/path/to/dists #================================================= -echo "SPECIFIC SETUP settings.py" db_pwd=$(ynh_app_setting_get $app mysqlpwd) admin_mail="$(ynh_user_get_info $admin mail)" key=$(ynh_string_random) @@ -170,8 +170,6 @@ ynh_replace_string "__FINALPATH__" "$final_path" $final_path/venv/lib/python2.7/ # SPECIFIC SETUP Filling up the database # https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database #========================================== -echo "SPECIFIC SETUP Filling up the database" -# set up database ( set +eu source ${final_path}/venv/bin/activate @@ -185,7 +183,6 @@ echo "SPECIFIC SETUP Filling up the database" #================================================= # SETUP CRON #================================================= -echo "SETUP CRON" cp ../conf/cron_weblate /etc/cron.d/$app ynh_replace_string "__FINALPATH__" "$final_path/" /etc/cron.d/$app diff --git a/scripts/restore b/scripts/restore index 4bd3306..c486f17 100755 --- a/scripts/restore +++ b/scripts/restore @@ -59,11 +59,12 @@ ynh_restore_file "$final_path" # RESTORE THE MYSQL DATABASE #================================================= +ynh_restore_file "/etc/mysql/conf.d/$app.cnf" +systemctl restart mysql + db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql -ynh_mysql_execute_as_root "set global innodb_file_format = BARRACUDA;" -ynh_mysql_execute_as_root "set global innodb_large_prefix = ON;" #================================================= # RECREATE THE DEDICATED USER