mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
First draft packaging v2
This commit is contained in:
parent
f29b962c43
commit
548d59accf
16 changed files with 98 additions and 655 deletions
|
@ -1,11 +0,0 @@
|
|||
SOURCE_URL=https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_9.0.2_x86-64.tar.gz
|
||||
SOURCE_SUM=5adb3c800cd48de38b6e5d9b073e03ff375cfa30208a7291c481cdf1e1cf167b
|
||||
# (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# default: sha256
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
# (Optional) Archive format
|
||||
# default: tar.gz
|
||||
SOURCE_FORMAT=tar.gz
|
||||
# (Optional) Put false if sources are directly in the archive root
|
||||
# default: true
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,11 +0,0 @@
|
|||
SOURCE_URL=https://download.seadrive.org/seafile-server_7.0.5_x86-64.tar.gz
|
||||
SOURCE_SUM=7eb8814f1bc8ee78c80741fa08cbdce2b5ea8895a87730bde2a1b32d031e8f53
|
||||
# (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# default: sha256
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
# (Optional) Archive format
|
||||
# default: tar.gz
|
||||
SOURCE_FORMAT=tar.gz
|
||||
# (Optional) Put false if sources are directly in the archive root
|
||||
# default: true
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,11 +0,0 @@
|
|||
SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v9.0.2/seafile-server-9.0.2-buster-arm64v8l.tar.gz
|
||||
SOURCE_SUM=0332a57364f92eaefe0109e5a65f8e3a3b909c3805b9113431d4bde2a962d78c
|
||||
# (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# default: sha256
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
# (Optional) Archive format
|
||||
# default: tar.gz
|
||||
SOURCE_FORMAT=tar.gz
|
||||
# (Optional) Put false if sources are directly in the archive root
|
||||
# default: true
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,11 +0,0 @@
|
|||
SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v7.0.5/seafile-server_7.0.5_stable_pi.tar.gz
|
||||
SOURCE_SUM=dae9ab5d232a2b56f129aa29e7e54d2de05d838f0479955543cebcb14c9417db
|
||||
# (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# default: sha256
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
# (Optional) Archive format
|
||||
# default: tar.gz
|
||||
SOURCE_FORMAT=tar.gz
|
||||
# (Optional) Put false if sources are directly in the archive root
|
||||
# default: true
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,11 +0,0 @@
|
|||
SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v9.0.2/seafile-server-9.0.2-buster-arm32v7l.tar.gz
|
||||
SOURCE_SUM=2aa42caa1420842435ee8a386fb9f3244a0d286a4c1f829a97cba49b41b274df
|
||||
# (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# default: sha256
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
# (Optional) Archive format
|
||||
# default: tar.gz
|
||||
SOURCE_FORMAT=tar.gz
|
||||
# (Optional) Put false if sources are directly in the archive root
|
||||
# default: true
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,11 +0,0 @@
|
|||
SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v7.0.5/seafile-server_7.0.5_stable_pi.tar.gz
|
||||
SOURCE_SUM=dae9ab5d232a2b56f129aa29e7e54d2de05d838f0479955543cebcb14c9417db
|
||||
# (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# default: sha256
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
# (Optional) Archive format
|
||||
# default: tar.gz
|
||||
SOURCE_FORMAT=tar.gz
|
||||
# (Optional) Put false if sources are directly in the archive root
|
||||
# default: true
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -26,7 +26,7 @@ location /seafhttp/ {
|
|||
|
||||
|
||||
location __PATH__/media/ {
|
||||
alias __FINALPATH__/seafile-server-latest/seahub/media/;
|
||||
alias __INSTALL_DIR__/seafile-server-latest/seahub/media/;
|
||||
}
|
||||
|
||||
location /seafdav {
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
{
|
||||
"name": "Seafile",
|
||||
"id": "seafile",
|
||||
"packaging_format": 1,
|
||||
"license": "AGPL-3.0,Apache-2.0,MIT,GPL-2.0",
|
||||
"url": "https://www.seafile.com",
|
||||
"upstream": {
|
||||
"license": "AGPL-3.0,Apache-2.0,MIT,GPL-2.0",
|
||||
"website": "https://www.seafile.com",
|
||||
"demo": "https://demo.seafile.com",
|
||||
"admindoc": "https://manual.seafile.com",
|
||||
"code": "https://github.com/haiwen/seafile-server"
|
||||
},
|
||||
"version": "9.0.2~ynh2",
|
||||
"description": {
|
||||
"en": "Open Source Cloud Storage",
|
||||
"fr": "Stockage Cloud Open Source"
|
||||
},
|
||||
"maintainer": {
|
||||
"name": "Josué Tille",
|
||||
"email": "josue@tille.ch"
|
||||
},
|
||||
"previous_maintainers": {
|
||||
"name": "mbugeia",
|
||||
"email": "maxime@max.privy.place"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx",
|
||||
"mysql"
|
||||
],
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3"
|
||||
},
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"default": "/seafile"
|
||||
},
|
||||
{
|
||||
"name": "server_name",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose a name (3 - 15 letters or digits)",
|
||||
"fr": "Choisissez un nom (3 - 15 letters or digits)"
|
||||
},
|
||||
"example": "Seafile",
|
||||
"default": "Seafile"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "admin_password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "Enter a password for the administrator",
|
||||
"fr": "Entrez un mot de passe pour l'administrateur"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"help": {
|
||||
"en": "If it's not public, everybody which want to access to any page of seafile need to be authenticated on the SSO. On the public mode anybody can access to the authentication page. The shared link will be olso accessible by anybody who has this link.",
|
||||
"fr": "Si n'est pas publique, n'importe qui veux accéder à n'importe quelle page de seafile doit être authentifié dans le SSO. Dans le mode publique n'importe qui peut accéder à la page d'authentification de seafile. Les liens partagé seront aussi accessible par n'import qui qui à ce liens."
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -2,50 +2,20 @@
|
|||
# SET ALL CONSTANTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
db_user=seafile
|
||||
time_zone=$(cat /etc/timezone)
|
||||
|
||||
#=================================================
|
||||
# DEFINE ALL COMMON FONCTIONS
|
||||
#=================================================
|
||||
|
||||
install_source() {
|
||||
mkdir "$final_path/seafile-server-$seafile_version"
|
||||
if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armel" ]
|
||||
then
|
||||
ynh_die --message "Error : this architecture is no longer supported by the upstream. Please create en issue here : https://github.com/YunoHost-Apps/seafile_ynh/issues to ask to discuss about a support of this architecture"
|
||||
fi
|
||||
ynh_setup_source "$final_path/seafile-server-$seafile_version" "$YNH_ARCH"
|
||||
|
||||
# Drop some conflicting package cf: https://forum.seafile.com/t/seahub-fails-to-start-nameerror-name-mysql-is-not-defined/14566/3
|
||||
ynh_secure_remove --file=$final_path/seafile-server-$seafile_version/seahub/thirdpart/MySQLdb
|
||||
ynh_secure_remove --file=$final_path/seafile-server-$seafile_version/seahub/thirdpart/cffi
|
||||
ynh_secure_remove --file=$final_path/seafile-server-$seafile_version/seahub/thirdpart/PIL
|
||||
}
|
||||
|
||||
install_source_7_0() {
|
||||
if ! [ -e $final_path/seafile-server-7.0.5 ]; then
|
||||
mkdir "$final_path/seafile-server-7.0.5"
|
||||
if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armel" ]
|
||||
then
|
||||
ynh_die --message "Error : this architecture is no longer supported by the upstream. Please create en issue here : https://github.com/YunoHost-Apps/seafile_ynh/issues to ask to discuss about a support of this architecture"
|
||||
fi
|
||||
ynh_setup_source "$final_path/seafile-server-7.0.5" "$YNH_ARCH"_7_0
|
||||
fi
|
||||
}
|
||||
|
||||
install_dependance() {
|
||||
ynh_install_app_dependencies python3 python3-setuptools python3-pip python3-requests python3-dev libmariadb-dev-compat libmariadb-dev \
|
||||
expect ffmpeg \
|
||||
memcached libmemcached-dev \
|
||||
python3-scipy python3-matplotlib \
|
||||
libjpeg62-turbo-dev zlib1g-dev libffi-dev # For building pillow
|
||||
ynh_add_swap --size=2000
|
||||
# We need to do that because we can have some issue about the permission access to the pip cache without this
|
||||
chown -R $seafile_user:$seafile_user $final_path
|
||||
chown -R $seafile_user:$seafile_user $install_dir
|
||||
|
||||
# Note that we install imageio to force the dependance, without this imageio 2.8 is installed and it need python3.5
|
||||
sudo -u $seafile_user pip3 install --user --no-warn-script-location --upgrade future mysqlclient PyMySQL Pillow pylibmc captcha Jinja2 SQLAlchemy psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 cffi==1.14.0
|
||||
# TODO add dependance when upgrade to seafile 8: django==2.2.*
|
||||
ynh_del_swap
|
||||
}
|
||||
|
||||
|
@ -57,14 +27,14 @@ mv_expect_scripts() {
|
|||
}
|
||||
|
||||
set_permission() {
|
||||
chown -R $seafile_user:$seafile_user $final_path
|
||||
chmod -R g-wx,o= $final_path
|
||||
setfacl -m user:www-data:rX $final_path
|
||||
setfacl -m user:www-data:rX $final_path/seafile-server-$seafile_version
|
||||
chown -R $seafile_user:$seafile_user $install_dir
|
||||
chmod -R g-wx,o= $install_dir
|
||||
setfacl -m user:www-data:rX $install_dir
|
||||
setfacl -m user:www-data:rX $install_dir/seafile-server-$seafile_version
|
||||
# At install time theses directory are not available
|
||||
test -e $final_path/seafile-server-latest/seahub && setfacl -m user:www-data:rX $final_path/seafile-server-latest/seahub
|
||||
test -e $final_path/seafile-server-latest/seahub/media && setfacl -R -m user:www-data:rX $final_path/seafile-server-latest/seahub/media
|
||||
test -e $final_path/seahub-data && setfacl -R -m user:www-data:rX $final_path/seahub-data
|
||||
#REMOVEME? test -e $install_dir/seafile-server-latest/seahub && setfacl -m user:www-data:rX $install_dir/seafile-server-latest/seahub
|
||||
#REMOVEME? test -e $install_dir/seafile-server-latest/seahub/media && setfacl -R -m user:www-data:rX $install_dir/seafile-server-latest/seahub/media
|
||||
#REMOVEME? test -e $install_dir/seahub-data && setfacl -R -m user:www-data:rX $install_dir/seahub-data
|
||||
|
||||
# check that this directory exist because in some really old install the data could still be in the main seafile directory
|
||||
# We also check at the install time when data directory is not already initialised
|
||||
|
@ -73,10 +43,3 @@ set_permission() {
|
|||
chmod -R o= /home/yunohost.app/seafile-data
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_clean_setup () {
|
||||
pkill -f seafile-controller
|
||||
pkill -f seaf-server
|
||||
pkill -f ccnet-server
|
||||
pkill -f seahub
|
||||
}
|
||||
|
|
|
@ -11,17 +11,8 @@ source ../settings/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..."
|
||||
|
||||
# retrieve useful param
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
seafile_version=$(ynh_app_upstream_version)
|
||||
seafile_user=$app
|
||||
|
||||
if [[ ! "$(systemctl status seafile)" =~ "Active: inactive (dead)" ]] || [[ ! "$(systemctl status seahub)" =~ "Active: failed (Result: signal)" ]]; then
|
||||
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop seafile service and seahub service with this command before to run the backup 'systemctl stop seafile.service seahub.service'"
|
||||
|
@ -33,7 +24,7 @@ fi
|
|||
|
||||
# # Backup app files
|
||||
ynh_print_info --message="Backing up code..."
|
||||
ynh_backup --src_path $final_path
|
||||
ynh_backup --src_path $install_dir
|
||||
ynh_print_info --message="Backing up user data..."
|
||||
ynh_backup --src_path=/home/yunohost.app/seafile-data --dest_path="data" --is_big=1
|
||||
ynh_print_info --message="Backing up configuration..."
|
||||
|
|
|
@ -12,19 +12,19 @@ source ./_common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Retrive arguments
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||
domain=$YNH_APP_NEW_DOMAIN
|
||||
old_path=$(ynh_normalize_url_path --path_url $YNH_APP_OLD_PATH)
|
||||
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
|
||||
seahub_port=$(ynh_app_setting_get --app $app --key seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port)
|
||||
webdav_port=$(ynh_app_setting_get --app $app --key webdav_port)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
#REMOVEME? old_path=$(ynh_normalize_url_path --path $YNH_APP_OLD_PATH)
|
||||
path=$(ynh_normalize_url_path --path $YNH_APP_NEW_PATH)
|
||||
#REMOVEME? seahub_port=$(ynh_app_setting_get --app $app --key seahub_port)
|
||||
#REMOVEME? fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port)
|
||||
#REMOVEME? webdav_port=$(ynh_app_setting_get --app $app --key webdav_port)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app $app --key install_dir)
|
||||
seafile_user=$app
|
||||
|
||||
# Create special path with / at the end
|
||||
|
@ -35,31 +35,31 @@ else
|
|||
old_path2=$old_path'/'
|
||||
fi
|
||||
|
||||
if [[ $path_url == '/' ]]
|
||||
if [[ $path == '/' ]]
|
||||
then
|
||||
path_url2=$path_url
|
||||
path2=$path
|
||||
else
|
||||
path_url2=$path_url'/'
|
||||
path2=$path'/'
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Updating nginx configuration..."
|
||||
#REMOVEME? ynh_script_progression --message="Updating nginx configuration..."
|
||||
|
||||
# Update nginx config
|
||||
#REMOVEME? # Update nginx config
|
||||
if [ "$old_domain" != "$domain" ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
#REMOVEME? ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
|
||||
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
#REMOVEME? mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
#REMOVEME? ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
#REMOVEME? ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
|
||||
|
@ -75,16 +75,16 @@ pkill -f seahub || true
|
|||
ynh_script_progression --message="Updating seafile configuration..."
|
||||
|
||||
# Update Seafile Config
|
||||
ynh_replace_string --match_string "SERVICE_URL = https://$old_domain$old_path" --replace_string "SERVICE_URL = https://$domain$path_url" --target_file $final_path/conf/ccnet.conf
|
||||
ynh_replace_string --match_string "SERVICE_URL = https://$old_domain$old_path" --replace_string "SERVICE_URL = https://$domain$path" --target_file $install_dir/conf/ccnet.conf
|
||||
|
||||
ynh_replace_string --match_string 'FILE_SERVER_ROOT = "https://'"$old_domain"'/seafhttp"' --replace_string 'FILE_SERVER_ROOT = "https://'"$domain"'/seafhttp"' --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string 'SITE_ROOT = "'"$old_path2"'"' --replace_string 'SITE_ROOT = "'"$path_url2"'"' --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string 'MEDIA_URL = "'"$old_path2"'media/"' --replace_string 'MEDIA_URL = "'"$path_url2"'media/"' --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string "LOGIN_URL = '${old_path2}accounts/login/'" --replace_string "LOGIN_URL = '${path_url2}accounts/login/'" --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string ' = "seafile@'"$old_domain"'"' --replace_string ' = "seafile@'"$domain"'"' --target_file $final_path/conf/seahub_settings.py
|
||||
sed --in-place "s@ALLOWED_HOSTS = \['${old_domain}'\]@ALLOWED_HOSTS = \['${domain}'\]@g" $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string "REMOTE_USER_DOMAIN = '$old_domain'" --replace_string "REMOTE_USER_DOMAIN = '$domain'" --target_file $final_path/conf/seahub_settings.py
|
||||
sed --in-place "s@REMOTE_USER_PROTECTED_PATH = \['$old_path', '$old_path/accounts/login'\]@REMOTE_USER_PROTECTED_PATH = \['$path_url', '$path_url/accounts/login'\]@g" $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string 'FILE_SERVER_ROOT = "https://'"$old_domain"'/seafhttp"' --replace_string 'FILE_SERVER_ROOT = "https://'"$domain"'/seafhttp"' --target_file $install_dir/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string 'SITE_ROOT = "'"$old_path2"'"' --replace_string 'SITE_ROOT = "'"$path2"'"' --target_file $install_dir/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string 'MEDIA_URL = "'"$old_path2"'media/"' --replace_string 'MEDIA_URL = "'"$path2"'media/"' --target_file $install_dir/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string "LOGIN_URL = '${old_path2}accounts/login/'" --replace_string "LOGIN_URL = '${path2}accounts/login/'" --target_file $install_dir/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string ' = "seafile@'"$old_domain"'"' --replace_string ' = "seafile@'"$domain"'"' --target_file $install_dir/conf/seahub_settings.py
|
||||
sed --in-place "s@ALLOWED_HOSTS = \['${old_domain}'\]@ALLOWED_HOSTS = \['${domain}'\]@g" $install_dir/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string "REMOTE_USER_DOMAIN = '$old_domain'" --replace_string "REMOTE_USER_DOMAIN = '$domain'" --target_file $install_dir/conf/seahub_settings.py
|
||||
sed --in-place "s@REMOTE_USER_PROTECTED_PATH = \['$old_path', '$old_path/accounts/login'\]@REMOTE_USER_PROTECTED_PATH = \['$path', '$path/accounts/login'\]@g" $install_dir/conf/seahub_settings.py
|
||||
|
||||
# Avoid the current effect
|
||||
sleep 2
|
||||
|
|
159
scripts/install
159
scripts/install
|
@ -11,84 +11,29 @@ source ./_common.sh
|
|||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
server_name="$YNH_APP_ARG_SERVER_NAME"
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
seafile_data=/home/yunohost.app/seafile-data
|
||||
final_path=/opt/yunohost/$app
|
||||
seafile_user=$app
|
||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
seafile_version=$(ynh_app_upstream_version)
|
||||
|
||||
# Create special path with / at the end
|
||||
if [[ $path_url == '/' ]]
|
||||
if [[ $path == '/' ]]
|
||||
then
|
||||
path_url2=$path_url
|
||||
path2=$path
|
||||
else
|
||||
path_url2=$path_url"/"
|
||||
path2=$path"/"
|
||||
fi
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
||||
|
||||
# Check Final Path availability
|
||||
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
|
||||
if [ -e "$seafile_data" ]; then
|
||||
old_data_dir_path="$seafile_data$(date '+%Y%m%d.%H%M%S')"
|
||||
ynh_print_warn "A data directory already exist. Data was renamed to $old_data_dir_path"
|
||||
mv "$seafile_data" "$old_data_dir_path"
|
||||
fi
|
||||
|
||||
# Find available ports
|
||||
ynh_script_progression --message="Finding available ports..."
|
||||
seahub_port=$(ynh_find_port --port 8000)
|
||||
fileserver_port=$(ynh_find_port --port 8082)
|
||||
webdav_port=$(ynh_find_port --port 8080)
|
||||
|
||||
if [ $fileserver_port -eq $webdav_port ]; then
|
||||
webdav_port=$(ynh_find_port --port $((fileserver_port + 1)))
|
||||
fi
|
||||
|
||||
# store config in yunohost
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_app_setting_set --app $app --key server_name --value "$server_name"
|
||||
ynh_app_setting_set --app $app --key final_path --value $final_path
|
||||
ynh_app_setting_set --app $app --key seafile_user --value $seafile_user
|
||||
ynh_app_setting_set --app $app --key admin --value $admin
|
||||
ynh_app_setting_set --app $app --key seahub_port --value $seahub_port
|
||||
ynh_app_setting_set --app $app --key fileserver_port --value $fileserver_port
|
||||
ynh_app_setting_set --app $app --key webdav_port --value $webdav_port
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Creating base directory..."
|
||||
mkdir -p $final_path
|
||||
mkdir -p $final_path/installed
|
||||
mkdir -p $final_path/logs
|
||||
mkdir -p $seafile_data
|
||||
ln -s $seafile_data $final_path/seafile-data
|
||||
|
||||
# Create User
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_system_user_create --username $seafile_user --home_dir $final_path
|
||||
ln -s $data_dir $install_dir/seafile-data
|
||||
|
||||
# Check dependencies
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=7
|
||||
install_dependance
|
||||
|
||||
# Download new version from sources
|
||||
ynh_script_progression --message="Installing sources files..." --weight=7
|
||||
install_source
|
||||
ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version
|
||||
|
||||
# init databases
|
||||
ynh_script_progression --message="Configuring MySQL database..."
|
||||
|
@ -101,76 +46,33 @@ ynh_script_progression --message="Configuring application..." --weight=3
|
|||
|
||||
# Run install script
|
||||
mv_expect_scripts
|
||||
chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
|
||||
chmod +x $install_dir/seafile-server-$seafile_version/setup-seafile-mysql.sh
|
||||
set_permission
|
||||
sudo -u $seafile_user $expect_scripts_dir/install.exp "$final_path/seafile-server-$seafile_version" "$server_name" "$domain" "$fileserver_port" "$db_pwd"
|
||||
sudo -u $seafile_user $expect_scripts_dir/install.exp "$install_dir/seafile-server-$seafile_version" "$server_name" "$domain" "$fileserver_port" "$db_pwd"
|
||||
|
||||
sleep 3
|
||||
|
||||
# Update seafile config
|
||||
ynh_replace_string --match_string http:// --replace_string https:// --target_file $final_path/conf/ccnet.conf
|
||||
ynh_replace_string --match_string :8000 --replace_string $path_url --target_file $final_path/conf/ccnet.conf
|
||||
echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | 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 = "'$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 = '"$path_url2"accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "ALLOWED_HOSTS = ['"$domain"']" | tee -a $final_path/conf/seahub_settings.py
|
||||
# Retrive values from auto generated config file
|
||||
seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*"[\w-]+"' $install_dir/conf/seahub_settings.py | cut -d'"' -f2)
|
||||
ccnet_id=$(grep -P 'ID\s*=\s*\w+$' $install_dir/conf/ccnet.conf | cut -d= -f2 | grep -o -P '\w+')
|
||||
ynh_app_setting_set --app $app --key seahub_secret_key --value $seahub_secret_key
|
||||
ynh_app_setting_set --app $app --key ccnet_id --value $ccnet_id
|
||||
|
||||
# Email configuration
|
||||
echo 'EMAIL_USE_TLS = False' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_HOST = "localhost"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_HOST_USER = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_PORT = "25"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'DEFAULT_FROM_EMAIL = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'SERVER_EMAIL = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_HOST_PASSWORD = ""' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "TIME_ZONE = \"$(cat /etc/timezone)\"" | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# SSO authentication
|
||||
echo 'ENABLE_REMOTE_USER_AUTHENTICATION = True' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "REMOTE_USER_HEADER = 'HTTP_EMAIL'" | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'REMOTE_USER_CREATE_UNKNOWN_USER = False' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "REMOTE_USER_PROTECTED_PATH = ['$path_url', '$path_url/accounts/login']" | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# LDAP configuration
|
||||
echo '[LDAP]' | tee -a $final_path/conf/ccnet.conf
|
||||
echo 'HOST = ldap://localhost:389' | tee -a $final_path/conf/ccnet.conf
|
||||
echo 'BASE = ou=users,dc=yunohost,dc=org' | tee -a $final_path/conf/ccnet.conf
|
||||
echo 'LOGIN_ATTR = mail' | tee -a $final_path/conf/ccnet.conf
|
||||
echo "FILTER = permission=cn=$app.main,ou=permission,dc=yunohost,dc=org" | tee -a $final_path/conf/ccnet.conf
|
||||
|
||||
# Enable manually wiki
|
||||
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# Enable memcached
|
||||
cat >> $final_path/conf/seahub_settings.py <<EOF
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||
'LOCATION': '127.0.0.1:11211',
|
||||
},
|
||||
}
|
||||
EOF
|
||||
# Update seafile config files
|
||||
ynh_add_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py
|
||||
ynh_add_config --template=ccnet.conf --destination=$install_dir/conf/ccnet.conf
|
||||
ynh_add_config --template=gunicorn.conf.py --destination=$install_dir/conf/gunicorn.conf.py
|
||||
ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.conf
|
||||
|
||||
# Configure admin info
|
||||
# It will be used the first start
|
||||
admin_email=$(ynh_user_get_info --username $admin --key 'mail')
|
||||
cp ../conf/create_admin.json $final_path/conf/admin.txt
|
||||
ynh_replace_string --match_string __ADMIN__ --replace_string $admin_email --target_file $final_path/conf/admin.txt
|
||||
ynh_replace_special_string --match_string __PASSWORD__ --replace_string $admin_password --target_file $final_path/conf/admin.txt
|
||||
cp ../conf/create_admin.json $install_dir/conf/admin.txt
|
||||
ynh_replace_string --match_string __ADMIN__ --replace_string $admin_email --target_file $install_dir/conf/admin.txt
|
||||
ynh_replace_special_string --match_string __PASSWORD__ --replace_string $admin_password --target_file $install_dir/conf/admin.txt
|
||||
|
||||
# Fix local warning
|
||||
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh
|
||||
|
||||
# Update gunicorn config
|
||||
sed --in-place -r "s@bind = \"127\.0\.0\.1:[[:digit:]]+\"@bind = \"127.0.0.1:$seahub_port\"@g" $final_path/conf/gunicorn.conf.py
|
||||
|
||||
# Add webdav
|
||||
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
||||
ynh_replace_string --match_string __WEBDAV_PORT__ --replace_string $webdav_port --target_file $final_path/conf/seafdav.conf
|
||||
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $install_dir/seafile-server-$seafile_version/seahub.sh
|
||||
|
||||
# Add Seafile Server to startup
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=2
|
||||
|
@ -189,25 +91,10 @@ ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
|||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
ynh_permission_create --permission=file_server --url=$domain/seafhttp --auth_header=false \
|
||||
--label="File server" --protected=true --allowed=visitors
|
||||
ynh_permission_create --permission=webdav --url=$domain/seafdav --auth_header=true \
|
||||
--label="Webdav" --protected=true --allowed=visitors
|
||||
# unprotect media
|
||||
ynh_permission_create --permission=media --url=/media --auth_header=true \
|
||||
--label="Media" --protected=true --allowed=visitors
|
||||
|
||||
if [ "$is_public" == '1' ];
|
||||
then
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate --logfile $final_path/logs
|
||||
ln -s $final_path/logs /var/log/seafile
|
||||
ynh_use_logrotate --logfile $install_dir/logs
|
||||
ln -s $install_dir/logs /var/log/seafile
|
||||
|
||||
# register yunohost service
|
||||
yunohost service add seafile
|
||||
|
|
|
@ -11,11 +11,6 @@ source ./_common.sh
|
|||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
@ -50,14 +45,6 @@ ynh_script_progression --message="Removing systemd units..."
|
|||
ynh_remove_systemd_config --service seafile
|
||||
ynh_remove_systemd_config --service seahub
|
||||
|
||||
# Remove user
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
ynh_system_user_delete --username seafile
|
||||
|
||||
# Remove depandance
|
||||
ynh_script_progression --message="Removing dependencies" --weight=10
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
# Remove nginx config
|
||||
ynh_script_progression --message="Removing nginx configuration..."
|
||||
ynh_remove_nginx_config
|
||||
|
@ -73,7 +60,5 @@ ynh_script_progression --message="Removing seafile service..."
|
|||
yunohost service remove seafile
|
||||
yunohost service remove seahub
|
||||
|
||||
ynh_print_info --message="Due of the backup core only feature the data directory in '/home/yunohost.app/seafile-data' was not removed. It need to be removed manually to purge app user data."
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
sleep 1
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
import json
|
||||
import sys
|
||||
|
||||
with open("/etc/ssowat/" + "conf.json.persistent", "r", encoding='utf-8') as jsonFile:
|
||||
data = json.load(jsonFile)
|
||||
|
||||
for domain in ("", sys.argv[1]):
|
||||
for path in ("/seafhttp", "/seafdav"):
|
||||
url = domain + path
|
||||
try:
|
||||
uri_list = data["skipped_urls"]
|
||||
while url in uri_list:
|
||||
uri_list.remove(url)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
uri_list = data["protected_urls"]
|
||||
while url in uri_list:
|
||||
uri_list.remove(url)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
uri_list = data["permissions"]["custom_protected"]["uris"]
|
||||
while url in uri_list:
|
||||
uri_list.remove(url)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
uri_list = data["permissions"]["custom_skipped"]["uris"]
|
||||
while url in uri_list:
|
||||
uri_list.remove(url)
|
||||
except:
|
||||
pass
|
||||
|
||||
with open("/etc/ssowat/" + "conf.json.persistent", "w", encoding='utf-8') as jsonFile:
|
||||
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))
|
|
@ -11,19 +11,10 @@ source ../settings/scripts/_common.sh
|
|||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
|
||||
seafile_data=/home/yunohost.app/seafile-data
|
||||
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
seafile_version=$(ynh_app_upstream_version)
|
||||
seafile_user=$app
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -33,17 +24,11 @@ seafile_user=$app
|
|||
ynh_script_progression --message="Restoring files..." --weight=10
|
||||
ynh_restore
|
||||
|
||||
# Create user
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_system_user_create --username $seafile_user --home_dir $final_path
|
||||
|
||||
# Restore dependencies
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
install_dependance
|
||||
|
||||
# Restore mysql dump
|
||||
ynh_script_progression --message="Restoring database..." --weight=3
|
||||
db_user=seafile
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name ccnetdb --db_pwd "$db_pwd"
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name seafiledb --db_pwd "$db_pwd"
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd"
|
||||
|
@ -57,8 +42,8 @@ su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
|
|||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate --logfile $final_path/logs
|
||||
ln -s $final_path/logs /var/log/seafile
|
||||
ynh_use_logrotate --logfile $install_dir/logs
|
||||
ln -s $install_dir/logs /var/log/seafile
|
||||
|
||||
# Set all permissions
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
|
|
252
scripts/upgrade
252
scripts/upgrade
|
@ -11,26 +11,12 @@ source ./_common.sh
|
|||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
|
||||
seahub_port=$(ynh_app_setting_get --app $app --key seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port)
|
||||
webdav_port=$(ynh_app_setting_get --app $app --key webdav_port)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
seafile_user=$app
|
||||
seafile_data=/home/yunohost.app/seafile-data
|
||||
installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/}
|
||||
seafile_version=$(ynh_app_upstream_version)
|
||||
|
||||
if [ "$YNH_APP_CURRENT_VERSION" == '-' ]; then
|
||||
YNH_APP_CURRENT_VERSION="6.0.9~ynh0"
|
||||
installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/}
|
||||
ynh_die "Upgrade from this version not supported"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
|
@ -53,60 +39,12 @@ pkill -f seaf-server || true
|
|||
pkill -f ccnet-server || true
|
||||
pkill -f seahub || true
|
||||
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30
|
||||
# Backup the current version of the app
|
||||
if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ] \
|
||||
&& (ynh_compare_current_package_version --comparison=ge --version='7.0.5~ynh1')
|
||||
then
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remainings that are not handled by the remove script.
|
||||
ynh_clean_check_starting
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MIGRATION FROM OLD VERSION
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Fixing old settings..." --weight=1
|
||||
|
||||
# Get configuration for user and final path
|
||||
if [ -z $final_path ]; then
|
||||
if [ -e /var/www/$app ]; then
|
||||
final_path=/var/www/$app
|
||||
elif [ -e /opt/yunohost/$app ]; then
|
||||
final_path=/opt/yunohost/$app
|
||||
else
|
||||
ynh_die --message "Error : can't find seafile path"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $final_path == "/var/www/$app" ]; then
|
||||
final_path="/opt/yunohost/$app"
|
||||
mkdir -p /opt/yunohost
|
||||
mv /var/www/$app /opt/yunohost/$app
|
||||
ynh_system_user_create --username $seafile_user --home_dir $final_path
|
||||
ynh_app_setting_set --app $app --key final_path --value $final_path
|
||||
test -e /var/log/seafile && rm /var/log/$app
|
||||
if ! [ -z "$(ls -A $final_path/seafile_data)" ]; then
|
||||
# Data directory NOT empty, transfer data to /home/yunohost.app/seafile
|
||||
mv $final_path/seafile_data/* /home/yunohost.app/seafile-data/
|
||||
ynh_secure_remove $final_path/seafile_data
|
||||
ln -s /home/yunohost.app/seafile-data $final_path/
|
||||
fi
|
||||
ln -s $final_path/logs /var/log/seafile
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||
|
||||
# extract new version
|
||||
test -e $final_path/seafile-server-$seafile_version && ynh_secure_remove --file="$final_path/seafile-server-$seafile_version"
|
||||
install_source
|
||||
ynh_script_progression --message="Installing sources files..." --weight=7
|
||||
ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version
|
||||
|
||||
# Upgrade dependances
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
install_dependance
|
||||
|
||||
ynh_script_progression --message="Configuring application..."
|
||||
|
@ -114,164 +52,62 @@ ynh_script_progression --message="Configuring application..."
|
|||
# permission to execute update script and expect helper
|
||||
mv_expect_scripts
|
||||
set_permission
|
||||
chmod u+x,o= $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh
|
||||
chmod u+x,o= $final_path/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
|
||||
chmod u+x,o= $install_dir/seafile-server-$seafile_version/upgrade/upgrade_*.sh
|
||||
chmod u+x,o= $install_dir/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
|
||||
|
||||
# TODO !! retrive config from config file if not already set
|
||||
|
||||
# do the upgrade ( the ";&" syntax mean when it go in the first case which is true it do all the next case)
|
||||
case $installed_version in
|
||||
"4.0."* )
|
||||
"4."* )
|
||||
# Update seafile by script
|
||||
ynh_die "Upgrade form the version 4.0 was removed. Upgrade from this version won't be supported any more."
|
||||
ynh_die "Upgrade form the version 4.x was removed. Upgrade from this version won't be supported any more."
|
||||
;&
|
||||
"4.1."* )
|
||||
"5."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_4.2.1.exp $final_path/seafile-server-7.0.5
|
||||
ynh_die "Upgrade form the version 5.x was removed. Upgrade from this version won't be supported any more."
|
||||
;&
|
||||
"4.3."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_4.4.3.exp $final_path/seafile-server-7.0.5
|
||||
;&
|
||||
"4.4."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_5.0.3.exp $final_path/seafile-server-7.0.5
|
||||
;&
|
||||
"5.0."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_5.1.exp $final_path/seafile-server-7.0.5
|
||||
;&
|
||||
"5.1."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_6.0.exp $final_path/seafile-server-7.0.5
|
||||
;&
|
||||
"6.0."* )
|
||||
install_source_7_0
|
||||
|
||||
# Update seafile by script
|
||||
$expect_scripts_dir/upgrade_6.1.exp $final_path/seafile-server-7.0.5
|
||||
|
||||
# Enable manually wiki
|
||||
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
|
||||
;&
|
||||
"6.1."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_6.2.exp $final_path/seafile-server-7.0.5
|
||||
;&
|
||||
"6.2."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_6.3.exp $final_path/seafile-server-7.0.5
|
||||
|
||||
# Update logrotate to have the last version
|
||||
ynh_use_logrotate --logfile $final_path/logs --nonappend
|
||||
;&
|
||||
"6.3."* )
|
||||
# Update seafile by script
|
||||
install_source_7_0
|
||||
$expect_scripts_dir/upgrade_7.0.exp $final_path/seafile-server-7.0.5
|
||||
# SSO authentication
|
||||
echo 'ENABLE_REMOTE_USER_AUTHENTICATION = True' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "REMOTE_USER_HEADER = 'HTTP_EMAIL'" | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'REMOTE_USER_CREATE_UNKNOWN_USER = False' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "REMOTE_USER_PROTECTED_PATH = ['$path_url', '$path_url/accounts/login']" | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# Clean connexion from the SSO. If we don't do this we could have some when the user was loged by the old SSO auth mecanisme
|
||||
ynh_mysql_execute_as_root --sql "DELETE FROM \`django_session\`" --database seahubdb
|
||||
|
||||
ynh_print_warn --message "To be able to continue to use the SSO you probybly need to migrate your account. You can use the command 'yunohost app action run seafile migrate_user_email_to_mail_email' to migrate all of theses account. Note that after this migratation you need to reconfigure all your client with the official email of the user."
|
||||
"6."* )
|
||||
ynh_die "Upgrade form the version 6.x was removed. Upgrade from this version won't be supported any more."
|
||||
;&
|
||||
"7.0"* )
|
||||
# Fix file comment
|
||||
pushd $final_path/seafile-server-$seafile_version
|
||||
sudo -u $seafile_user $final_path/seafile-server-$seafile_version/seahub.sh python-env python3 seahub/manage.py migrate_file_comment
|
||||
pushd $install_dir/seafile-server-$seafile_version
|
||||
sudo -u $seafile_user $install_dir/seafile-server-$seafile_version/seahub.sh python-env python3 seahub/manage.py migrate_file_comment
|
||||
popd
|
||||
|
||||
# Update seafile by script
|
||||
sudo -u $seafile_user $expect_scripts_dir/upgrade_7.1.exp $final_path/seafile-server-$seafile_version
|
||||
sudo -u $seafile_user $expect_scripts_dir/upgrade_7.1.exp $install_dir/seafile-server-$seafile_version
|
||||
|
||||
ynh_secure_remove --file="$final_path/seafile-server-7.0.5"
|
||||
|
||||
# Enable memcached
|
||||
cat >> $final_path/conf/seahub_settings.py <<EOF
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||
'LOCATION': '127.0.0.1:11211',
|
||||
},
|
||||
}
|
||||
EOF
|
||||
# Fix seafile data link. Look like that the upgrade script of seafile don't always work correctly
|
||||
if [ -e $final_path/seafile-data ]; then
|
||||
old_data_dir_path="$final_path/seafile_data$(date '+%Y%m%d.%H%M%S')"
|
||||
mv "$final_path/seafile-data" "$old_data_dir_path"
|
||||
if [ -e $install_dir/seafile-data ]; then
|
||||
old_data_dir_path="$install_dir/seafile_data$(date '+%Y%m%d.%H%M%S')"
|
||||
mv "$install_dir/seafile-data" "$old_data_dir_path"
|
||||
fi
|
||||
ln -s $seafile_data $final_path/seafile-data
|
||||
ln -s $seafile_data $install_dir/seafile-data
|
||||
;&
|
||||
"7.1."* )
|
||||
sudo -u $seafile_user $expect_scripts_dir/upgrade_8.0.exp $final_path/seafile-server-$seafile_version
|
||||
echo "FILTER = permission=cn=$app.main,ou=permission,dc=yunohost,dc=org" | tee -a $final_path/conf/ccnet.conf
|
||||
sudo -u $seafile_user $expect_scripts_dir/upgrade_8.0.exp $install_dir/seafile-server-$seafile_version
|
||||
echo "FILTER = permission=cn=$app.main,ou=permission,dc=yunohost,dc=org" | tee -a $install_dir/conf/ccnet.conf
|
||||
;&
|
||||
"8.0."* )
|
||||
sudo -u $seafile_user $expect_scripts_dir/upgrade_9.0.exp $final_path/seafile-server-$seafile_version
|
||||
sudo -u $seafile_user $expect_scripts_dir/upgrade_9.0.exp $install_dir/seafile-server-$seafile_version
|
||||
;&
|
||||
esac
|
||||
|
||||
sudo -u $seafile_user $expect_scripts_dir/minor-upgrade.exp $final_path/seafile-server-$seafile_version
|
||||
sudo -u $seafile_user $expect_scripts_dir/minor-upgrade.exp $install_dir/seafile-server-$seafile_version
|
||||
|
||||
## Install webdav and logrotate if not installed
|
||||
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
|
||||
then
|
||||
ynh_script_progression --message="Configuring webdav..."
|
||||
webdav_port=$(ynh_find_port 8080)
|
||||
ynh_app_setting_set --app $app --key webdav_port --value $webdav_port
|
||||
|
||||
# Disallow port that was used by old seafile client
|
||||
ccnet_port=$(ynh_app_setting_get --app $app --key ccnet_port)
|
||||
seafile_port=$(ynh_app_setting_get --app $app --key seafile_port)
|
||||
yunohost firewall disallow Both $ccnet_port
|
||||
yunohost firewall disallow Both $seafile_port
|
||||
|
||||
# Add webdav config
|
||||
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
||||
ynh_replace_string --match_string __WEBDAV_PORT__ --replace_string $webdav_port --target_file $final_path/conf/seafdav.conf
|
||||
|
||||
# Update seafile config
|
||||
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
|
||||
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_url/accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
fi
|
||||
|
||||
if [ $(grep -c "TIME_ZONE" $final_path/conf/seahub_settings.py) == 0 ]
|
||||
then
|
||||
echo "TIME_ZONE = \"$(cat /etc/timezone)\"" | tee -a $final_path/conf/seahub_settings.py
|
||||
fi
|
||||
# Update seafile config files
|
||||
ynh_add_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py
|
||||
ynh_add_config --template=ccnet.conf --destination=$install_dir/conf/ccnet.conf
|
||||
ynh_add_config --template=gunicorn.conf.py --destination=$install_dir/conf/gunicorn.conf.py
|
||||
ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.conf
|
||||
|
||||
# Fix local warning
|
||||
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh
|
||||
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $install_dir/seafile-server-$seafile_version/seahub.sh
|
||||
|
||||
# Update gunicorn config
|
||||
sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $final_path/conf/gunicorn.conf.py
|
||||
|
||||
# In the 3.x seafile version package the seahub_port and fileserver_port wasn't saved in the settings. If the settings is empty we try to get it and save in the settings
|
||||
|
||||
if [[ -z $seahub_port ]] || [[ -z $fileserver_port ]]
|
||||
then
|
||||
seahub_port=$(head -n 20 /etc/nginx/conf.d/$domain.d/seafile.conf | grep -E "fastcgi_pass.*127.0.0.1:" | cut -d':' -f2 | cut -d';' -f1)
|
||||
fileserver_port=$(head -n 50 /etc/nginx/conf.d/$domain.d/seafile.conf | grep -E "proxy_pass.*127.0.0.1:" | cut -d':' -f3 | cut -d';' -f1 | cut -d'/' -f1)
|
||||
|
||||
ynh_app_setting_set --app $app --key seahub_port --value $seahub_port
|
||||
ynh_app_setting_set --app $app --key fileserver_port --value $fileserver_port
|
||||
fi
|
||||
sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $install_dir/conf/gunicorn.conf.py
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -295,32 +131,12 @@ set_permission
|
|||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate --logfile $final_path/logs --nonappend
|
||||
ynh_use_logrotate --logfile $install_dir/logs --nonappend
|
||||
|
||||
# Add fail2ban
|
||||
ynh_script_progression --message="Configuring fail2ban..." --weight=10
|
||||
ynh_add_fail2ban_config --use_template
|
||||
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
ynh_legacy_permissions_delete_all
|
||||
if ! ynh_permission_exists --permission=file_server; then
|
||||
ynh_permission_create --permission=file_server --url=$domain/seafhttp --auth_header=false \
|
||||
--label="File server" --protected=true --allowed=visitors
|
||||
ynh_permission_create --permission=webdav --url=$domain/seafdav --auth_header=true \
|
||||
--label="Webdav" --protected=true --allowed=visitors
|
||||
ynh_permission_create --permission=media --url=/media --auth_header=true \
|
||||
--label="Media" --protected=true --allowed=visitors
|
||||
python3 remove_sso_conf_persistent.py $domain \
|
||||
|| ynh_print_warn --message="Your file /etc/ssowat/""conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually."
|
||||
else
|
||||
ynh_permission_url --permission=file_server --url=$domain/seafhttp --auth_header=false
|
||||
ynh_permission_update --permission=file_server --label="File server" --show_tile=false --protected=true
|
||||
ynh_permission_url --permission=webdav --url=$domain/seafdav --auth_header=false
|
||||
ynh_permission_update --permission=webdav --label="Webdav" --show_tile=false --protected=true
|
||||
ynh_permission_url --permission=media --url=/media --auth_header=true
|
||||
ynh_permission_update --permission=media --label="Media" --show_tile=false --protected=true
|
||||
fi
|
||||
|
||||
# register yunohost service
|
||||
ynh_script_progression --message="Register seafile service..."
|
||||
yunohost service add seafile
|
||||
|
@ -338,10 +154,10 @@ sleep 2
|
|||
|
||||
# remove old version files
|
||||
ynh_script_progression --message="Cleaning system and updating settings..."
|
||||
ls $final_path | grep "seafile-server-" | egrep -v "(${seafile_version//./\\.})|(latest)" | \
|
||||
ls $install_dir | grep "seafile-server-" | egrep -v "(${seafile_version//./\\.})|(latest)" | \
|
||||
while read f
|
||||
do
|
||||
ynh_secure_remove --file=$final_path/$f
|
||||
ynh_secure_remove --file=$install_dir/$f
|
||||
done
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue