mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Fix issues
This commit is contained in:
parent
7b40b86c96
commit
4d349f0090
7 changed files with 48 additions and 53 deletions
11
actions.json
11
actions.json
|
@ -1,13 +1,4 @@
|
|||
[{
|
||||
"id": "migrate_user_email_to_mail_email",
|
||||
"name": "Migrate all user email with seafile domain to main user email",
|
||||
"command": "bash scripts/actions",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Hight level function : Change automatically the email for the user authentication to a the main user email. This function should be run when you migrate from seafile 6 to seafile 7.\nBy example 'toto@seafile-domain.tld' will be renamed to the new email 'toto-main-email@main-yunohost-domain.tld'. Note that when do you this change the email need to be also changed in all client !!"
|
||||
}
|
||||
},
|
||||
[
|
||||
{
|
||||
"id": "change_user_email",
|
||||
"name": "Change user email of user",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[General]
|
||||
SERVICE_URL = https://__DOMAIN____PATH__
|
||||
|
||||
[Database]
|
||||
ENGINE = mysql
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# SET ALL CONSTANTS
|
||||
#=================================================
|
||||
|
||||
db_user=seafile
|
||||
time_zone=$(cat /etc/timezone)
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -93,21 +93,21 @@ migrate_email_in_database() {
|
|||
|
||||
# seafile DB
|
||||
# Note that when we do a migration from seafile v6 some time don't exist. So yes it's probably a bug on seafile side. But anyway just ignore this problem...
|
||||
mysql_relpace_db seafiledb FolderUserPerm user || true
|
||||
mysql_relpace_db seafiledb OrgGroupRepo owner || true
|
||||
mysql_relpace_db seafiledb OrgRepo user || true
|
||||
mysql_relpace_db seafiledb OrgSharedRepo from_email || true
|
||||
mysql_relpace_db seafiledb OrgSharedRepo to_email || true
|
||||
mysql_relpace_db seafiledb OrgUserQuota user
|
||||
mysql_relpace_db seafiledb RepoGroup user_name
|
||||
mysql_relpace_db seafiledb RepoInfo last_modifier
|
||||
mysql_relpace_db seafiledb RepoOwner owner_id
|
||||
mysql_relpace_db seafiledb RepoTrash owner_id
|
||||
mysql_relpace_db seafiledb RepoUserToken email
|
||||
mysql_relpace_db seafiledb SharedRepo from_email
|
||||
mysql_relpace_db seafiledb SharedRepo to_email
|
||||
mysql_relpace_db seafiledb UserQuota user
|
||||
mysql_relpace_db seafiledb UserShareQuota user
|
||||
mysql_relpace_db $db_name FolderUserPerm user || true
|
||||
mysql_relpace_db $db_name OrgGroupRepo owner || true
|
||||
mysql_relpace_db $db_name OrgRepo user || true
|
||||
mysql_relpace_db $db_name OrgSharedRepo from_email || true
|
||||
mysql_relpace_db $db_name OrgSharedRepo to_email || true
|
||||
mysql_relpace_db $db_name OrgUserQuota user
|
||||
mysql_relpace_db $db_name RepoGroup user_name
|
||||
mysql_relpace_db $db_name RepoInfo last_modifier
|
||||
mysql_relpace_db $db_name RepoOwner owner_id
|
||||
mysql_relpace_db $db_name RepoTrash owner_id
|
||||
mysql_relpace_db $db_name RepoUserToken email
|
||||
mysql_relpace_db $db_name SharedRepo from_email
|
||||
mysql_relpace_db $db_name SharedRepo to_email
|
||||
mysql_relpace_db $db_name UserQuota user
|
||||
mysql_relpace_db $db_name UserShareQuota user
|
||||
|
||||
# seahub DB
|
||||
mysql_relpace_db seahubdb api2_token user
|
||||
|
@ -168,33 +168,10 @@ migrate_user() {
|
|||
start_seafile
|
||||
}
|
||||
|
||||
migrate_all_user() {
|
||||
stop_seafile
|
||||
get_email_list_in_seafile
|
||||
|
||||
for user in $user_list; do
|
||||
# Try to get the main email of the user in yunohost which has is the old email
|
||||
user_main_email=$(yunohost tools shell -c "
|
||||
from yunohost.user import user_info
|
||||
info = user_info('$user'.split('@')[0])
|
||||
print(info['mail'])
|
||||
exit()
|
||||
")
|
||||
if [ "$user" == "$user_main_email" ]; then
|
||||
ynh_print_info --message "Nothing to do for user $user."
|
||||
fi
|
||||
|
||||
migrate_email_in_database $user $user_main_email
|
||||
done
|
||||
|
||||
start_seafile
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
case $YNH_ACTION in
|
||||
migrate_user_email_to_mail_email) migrate_all_user;;
|
||||
change_user_email) migrate_user;;
|
||||
esac
|
||||
|
|
|
@ -18,6 +18,14 @@ source /usr/share/yunohost/helpers
|
|||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
# Create special path with / at the end
|
||||
if [[ $path == '/' ]]
|
||||
then
|
||||
path2=$path
|
||||
else
|
||||
path2=$path"/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
|
|
|
@ -32,8 +32,8 @@ ynh_script_progression --message="Restoring database..." --weight=3
|
|||
db_helper=ynh_"mysql"_setup_db
|
||||
$db_helper --db_user $db_user --db_name ccnetdb --db_pwd "$db_pwd"
|
||||
$db_helper --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd"
|
||||
su -c "mysql -u ${app} -p$db_pwd $db_name < ${YNH_CWD}/seafiledb.dmp"
|
||||
su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${YNH_CWD}/ccnetdb.dmp"
|
||||
su -c "mysql -u ${app} -p$db_pwd seafiledb < ${YNH_CWD}/seafiledb.dmp"
|
||||
su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -15,6 +15,14 @@ source /usr/share/yunohost/helpers
|
|||
installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/}
|
||||
seafile_version=$(ynh_app_upstream_version)
|
||||
|
||||
# Create special path with / at the end
|
||||
if [[ $path == '/' ]]
|
||||
then
|
||||
path2=$path
|
||||
else
|
||||
path2=$path"/"
|
||||
fi
|
||||
|
||||
if [ "$YNH_APP_CURRENT_VERSION" == '-' ]; then
|
||||
ynh_die "Upgrade from this version not supported"
|
||||
fi
|
||||
|
@ -39,10 +47,21 @@ pkill -f seaf-server || true
|
|||
pkill -f ccnet-server || true
|
||||
pkill -f seahub || true
|
||||
|
||||
# Migrate DB if needed
|
||||
# Migrate DB name if needed
|
||||
if mysqlshow | grep -q seafiledb; then
|
||||
ynh_mysql_execute_as_root --sql 'DROP DATABASE `'$db_name'`'
|
||||
ynh_mysql_execute_as_root --sql 'RENAME DATABASE `seafiledb TO "'$db_name'"'
|
||||
mysqlconn="mysql -u root"
|
||||
sql_mv_params=$($mysqlconn -N -e "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES \
|
||||
WHERE table_schema='seafiledb'")
|
||||
for name in $sql_mv_params; do
|
||||
$mysqlconn -e "RENAME TABLE seafiledb.$name to $db_name.$name";
|
||||
done;
|
||||
$mysqlconn -e "DROP DATABASE seafiledb"
|
||||
fi
|
||||
|
||||
# Set missing settings
|
||||
if [ -z ${seahub_secret_key:-} ]; then
|
||||
seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*".+"' $install_dir/conf/seahub_settings.py | cut -d'"' -f2)
|
||||
ynh_app_setting_set --app $app --key seahub_secret_key --value $seahub_secret_key
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||
|
|
Loading…
Add table
Reference in a new issue