mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Upgrade setuptools before install by pip and refactor change_url
This commit is contained in:
parent
6e1185bd78
commit
a024a62523
7 changed files with 136 additions and 98 deletions
|
@ -1,6 +1,6 @@
|
|||
location PATHTOCHANGE1 {
|
||||
location __PATH__ {
|
||||
proxy_redirect http:// https://;
|
||||
proxy_pass http://127.0.0.1:SEAHUB_PORT;
|
||||
proxy_pass http://127.0.0.1:__SEAHUB_PORT__;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
@ -21,7 +21,7 @@ location PATHTOCHANGE1 {
|
|||
}
|
||||
|
||||
location /seafhttp/ {
|
||||
proxy_pass http://127.0.0.1:SEAFILE_FILESERVER_PORT/;
|
||||
proxy_pass http://127.0.0.1:__FILESERVER_PORT__/;
|
||||
client_max_body_size 0;
|
||||
proxy_connect_timeout 36000s;
|
||||
proxy_read_timeout 36000s;
|
||||
|
@ -29,12 +29,12 @@ location /seafhttp/ {
|
|||
}
|
||||
|
||||
|
||||
location PATHTOCHANGE2media/ {
|
||||
alias ALIASTOCHANGEseafile-server-latest/seahub/media/;
|
||||
location __PATH__/media/ {
|
||||
alias __FINALPATH__seafile-server-latest/seahub/media/;
|
||||
}
|
||||
|
||||
location /seafdav {
|
||||
fastcgi_pass 127.0.0.1:WEBDAV_PORT;
|
||||
fastcgi_pass 127.0.0.1:__WEBDAV_PORT__;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_script_name;
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ get_configuration() {
|
|||
fi
|
||||
}
|
||||
|
||||
set_path_2() {
|
||||
if [[ $path == '/' ]]
|
||||
then
|
||||
path2=$path
|
||||
else
|
||||
path2=$path"/"
|
||||
fi
|
||||
}
|
||||
# set_path_2() {
|
||||
# if [[ $path == '/' ]]
|
||||
# then
|
||||
# path2=$path
|
||||
# else
|
||||
# path2=$path"/"
|
||||
# fi
|
||||
# }
|
||||
|
||||
config_nginx() {
|
||||
|
||||
|
@ -54,15 +54,17 @@ config_nginx() {
|
|||
ynh_app_setting_set $app fileserver_port $fileserver_port
|
||||
fi
|
||||
|
||||
ynh_replace_string PATHTOCHANGE1 $path ../conf/nginx.conf
|
||||
ynh_replace_string PATHTOCHANGE2 $path2 ../conf/nginx.conf
|
||||
ynh_replace_string ALIASTOCHANGE $final_path/ ../conf/nginx.conf
|
||||
ynh_replace_string SEAHUB_PORT $seahub_port ../conf/nginx.conf
|
||||
ynh_replace_string SEAFILE_FILESERVER_PORT $fileserver_port ../conf/nginx.conf
|
||||
ynh_replace_string WEBDAV_PORT $webdav_port ../conf/nginx.conf
|
||||
cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
||||
|
||||
systemctl reload nginx.service
|
||||
# ynh_replace_string PATHTOCHANGE1 $path ../conf/nginx.conf
|
||||
# ynh_replace_string PATHTOCHANGE2 $path2 ../conf/nginx.conf
|
||||
# ynh_replace_string ALIASTOCHANGE $final_path/ ../conf/nginx.conf
|
||||
# ynh_replace_string SEAHUB_PORT $seahub_port ../conf/nginx.conf
|
||||
# ynh_replace_string SEAFILE_FILESERVER_PORT $fileserver_port ../conf/nginx.conf
|
||||
# ynh_replace_string WEBDAV_PORT $webdav_port ../conf/nginx.conf
|
||||
# cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
||||
#
|
||||
# systemctl reload nginx.service
|
||||
|
||||
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
}
|
||||
|
||||
install_source() {
|
||||
|
@ -71,10 +73,11 @@ install_source() {
|
|||
}
|
||||
|
||||
install_dependance() {
|
||||
ynh_install_app_dependencies python2.7 python-pip python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect python-requests python-dev
|
||||
ynh_install_app_dependencies python2.7 python-pip python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect python-requests python-dev \
|
||||
libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev tcl8.6-dev tk8.6-dev python-tk # For building pillow
|
||||
# Upgrade setuptools for jessie because the new moviepy package is not compatible with setuptools 5.x
|
||||
[ "$(lsb_release --codename --short)" = "jessie" ] && pip install --upgrade setuptools
|
||||
pip install pillow moviepy
|
||||
pip install --upgrade pillow moviepy
|
||||
}
|
||||
|
||||
ynh_clean_setup () {
|
||||
|
|
|
@ -16,16 +16,12 @@ source ./_common.sh
|
|||
|
||||
# Retrive arguments
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
|
||||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$(ynh_normalize_url_path ${YNH_APP_OLD_PATH:-'/'})
|
||||
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH:-'/'})
|
||||
seahub_port=$(ynh_app_setting_get $app seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get $app fileserver_port)
|
||||
webdav_port=$(ynh_app_setting_get $app webdav_port)
|
||||
|
||||
# Get dest folder and system user
|
||||
get_configuration
|
||||
|
@ -35,67 +31,54 @@ if [[ $old_path == '/' ]]
|
|||
then
|
||||
old_path2=$old_path
|
||||
else
|
||||
old_path2=$old_path'/'
|
||||
old_path2=$old_path'/'
|
||||
fi
|
||||
|
||||
if [[ $new_path == '/' ]]
|
||||
if [[ $path_url == '/' ]]
|
||||
then
|
||||
new_path2=$new_path
|
||||
path_url2=$path_url
|
||||
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
|
||||
path_url2=$path_url'/'
|
||||
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 ]
|
||||
# Update nginx config
|
||||
if [ "$old_domain" != "$domain" ]
|
||||
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
|
||||
old_file_path="/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
new_file_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
mv "$old_file_path" "$new_file_path"
|
||||
|
||||
# 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
|
||||
# Change the checksum setting name
|
||||
checksum_setting_old_name=checksum_${old_file_path//[\/ ]/_}
|
||||
checksum_setting_new_name=checksum_${new_file_path//[\/ ]/_}
|
||||
checksum_value=$(ynh_app_setting_get $app $checksum_setting_old_name)
|
||||
ynh_app_setting_set $app $checksum_setting_new_name $checksum_value
|
||||
fi
|
||||
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
|
||||
|
||||
# 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 "SERVICE_URL = https://$old_domain$old_path" "SERVICE_URL = https://$domain$path_url" $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
|
||||
sed --in-place "s@ALLOWED_HOSTS = \['${old_domain}'\]@ALLOWED_HOSTS = \['${new_domain}'\]@g" $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string 'FILE_SERVER_ROOT = "https://'"$old_domain"'/seafhttp"' 'FILE_SERVER_ROOT = "https://'"$domain"'/seafhttp"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string 'SITE_ROOT = "'"$old_path2"'"' 'SITE_ROOT = "'"$path_url2"'"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string 'MEDIA_URL = "'"$old_path2"'media/"' 'MEDIA_URL = "'"$path_url2"'media/"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string "LOGIN_URL = '${old_path2}accounts/login/'" "LOGIN_URL = '${path_url2}accounts/login/'" $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string ' = "seafile@'"$old_domain"'"' ' = "seafile@'"$domain"'"' $final_path/conf/seahub_settings.py
|
||||
sed --in-place "s@ALLOWED_HOSTS = \['${old_domain}'\]@ALLOWED_HOSTS = \['${domain}'\]@g" $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')"
|
||||
sql_request='UPDATE `'"$2"'` SET '"$3 = replace($3, '$old_domain', '$domain')"
|
||||
ynh_mysql_execute_as_root "$sql_request" $1
|
||||
}
|
||||
|
||||
|
@ -157,15 +140,3 @@ mysql_relpace_db seahubdb wiki_personalwiki username
|
|||
# Reload services
|
||||
sudo systemctl reload nginx.service
|
||||
sudo systemctl start seafile-server.service
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -54,3 +54,65 @@ ynh_app_package_version () {
|
|||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||
echo "${version_key/*~ynh/}"
|
||||
}
|
||||
|
||||
|
||||
# Create a dedicated nginx config
|
||||
#
|
||||
# usage: ynh_add_nginx_config "list of others variables to replace"
|
||||
#
|
||||
# | arg: list of others variables to replace separeted by a space
|
||||
# | for example : 'path_2 port_2 ...'
|
||||
#
|
||||
# This will use a template in ../conf/nginx.conf
|
||||
# __PATH__ by $path_url
|
||||
# __DOMAIN__ by $domain
|
||||
# __PORT__ by $port
|
||||
# __NAME__ by $app
|
||||
# __FINALPATH__ by $final_path
|
||||
#
|
||||
# And dynamic variables (from the last example) :
|
||||
# __PATH_2__ by $path_2
|
||||
# __PORT_2__ by $port_2
|
||||
#
|
||||
ynh_add_nginx_config () {
|
||||
local finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
local others_var=${1:-}
|
||||
ynh_backup_if_checksum_is_different "$finalnginxconf"
|
||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
||||
|
||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||
# Substitute in a nginx config file only if the variable is not empty
|
||||
if test -n "${path_url:-}"; then
|
||||
# path_url_slash_less is path_url, or a blank value if path_url is only '/'
|
||||
local path_url_slash_less=${path_url%/}
|
||||
ynh_replace_string "__PATH__/" "$path_url_slash_less/" "$finalnginxconf"
|
||||
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${domain:-}"; then
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${port:-}"; then
|
||||
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${app:-}"; then
|
||||
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${final_path:-}"; then
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
|
||||
fi
|
||||
|
||||
# Replace all other variable given as arguments
|
||||
for v in $others_var
|
||||
do
|
||||
ynh_replace_string "__${v^^}__" "${!v}" "$finalnginxconf"
|
||||
done
|
||||
|
||||
if [ "${path_url:-}" != "/" ]
|
||||
then
|
||||
ynh_replace_string "^#sub_path_only" "" "$finalnginxconf"
|
||||
fi
|
||||
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
|
||||
sudo systemctl reload nginx
|
||||
}
|
|
@ -16,7 +16,7 @@ source ./_common.sh
|
|||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
server_name="$YNH_APP_ARG_SERVER_NAME"
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
|
@ -26,11 +26,16 @@ final_path=/opt/yunohost/$app
|
|||
seafile_user=seafile
|
||||
|
||||
# Create special path with / at the end
|
||||
set_path_2
|
||||
if [[ $path_url == '/' ]]
|
||||
then
|
||||
path_url2=$path_url
|
||||
else
|
||||
path_url2=$path_url"/"
|
||||
fi
|
||||
|
||||
# Check domain/path availability
|
||||
test $(ynh_webpath_available $domain $path) == 'True' || ynh_die "$domain$path is not available, please use an other domain or path."
|
||||
ynh_webpath_register $app $domain $path
|
||||
test $(ynh_webpath_available $domain $path_url) == 'True' || ynh_die "$domain$path_url is not available, please use an other domain or path."
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
|
||||
# Check Final Path availability
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
@ -89,11 +94,11 @@ chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
|
|||
|
||||
# Update seafile config
|
||||
ynh_replace_string http:// https:// $final_path/conf/ccnet.conf
|
||||
ynh_replace_string :8000 $path $final_path/conf/ccnet.conf
|
||||
ynh_replace_string :8000 $path_url $final_path/conf/ccnet.conf
|
||||
echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'SITE_ROOT = "'$path2'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'SITE_ROOT = "'$path_url2'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'SERVE_STATIC = False' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'MEDIA_URL = "'$path2'media/"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'MEDIA_URL = "'$path_url2'media/"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "LOGIN_URL = '"$path2"accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
|
|
|
@ -16,12 +16,12 @@ source ../settings/scripts/_common.sh
|
|||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
||||
seafile_data=/home/yunohost.app/seafile-data
|
||||
|
||||
# Check domain/path availability
|
||||
ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain or path."
|
||||
ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain or path."
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
|
|
@ -19,7 +19,7 @@ get_configuration
|
|||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||
installed_version=$(ynh_app_setting_get $app installed_version)
|
||||
seahub_port=$(ynh_app_setting_get $app seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get $app fileserver_port)
|
||||
|
@ -29,9 +29,6 @@ root_pwd=$(cat /etc/yunohost/mysql)
|
|||
# Get configuration for user and final path
|
||||
get_configuration
|
||||
|
||||
# Create special path with / at the end
|
||||
set_path_2
|
||||
|
||||
# stop seafile server
|
||||
systemctl stop seafile-server.service
|
||||
|
||||
|
@ -133,7 +130,7 @@ fi
|
|||
# Update seahub config for old version to version 5.0.4
|
||||
if [[ $(grep -c "LOGIN_URL" $final_path/conf/seahub_settings.py) == 0 ]]
|
||||
then
|
||||
echo "LOGIN_URL = '$path/accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "LOGIN_URL = '$path_url/accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
fi
|
||||
|
||||
# Fix local warning
|
||||
|
|
Loading…
Reference in a new issue