mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
Merge branch 'testing' into enh_postgresql_migration
This commit is contained in:
commit
76bd835228
7 changed files with 93 additions and 2 deletions
|
@ -51,8 +51,8 @@
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"help": {
|
"help": {
|
||||||
"en": "If enabled, Nextcloud will be accessible by Nextcloud Desktop and by users without a YunoHost account. This can be changed later in the webadmin.",
|
"en": "You need to enable public if you want to connect Nextcloud Desktop client to Nextcloud server. This can be changed later via the webadmin.",
|
||||||
"fr": "Si cette case est cochée, Nextcloud sera accessible par Nextcloud Desktop et par les utilisateurs n’ayant pas de compte YunoHost. Vous pourrez changer dans la webadmin."
|
"fr": "Vous devez cocher cette case si vous souhaitez connecter le client Nextcloud Desktop au serveur Nextcloud. Cela peut être modifié ultérieurement via l'administrateur Web."
|
||||||
},
|
},
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
|
|
36
scripts/_ynh_mysql_connect_as.sh
Normal file
36
scripts/_ynh_mysql_connect_as.sh
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Open a connection as a user
|
||||||
|
#
|
||||||
|
# example: ynh_mysql_connect_as --user="user" --password="pass" <<< "UPDATE ...;"
|
||||||
|
# example: ynh_mysql_connect_as --user="user" --password="pass" --default_character_set="utf8mb4" < /path/to/file.sql
|
||||||
|
#
|
||||||
|
# usage: ynh_mysql_connect_as --user=user --password=password [--database=database] [--default_character_set=character-set]
|
||||||
|
# | arg: -u, --user= - the user name to connect as
|
||||||
|
# | arg: -p, --password= - the user password
|
||||||
|
# | arg: -d, --database= - the database to connect to
|
||||||
|
# | arg: -c, --default_character_set= - the charset to use
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
|
ynh_mysql_connect_as() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=updc
|
||||||
|
local -A args_array=( [u]=user= [p]=password= [d]=database= [c]=default_character_set= )
|
||||||
|
local user
|
||||||
|
local password
|
||||||
|
local database
|
||||||
|
local default_character_set
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
database="${database:-}"
|
||||||
|
default_character_set="${default_character_set:-}"
|
||||||
|
|
||||||
|
if [ -n "$default_character_set" ]
|
||||||
|
then
|
||||||
|
default_character_set="--default-character-set=$default_character_set"
|
||||||
|
else
|
||||||
|
default_character_set="--default-character-set=latin1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mysql --user="$user" --password="$password" "$default_character_set" --batch "$database"
|
||||||
|
}
|
37
scripts/_ynh_mysql_dump_db.sh
Normal file
37
scripts/_ynh_mysql_dump_db.sh
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Dump a database
|
||||||
|
#
|
||||||
|
# example: ynh_mysql_dump_db --database=roundcube --default_character_set="utf8mb4" > ./dump.sql
|
||||||
|
#
|
||||||
|
# usage: ynh_mysql_dump_db --database=database
|
||||||
|
# | arg: -d, --database= - the database name to dump
|
||||||
|
# | arg: -c, --default_character_set= - the charset to use
|
||||||
|
# | ret: the mysqldump output
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
|
ynh_mysql_dump_db() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=dc
|
||||||
|
local -A args_array=( [d]=database= [c]=default_character_set= )
|
||||||
|
local database
|
||||||
|
local default_character_set
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
default_character_set="${default_character_set:-}"
|
||||||
|
MYSQL_ROOT_PWD_FILE=/etc/yunohost/mysql
|
||||||
|
|
||||||
|
if [ -n "$default_character_set" ]
|
||||||
|
then
|
||||||
|
default_character_set="--default-character-set=$default_character_set"
|
||||||
|
else
|
||||||
|
# By default, default character set is "latin1"
|
||||||
|
default_character_set="--default-character-set=latin1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$MYSQL_ROOT_PWD_FILE" ]; then
|
||||||
|
mysqldump --user="root" --password="$(cat $MYSQL_ROOT_PWD_FILE)" --single-transaction --skip-dump-date "$default_character_set" "$database"
|
||||||
|
else
|
||||||
|
mysqldump --single-transaction --skip-dump-date "$default_character_set" "$database"
|
||||||
|
fi
|
||||||
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source ../settings/scripts/_ynh_mysql_dump_db.sh
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source _ynh_mysql_connect_as.sh
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
|
@ -79,6 +80,9 @@ ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
|
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
||||||
|
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -191,6 +195,9 @@ exec_occ maintenance:install \
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Nextcloud..." --weight=8
|
ynh_script_progression --message="Configuring Nextcloud..." --weight=8
|
||||||
|
|
||||||
|
# Set the mysql.utf8mb4 config to true in config.php
|
||||||
|
exec_occ config:system:set mysql.utf8mb4 --type boolean --value="true"
|
||||||
|
|
||||||
# Ensure that UpdateNotification app is disabled
|
# Ensure that UpdateNotification app is disabled
|
||||||
exec_occ app:disable updatenotification
|
exec_occ app:disable updatenotification
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source ../settings/scripts/_ynh_mysql_connect_as.sh
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
|
|
|
@ -276,6 +276,15 @@ then
|
||||||
# Print the current version number of Nextcloud
|
# Print the current version number of Nextcloud
|
||||||
exec_occ -V
|
exec_occ -V
|
||||||
|
|
||||||
|
if [ "$(exec_occ config:system:get mysql.utf8mb4)" != "true" ]; then
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
|
# Change your databases character set and collation
|
||||||
|
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
||||||
|
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||||
|
# Set the mysql.utf8mb4 config to true in config.php
|
||||||
|
exec_occ config:system:set mysql.utf8mb4 --type boolean --value="true"
|
||||||
|
exec_occ maintenance:repair
|
||||||
|
fi
|
||||||
|
|
||||||
# Upgrade may fail if this app is enabled
|
# Upgrade may fail if this app is enabled
|
||||||
# Take all apps enabled, and check if mail is one of them
|
# Take all apps enabled, and check if mail is one of them
|
||||||
|
|
Loading…
Add table
Reference in a new issue