mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
cleaning
This commit is contained in:
parent
5d384066ec
commit
5a114fddf6
3 changed files with 24 additions and 50 deletions
|
@ -1,36 +0,0 @@
|
|||
#!/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"
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source _ynh_mysql_connect_as.sh
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
|
|
|
@ -123,8 +123,28 @@ local mount_id=$(exec_occ files_external:create --output=json \
|
|||
&& ynh_print_warn --message="Unable to create external storage" \
|
||||
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
||||
}
|
||||
# Define app's data directory
|
||||
#data_dir="/home/yunohost.app/$app/data"
|
||||
|
||||
#=================================================
|
||||
# HANDLE DATABASE MIGRATION
|
||||
#=================================================
|
||||
|
||||
mysql_db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
if [ -n "$mysql_db_pwd" ]
|
||||
then
|
||||
ynh_script_progression --message="Migrate Database..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/config/config.php"
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name
|
||||
|
||||
exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n
|
||||
|
||||
ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
|
||||
ynh_app_setting_delete --app=$app --key=mysqlpwd
|
||||
|
||||
ynh_store_file_checksum --file="${install_dir}/config/config.php"
|
||||
fi
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
|
@ -142,15 +162,6 @@ then
|
|||
# Print the current version number of Nextcloud
|
||||
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
|
||||
# Take all apps enabled, and check if mail is one of them
|
||||
|
@ -188,7 +199,7 @@ then
|
|||
# Load the value for this version
|
||||
source upgrade.d/upgrade.$current_major_version.sh
|
||||
|
||||
ynh_print_info --message="Upgrade to nextcloud $next_version"
|
||||
ynh_print_info --message="Upgrade to Nextcloud $next_version"
|
||||
|
||||
# Create an app.src for this version of Nextcloud
|
||||
cat > ../conf/app.src << EOF
|
||||
|
@ -242,7 +253,7 @@ EOF
|
|||
current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
|
||||
current_major_version=${current_version%%.*}
|
||||
|
||||
# Print the current version number of nextcloud
|
||||
# Print the current version number of Nextcloud
|
||||
exec_occ -V
|
||||
done
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue