mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Cleanup action
This commit is contained in:
parent
8fc798ef47
commit
2139b5d744
2 changed files with 0 additions and 205 deletions
28
actions.json
28
actions.json
|
@ -1,28 +0,0 @@
|
|||
[
|
||||
{
|
||||
"id": "change_user_email",
|
||||
"name": "Change user email of user",
|
||||
"command": "bash scripts/actions",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Low level function : Change manually the email for the user authentication to a other email.\nBy example 'toto@seafile-domain.tld' will be renamed to the new email 'toto@main-yunohost-domain.tld'. Note that when do you this change the email need to be also changed in all client !!"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"name": "old_email",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Old user email"
|
||||
},
|
||||
"example": "toto@seafile-domain.tld"
|
||||
}, {
|
||||
"name": "new_email",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "New user email"
|
||||
},
|
||||
"example": "toto@main-yunohost-domain.tld"
|
||||
}
|
||||
]
|
||||
}]
|
177
scripts/actions
177
scripts/actions
|
@ -1,177 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
||||
# Import common cmd
|
||||
source scripts/experimental_helper.sh
|
||||
source scripts/_common.sh
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
# Retrive arguments
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
|
||||
#=================================================
|
||||
# FUNCTION DECLARATION
|
||||
#=================================================
|
||||
|
||||
stop_seafile() {
|
||||
ynh_print_info --message="Stoping seafile..."
|
||||
|
||||
# Stop service before any change
|
||||
ynh_systemd_action --service_name seafile --action stop
|
||||
ynh_systemd_action --service_name seahub --action stop
|
||||
sleep 2
|
||||
pkill -f seafile-controller || true
|
||||
pkill -f seaf-server || true
|
||||
pkill -f ccnet-server || true
|
||||
pkill -f seahub || true
|
||||
}
|
||||
|
||||
start_seafile(){
|
||||
ynh_print_info --message="Starting seafile..."
|
||||
# Avoid the current effect
|
||||
sleep 2
|
||||
|
||||
# Reload services
|
||||
ynh_print_info --message="Starting services..."
|
||||
ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd"
|
||||
sleep 2
|
||||
}
|
||||
|
||||
get_email_list_in_seafile() {
|
||||
sql_request='SELECT email FROM `EmailUser`; SELECT email FROM `LDAPUsers`'
|
||||
all_user_list=$(ynh_mysql_execute_as_root --sql "$sql_request" --database ccnetdb | grep -v "^email$")
|
||||
user_list=$(echo "$all_user_list" | grep "@$domain$" || true)
|
||||
}
|
||||
|
||||
migrate_email_in_database() {
|
||||
|
||||
ynh_print_info --message="Migrating email $1 to $2"
|
||||
local old_email=$1
|
||||
local new_email=$2
|
||||
sleep 1
|
||||
|
||||
if [[ "$all_user_list" =~ "$new_email" ]]; then
|
||||
ynh_print_err --message "The user '$new_email' already exist in seafile, can rename '$old_email' to '$new_email'"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! [[ "$all_user_list" =~ "$old_email" ]]; then
|
||||
ynh_print_err --message "The user '$old_email' don't exist in seafile, can rename '$old_email' to '$new_email'"
|
||||
return
|
||||
fi
|
||||
|
||||
# Update database
|
||||
|
||||
# This fonction relplace all old domain name by the new domain name.
|
||||
# use : mysql_relpace_db db_name table collum
|
||||
mysql_relpace_db() {
|
||||
sql_request='UPDATE `'"$2"'` SET '"$3 = replace($3, '$old_email', '$new_email')"
|
||||
ynh_mysql_execute_as_root --sql "$sql_request" --database $1
|
||||
}
|
||||
|
||||
# TODO check DB update
|
||||
# ccnet DB
|
||||
mysql_relpace_db ccnetdb Binding email
|
||||
mysql_relpace_db ccnetdb EmailUser email
|
||||
mysql_relpace_db ccnetdb Group creator_name
|
||||
mysql_relpace_db ccnetdb GroupUser user_name
|
||||
mysql_relpace_db ccnetdb LDAPUsers email
|
||||
mysql_relpace_db ccnetdb Organization creator
|
||||
mysql_relpace_db ccnetdb OrgUser email
|
||||
mysql_relpace_db ccnetdb UserRole email
|
||||
|
||||
# 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 $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
|
||||
mysql_relpace_db seahubdb api2_tokenv2 user
|
||||
mysql_relpace_db seahubdb auth_user email
|
||||
mysql_relpace_db seahubdb auth_user username
|
||||
mysql_relpace_db seahubdb auth_user_groups user_id
|
||||
mysql_relpace_db seahubdb auth_user_user_permissions user_id
|
||||
mysql_relpace_db seahubdb avatar_avatar emailuser
|
||||
mysql_relpace_db seahubdb base_clientlogintoken username
|
||||
mysql_relpace_db seahubdb base_devicetoken user
|
||||
mysql_relpace_db seahubdb base_filecomment author
|
||||
mysql_relpace_db seahubdb base_innerpubmsg from_email
|
||||
mysql_relpace_db seahubdb base_innerpubmsgreply from_email
|
||||
mysql_relpace_db seahubdb base_userenabledmodule username
|
||||
mysql_relpace_db seahubdb base_userlastlogin username
|
||||
mysql_relpace_db seahubdb base_userstarredfiles email
|
||||
mysql_relpace_db seahubdb django_cas_ng_proxygrantingticket user || true
|
||||
mysql_relpace_db seahubdb drafts_draft username
|
||||
mysql_relpace_db seahubdb group_groupmessage from_email
|
||||
mysql_relpace_db seahubdb group_messagereply from_email
|
||||
mysql_relpace_db seahubdb institutions_institutionadmin user
|
||||
mysql_relpace_db seahubdb notifications_usernotification to_user
|
||||
mysql_relpace_db seahubdb options_useroptions email
|
||||
mysql_relpace_db seahubdb post_office_attachment_emails email_id
|
||||
mysql_relpace_db seahubdb post_office_email from_email
|
||||
mysql_relpace_db seahubdb profile_profile user
|
||||
mysql_relpace_db seahubdb profile_profile login_id
|
||||
mysql_relpace_db seahubdb profile_profile contact_email
|
||||
mysql_relpace_db seahubdb registration_registrationprofile emailuser_id
|
||||
mysql_relpace_db seahubdb role_permissions_adminrole email
|
||||
mysql_relpace_db seahubdb share_anonymousshare repo_owner
|
||||
mysql_relpace_db seahubdb share_extrasharepermission share_to
|
||||
mysql_relpace_db seahubdb share_fileshare username
|
||||
mysql_relpace_db seahubdb share_privatefiledirshare from_user
|
||||
mysql_relpace_db seahubdb share_privatefiledirshare to_user
|
||||
mysql_relpace_db seahubdb share_uploadlinkshare username
|
||||
mysql_relpace_db seahubdb social_auth_code email || true
|
||||
mysql_relpace_db seahubdb social_auth_usersocialauth username
|
||||
mysql_relpace_db seahubdb sysadmin_extra_userloginlog username
|
||||
mysql_relpace_db seahubdb tags_filetag username
|
||||
mysql_relpace_db seahubdb termsandconditions_usertermsandconditions username
|
||||
mysql_relpace_db seahubdb two_factor_phonedevice user
|
||||
mysql_relpace_db seahubdb two_factor_staticdevice user
|
||||
mysql_relpace_db seahubdb two_factor_totpdevice user
|
||||
mysql_relpace_db seahubdb wiki_personalwiki username
|
||||
mysql_relpace_db seahubdb wiki_wiki username
|
||||
|
||||
ynh_print_info --message="Migration of email $1 to $2 done"
|
||||
}
|
||||
|
||||
migrate_user() {
|
||||
stop_seafile
|
||||
get_email_list_in_seafile
|
||||
|
||||
migrate_email_in_database $YNH_ACTION_OLD_EMAIL $YNH_ACTION_NEW_EMAIL
|
||||
|
||||
start_seafile
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
case $YNH_ACTION in
|
||||
change_user_email) migrate_user;;
|
||||
esac
|
Loading…
Reference in a new issue