This commit is contained in:
Thatoo 2024-05-23 18:51:28 +02:00 committed by GitHub
commit 439b993130
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,16 +14,25 @@
# Requires YunoHost version 2.2.4 or higher. # Requires YunoHost version 2.2.4 or higher.
ynh_mysql_connect_as() { ynh_mysql_connect_as() {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=upd local legacy_args=updc
local -A args_array=([u]=user= [p]=password= [d]=database=) local -A args_array=( [u]=user= [p]=password= [d]=database= [c]=default_character_set= )
local user local user
local password local password
local database local database
local default_character_set
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
database="${database:-}" database="${database:-}"
default_character_set="${default_character_set:-}"
mysql --user="$user" --password="$password" --batch "$database" 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"
} }
# Execute a command as root user # Execute a command as root user
@ -127,13 +136,15 @@ ynh_mysql_drop_db() {
# Requires YunoHost version 2.2.4 or higher. # Requires YunoHost version 2.2.4 or higher.
ynh_mysql_dump_db() { ynh_mysql_dump_db() {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=d local legacy_args=dc
local -A args_array=([d]=database=) local -A args_array=( [d]=database= [c]=default_character_set= )
local database local database
local default_character_set
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
default_character_set="${default_character_set:-latin1}"
mysqldump --single-transaction --skip-dump-date --routines "$database" mysqldump --single-transaction --skip-dump-date --routines --default-character-set=$default_character_set "$database"
} }
# Create a user # Create a user