mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Add change_url script
This commit is contained in:
parent
60a41c7df7
commit
48ecc1f2bf
2 changed files with 164 additions and 2 deletions
11
README.md
11
README.md
|
@ -27,7 +27,7 @@ From command line:
|
|||
Infos
|
||||
-----
|
||||
|
||||
Seafile server v6.0.6
|
||||
Seafile server v6.1.0
|
||||
|
||||
Available for x64, i386, and Raspberry Pi architecture but only tested for x64 (feedback are welcome)
|
||||
|
||||
|
@ -35,6 +35,13 @@ Seafile no longer distribute binary for generic armhf architectures but rpi bina
|
|||
|
||||
/!\ To login use your yunohost email not your username.
|
||||
|
||||
Change URL
|
||||
----------
|
||||
|
||||
Since now it's possible to change domain or the url of seafile but use it with precaution because it has not been tested enought for a big production installation. For the authentification and user every email for authentification will have the new domain name. For example `toto@old_domain.tld` will be `toto@new_domain.tld`.
|
||||
|
||||
To do this run : `yunohost app change-url seafile -d new_domain.tld -p PATH new_path
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
|
@ -52,7 +59,7 @@ TODO
|
|||
- Auto login/logout, see #1
|
||||
- Test of backup/restore script
|
||||
|
||||
Use a spial user and put seafile binary in /opt dir :
|
||||
Use a special user and put seafile binary in /opt dir :
|
||||
--------------------------------------
|
||||
|
||||
With this new package for a better security, it's possible to run seafile with a special user (seafile) put all seafile file in /opt/yunohost dir.
|
||||
|
|
155
scripts/change_url
Normal file
155
scripts/change_url
Normal file
|
@ -0,0 +1,155 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Import common cmd
|
||||
source ./_common.sh
|
||||
|
||||
# Retrive arguments
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$(ynh_normalize_url_path $YNH_APP_OLD_PATH)
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$(ynh_normalize_url_path $YNH_APP_NEW_PATH)
|
||||
|
||||
get_configuration
|
||||
|
||||
# Create special path with / at the end
|
||||
if [[ $old_path == '/' ]]
|
||||
then
|
||||
old_path2=$old_path
|
||||
else
|
||||
old_path2=$old_path'/'
|
||||
fi
|
||||
|
||||
if [[ $new_path == '/' ]]
|
||||
then
|
||||
new_path2=$new_path
|
||||
else
|
||||
new_path2=$new_path'/'
|
||||
fi
|
||||
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
# STANDARD MODIFICATIONS
|
||||
# MODIFY URL IN NGINX CONF
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
ynh_replace_string "location $old_path {" "location $new_path {" "$nginx_conf_path"
|
||||
ynh_replace_string "location ${old_path2}media {" "location ${new_path2}media {" "$nginx_conf_path"
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
sudo mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
fi
|
||||
|
||||
# Stop service before any change
|
||||
sudo systemctl stop seafile-server.service
|
||||
|
||||
# Update Seafile Config
|
||||
ynh_replace_string "SERVICE_URL = https://$old_domain$old_path" "SERVICE_URL = https://$new_domain$new_path" $final_path/conf/ccnet.conf
|
||||
|
||||
ynh_replace_string 'FILE_SERVER_ROOT = "https://'"$old_domain"'/seafhttp"' 'FILE_SERVER_ROOT = "https://'"$new_domain"'/seafhttp"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string 'SITE_ROOT = "'"$old_path2"'"' 'SITE_ROOT = "'"$new_path2"'"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string 'MEDIA_URL = "'"$old_path2"'media/"' 'MEDIA_URL = "'"$new_path2"'media/"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string "LOGIN_URL = '${old_path2}accounts/login/'" "LOGIN_URL = '${new_path2}accounts/login/'" $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string ' = "seafile@'"$old_domain"'"' ' = "seafile@'"$new_domain"'"' $final_path/conf/seahub_settings.py
|
||||
|
||||
# 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_domain', '$new_domain')"
|
||||
ynh_mysql_execute_as_root "$sql_request" $1
|
||||
}
|
||||
|
||||
# ccnet DB
|
||||
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
|
||||
mysql_relpace_db seafiledb OrgUserQuota user
|
||||
mysql_relpace_db seafiledb RepoGroup user_name
|
||||
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
|
||||
|
||||
# seahub DB
|
||||
mysql_relpace_db seahubdb api2_token user
|
||||
mysql_relpace_db seahubdb api2_tokenv2 user
|
||||
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 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 share_anonymousshare repo_owner
|
||||
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 sysadmin_extra_userloginlog 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
|
||||
|
||||
# Reload services
|
||||
sudo systemctl reload nginx.service
|
||||
sudo systemctl start seafile-server.service
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue