From 548d59accf62f421a37db83dd1c31a6ffac15e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 8 Aug 2023 23:21:11 +0200 Subject: [PATCH 01/25] First draft packaging v2 --- conf/amd64.src | 11 -- conf/amd64_7_0.src | 11 -- conf/arm64.src | 11 -- conf/arm64_7_0.src | 11 -- conf/armhf.src | 11 -- conf/armhf_7_0.src | 11 -- conf/nginx.conf | 2 +- manifest.json | 79 -------- scripts/_common.sh | 57 +----- scripts/backup | 11 +- scripts/change_url | 54 +++--- scripts/install | 159 +++------------- scripts/remove | 15 -- scripts/remove_sso_conf_persistent.py | 39 ---- scripts/restore | 19 +- scripts/upgrade | 252 ++++---------------------- 16 files changed, 98 insertions(+), 655 deletions(-) delete mode 100644 conf/amd64.src delete mode 100644 conf/amd64_7_0.src delete mode 100644 conf/arm64.src delete mode 100644 conf/arm64_7_0.src delete mode 100644 conf/armhf.src delete mode 100644 conf/armhf_7_0.src delete mode 100644 manifest.json delete mode 100644 scripts/remove_sso_conf_persistent.py diff --git a/conf/amd64.src b/conf/amd64.src deleted file mode 100644 index aa14472..0000000 --- a/conf/amd64.src +++ /dev/null @@ -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 diff --git a/conf/amd64_7_0.src b/conf/amd64_7_0.src deleted file mode 100644 index 4bd9e8a..0000000 --- a/conf/amd64_7_0.src +++ /dev/null @@ -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 diff --git a/conf/arm64.src b/conf/arm64.src deleted file mode 100644 index fa48fe7..0000000 --- a/conf/arm64.src +++ /dev/null @@ -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 diff --git a/conf/arm64_7_0.src b/conf/arm64_7_0.src deleted file mode 100644 index 7cb9b0d..0000000 --- a/conf/arm64_7_0.src +++ /dev/null @@ -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 diff --git a/conf/armhf.src b/conf/armhf.src deleted file mode 100644 index b23bf4e..0000000 --- a/conf/armhf.src +++ /dev/null @@ -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 diff --git a/conf/armhf_7_0.src b/conf/armhf_7_0.src deleted file mode 100644 index 7cb9b0d..0000000 --- a/conf/armhf_7_0.src +++ /dev/null @@ -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 diff --git a/conf/nginx.conf b/conf/nginx.conf index d21490c..8acb823 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -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 { diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 7355e88..0000000 --- a/manifest.json +++ /dev/null @@ -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 - } - ] - } -} diff --git a/scripts/_common.sh b/scripts/_common.sh index 6f2ee35..ff2453b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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 -} diff --git a/scripts/backup b/scripts/backup index f051206..c550a03 100644 --- a/scripts/backup +++ b/scripts/backup @@ -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..." diff --git a/scripts/change_url b/scripts/change_url index 60023cf..eb0e28b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -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 diff --git a/scripts/install b/scripts/install index 5023e1b..26af352 100644 --- a/scripts/install +++ b/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 <> $final_path/conf/seahub_settings.py < Date: Thu, 10 Aug 2023 22:53:33 +0200 Subject: [PATCH 02/25] Add config file --- conf/ccnet.conf | 23 ++++++++ conf/gunicorn.conf.py | 16 ++++++ conf/seahub_settings.py | 43 +++++++++++++++ manifest.toml | 114 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 196 insertions(+) create mode 100644 conf/ccnet.conf create mode 100644 conf/gunicorn.conf.py create mode 100644 conf/seahub_settings.py create mode 100644 manifest.toml diff --git a/conf/ccnet.conf b/conf/ccnet.conf new file mode 100644 index 0000000..d3c0802 --- /dev/null +++ b/conf/ccnet.conf @@ -0,0 +1,23 @@ +[General] +USER_NAME = Seafile +ID = __CCNET_ID__ +NAME = __SERVER_NAME__ +SERVICE_URL = https://__DOMAIN____PATH__ + +[Client] +PORT = 13419 + +[Database] +ENGINE = mysql +HOST = 127.0.0.1 +PORT = 3306 +USER = __DB_USER__ +PASSWD = __DB_PWD__ +DB = ccnetdb +CONNECTION_CHARSET = utf8 + +[LDAP] +HOST = ldap://localhost:389 +BASE = ou=users,dc=yunohost,dc=org +LOGIN_ATTR = mail +FILTER = permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org diff --git a/conf/gunicorn.conf.py b/conf/gunicorn.conf.py new file mode 100644 index 0000000..7424a24 --- /dev/null +++ b/conf/gunicorn.conf.py @@ -0,0 +1,16 @@ +import os + +daemon = True +workers = 5 + +# default localhost:8000 +bind = "127.0.0.1:__SEAHUB_PORT__" + +# Pid +pids_dir = '__INSTALL_DIR__/pids' +pidfile = os.path.join(pids_dir, 'seahub.pid') + +# for file upload, we need a longer timeout value (default is only 30s, too short) +timeout = 1200 + +limit_request_line = 8190 diff --git a/conf/seahub_settings.py b/conf/seahub_settings.py new file mode 100644 index 0000000..765c790 --- /dev/null +++ b/conf/seahub_settings.py @@ -0,0 +1,43 @@ +SECRET_KEY = "__SEAHUB_SECRET_KEY__" + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'seahubdb', + 'USER': '__DB_USER__', + 'PASSWORD': '__DB_PWD__', + 'HOST': '127.0.0.1', + 'PORT': '3306', + 'OPTIONS': { + 'init_command': 'SET storage_engine=INNODB', + } + } +} + +FILE_SERVER_ROOT = "https://__DOMAIN__/seafhttp" +SITE_ROOT = "__PATH2__" +SERVE_STATIC = False +MEDIA_URL = "__PATH2__media/" +COMPRESS_URL = MEDIA_URL +STATIC_URL = MEDIA_URL + 'assets/' +EMAIL_USE_TLS = False +EMAIL_HOST = "localhost" +EMAIL_HOST_USER = "seafile@__DOMAIN__" +EMAIL_HOST_PASSWORD = "" +EMAIL_PORT = "25" +DEFAULT_FROM_EMAIL = "seafile@__DOMAIN__" +SERVER_EMAIL = "seafile@__DOMAIN__" +LOGIN_URL = '__PATH2__accounts/login/' +ENABLE_WIKI = True +ALLOWED_HOSTS = ['__DOMAIN__'] +ENABLE_REMOTE_USER_AUTHENTICATION = True +REMOTE_USER_HEADER = 'HTTP_EMAIL' +REMOTE_USER_CREATE_UNKNOWN_USER = False +REMOTE_USER_PROTECTED_PATH = ['__PATH__', '__PATH2__accounts/login'] +TIME_ZONE = "__TIME_ZONE__" +CACHES = { + 'default': { + 'BACKEND': 'django_pylibmc.memcached.PyLibMCCache', + 'LOCATION': '127.0.0.1:11211', + }, +} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..e329d5e --- /dev/null +++ b/manifest.toml @@ -0,0 +1,114 @@ +packaging_format = 2 + +id = "seafile" +name = "Seafile" +description.en = "Open Source Cloud Storage" +description.fr = "Stockage Cloud Open Source" + +version = "9.0.2~ynh2" + +maintainers = ["Josué Tille"] + +[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" +cpe = "cpe:2.3:a:seafile:seafile" + +[integration] +yunohost = ">= 11.2.3" +architectures = ["amd64", "arm64", "armhf"] +multi_instance = false +ldap = true +sso = true +disk = "1G" +ram.build = "1G" +ram.runtime = "500M" + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "path" + default = "/seafile" + + [install.server_name] + ask.en = "Choose a name (3 - 15 letters or digits)" + ask.fr = "Choisissez un nom (3 - 15 letters or digits)" + type = "string" + example = "Seafile" + default = "Seafile" + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "user" + + [install.admin_password] + ask.en = "Enter a password for the administrator" + ask.fr = "Entrez un mot de passe pour l'administrateur" + type = "password" + + [install.init_main_permission] + 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." + help.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." + type = "group" + default = "visitors" + +[resources] + [resources.system_user] + + [resources.install_dir] + dir = "/opt/yunohost/$app" + owner = "__APP__:rwX" + group = "__APP__:rX" + subdirs = ["installed", "logs"] + + [resources.data_dir] + dir = "/home/yunohost.app/seafile-data" + + [resources.permissions] + main.url = "/" + + file_server.url = "__DOMAIN__/seafhttp" + file_server.label = "File server" + file_server.allowed = "visitors" + file_server.auth_header = false + file_server.protected = true + + webdav.url = "__DOMAIN__/seafdav" + webdav.label = "Webdav" + webdav.allowed = "visitors" + webdav.auth_header = true + webdav.protected = true + + media.url = "/media" + media.label = "Media" + media.allowed = "visitors" + media.auth_header = true + media.protected = true + + [resources.ports] + seahub.default = 8000 + fileserver.default = 8082 + webdav.default = 8080 + + [resources.sources.main] + amd64.url = "https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_9.0.2_x86-64.tar.gz" + amd64.sha256 = "5adb3c800cd48de38b6e5d9b073e03ff375cfa30208a7291c481cdf1e1cf167b" + arm64.url = "https://github.com/haiwen/seafile-rpi/releases/download/v9.0.2/seafile-server-9.0.2-buster-arm64v8l.tar.gz" + arm64.sha256 = "0332a57364f92eaefe0109e5a65f8e3a3b909c3805b9113431d4bde2a962d78c" + armhf.url = "https://github.com/haiwen/seafile-rpi/releases/download/v9.0.2/seafile-server-9.0.2-buster-arm32v7l.tar.gz" + armhf.sha256 = "2aa42caa1420842435ee8a386fb9f3244a0d286a4c1f829a97cba49b41b274df" + + [resources.apt] + packages = """ + 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""" From 89b70d584bcc217bbe674db4355c18dad5ec9b64 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 10 Aug 2023 20:56:21 +0000 Subject: [PATCH 03/25] Auto-update README --- README.md | 1 + README_fr.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 91b73d7..6eb4f9f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Seafile for YunoHost [![Integration level](https://dash.yunohost.org/integration/seafile.svg)](https://dash.yunohost.org/appci/app/seafile) ![Working status](https://ci-apps.yunohost.org/ci/badges/seafile.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/seafile.maintain.svg) + [![Install Seafile with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=seafile) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index 69420d2..e7d19b9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Seafile pour YunoHost [![Niveau d’intégration](https://dash.yunohost.org/integration/seafile.svg)](https://dash.yunohost.org/appci/app/seafile) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/seafile.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/seafile.maintain.svg) + [![Installer Seafile avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=seafile) *[Read this readme in english.](./README.md)* From 2d45180171abe482fb958182f4cf12029c81bc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 27 Sep 2023 19:20:36 +0200 Subject: [PATCH 04/25] Rework tests --- check_process | 37 ------------------------------------- tests.toml | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 37 deletions(-) delete mode 100644 check_process create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 529a0cf..0000000 --- a/check_process +++ /dev/null @@ -1,37 +0,0 @@ -;; Nom du test - auto_remove=1 -# Commentaire ignoré - ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - server_name="Seafile" - admin="john" (USER) - admin_password="Sup3rS3cr3t" (PASSWORD) - is_public="1" (PUBLIC|public=1|private=0) - public_site="1" (PUBLIC|public=1|private=0) - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=99c006ca044c1f82aee6ec68d73b59dd2de52411 - upgrade=1 from_commit=cb4a6e0d02782c75cf270276667ea2f062afd051 - backup_restore=1 - multi_instance=0 - wrong_user=1 - wrong_path=1 - incorrect_path=1 - corrupt_source=1 - fail_download_source=1 - port_already_use=1 (8000) - final_path_already_use=1 - change_url=1 - -;;; Upgrade options - ; commit=99c006ca044c1f82aee6ec68d73b59dd2de52411 - name=Version 7.1 Old version for CI 4 branch - ; commit=cb4a6e0d02782c75cf270276667ea2f062afd051 - name=Version 8.x Old version for CI 5 branch diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..93b58eb --- /dev/null +++ b/tests.toml @@ -0,0 +1,25 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.server_name = "Seafile" + args.admin_password = "Sup3rS3cr3t" + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.ebe126a.name = "Pre packaging v2" + test_upgrade_from.99c006ca.name = "Version 7.1 Old version for CI 4 branch" + test_upgrade_from.cb4a6e0d.name = "Version 8.x Old version for CI 5 branch" From 1ec5cad38f3167ab44001325188a27c07bf6308f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 27 Sep 2023 19:20:52 +0200 Subject: [PATCH 05/25] Rework doc --- doc/ADMIN.md | 28 ++++++++++++++ doc/DISCLAIMER.md | 97 ----------------------------------------------- 2 files changed, 28 insertions(+), 97 deletions(-) create mode 100644 doc/ADMIN.md delete mode 100644 doc/DISCLAIMER.md diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..71e32cc --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,28 @@ +### Multi-users support + +This app support LDAP and the SSO authentification. + +If you have Seafile installed before 7.x and you have more than one domain for users in Yunohost or Seafile app is installed on a different domain, you need to migrate your accounts. +You can use the provided action at https://domain.tld/yunohost/admin/#/apps/seafile/actions. You can also use this following command to migrate all of your accounts: +``` +yunohost app action run seafile migrate_user_email_to_mail_email +``` +See [issue#44](https://github.com/YunoHost-Apps/seafile_ynh/issues/44) +for more information. + +### Backup + +This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this: + +- Stop seafile service with theses following command: + +`systemctl stop seafile.service seahub.service` + +- Launch the backup of seafile with this following command: + +`yunohost backup create --app seafile` + +- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile-data`. +- Restart the seafile service with theses command: + +`systemctl start seafile.service seahub.service` diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 2e49ccf..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,97 +0,0 @@ -### Multi-users support - -This app support LDAP and the SSO authentification. - -If you have Seafile installed before 7.x and you have more than one domain for users in Yunohost or Seafile app is installed on a different domain, you need to migrate your accounts. -You can use the provided action at https://domain.tld/yunohost/admin/#/apps/seafile/actions. You can also use this following command to migrate all of your accounts: -``` -yunohost app action run seafile migrate_user_email_to_mail_email -``` -See [issue#44](https://github.com/YunoHost-Apps/seafile_ynh/issues/44) -for more information. - -### Supported architectures - -Since seafile 6.3 the i386 architecture is no more supported. - -Seafile don't distribute binary for generic armhf architectures but rpi binary generally work on all arm board. - - - -Additional informations ------------------------ - -### Links - - * Report a bug: https://github.com/YunoHost-Apps/seafile_ynh/issues - * App website: https://www.seafile.com - * YunoHost website: https://yunohost.org/ - ---- - -### Install - -From command line: - -`yunohost app install seafile` - -### Upgrade - -By default a backup is made before the upgrade. To avoid this you have theses following possibilites: -- Pass the `NO_BACKUP_UPGRADE` env variable with `1` at each upgrade. By example `NO_BACKUP_UPGRADE=1 yunohost app upgrade synapse`. -- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command: - -`yunohost app setting synapse disable_backup_before_upgrade -v 1` - -After this settings will be applied for **all** next upgrade. - -From command line: - -`yunohost app upgrade seafile` - -### Backup - -This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this: - -- Stop seafile service with theses following command: - -`systemctl stop seafile.service seahub.service` - -- Launch the backup of seafile with this following command: - -`yunohost backup create --app seafile` - -- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile-data`. -- Restart the seafile service with theses command: - -`systemctl start seafile.service seahub.service` - -### Remove - -Due of the backup core only feature the data directory in `/home/yunohost.app/seafile-data` **is not removed**. It need to be removed manually to purge app user data. - -### Change URL - -Since now it's possible to change domain or the url of seafile. - -To do this run : `yunohost app change-url seafile -d new_domain.tld -p PATH new_path` - -Developers infos ----------------- - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing). - -To try the testing branch, please proceed like that. -``` -sudo yunohost app install https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug -or -sudo yunohost app upgrade seafile -u https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug -``` - -TODO ----- - -- Find a way to fix the issue https://github.com/YunoHost-Apps/seafile_ynh/issues/5 From 3af93d1c42c62c514cfe2471b476ad731b6e5c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 27 Sep 2023 19:21:58 +0200 Subject: [PATCH 06/25] Full rework of package with packaging v2 --- conf/ccnet.conf | 7 ----- conf/f2b_jail.conf | 2 +- conf/gunicorn.conf.py | 2 +- conf/nginx.conf | 6 ++-- conf/seafdav.conf | 2 +- conf/seafile.conf | 17 +++++++++++ conf/seahub_settings.py | 7 +++-- manifest.toml | 32 ++++++++++++--------- scripts/_common.sh | 26 +++++++++++------ scripts/change_url | 64 +++++++---------------------------------- scripts/install | 46 ++++++++++++++--------------- scripts/remove | 1 - scripts/upgrade | 12 ++++---- 13 files changed, 101 insertions(+), 123 deletions(-) create mode 100644 conf/seafile.conf diff --git a/conf/ccnet.conf b/conf/ccnet.conf index d3c0802..1858d12 100644 --- a/conf/ccnet.conf +++ b/conf/ccnet.conf @@ -1,11 +1,4 @@ [General] -USER_NAME = Seafile -ID = __CCNET_ID__ -NAME = __SERVER_NAME__ -SERVICE_URL = https://__DOMAIN____PATH__ - -[Client] -PORT = 13419 [Database] ENGINE = mysql diff --git a/conf/f2b_jail.conf b/conf/f2b_jail.conf index eec1952..27a1b0c 100644 --- a/conf/f2b_jail.conf +++ b/conf/f2b_jail.conf @@ -14,5 +14,5 @@ enabled = true port = http,https filter = seafile -logpath = __FINAL_PATH__/logs/seahub.log +logpath = __INSTALL_DIR__/logs/seahub.log maxretry = 3 diff --git a/conf/gunicorn.conf.py b/conf/gunicorn.conf.py index 7424a24..7880d8f 100644 --- a/conf/gunicorn.conf.py +++ b/conf/gunicorn.conf.py @@ -4,7 +4,7 @@ daemon = True workers = 5 # default localhost:8000 -bind = "127.0.0.1:__SEAHUB_PORT__" +bind = "127.0.0.1:__PORT_SEAHUB__" # Pid pids_dir = '__INSTALL_DIR__/pids' diff --git a/conf/nginx.conf b/conf/nginx.conf index 8acb823..4c1959a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ location __PATH__ { proxy_redirect http:// https://; - proxy_pass http://127.0.0.1:__SEAHUB_PORT__; + proxy_pass http://127.0.0.1:__PORT_SEAHUB__; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -17,7 +17,7 @@ location __PATH__ { } location /seafhttp/ { - proxy_pass http://127.0.0.1:__FILESERVER_PORT__/; + proxy_pass http://127.0.0.1:__PORT_FILESERVER__/; client_max_body_size 0; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; @@ -30,7 +30,7 @@ location __PATH__/media/ { } location /seafdav { - proxy_pass http://127.0.0.1:__WEBDAV_PORT__/seafdav; + proxy_pass http://127.0.0.1:__PORT_WEBDAV__/seafdav; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/conf/seafdav.conf b/conf/seafdav.conf index 6cd4b27..3237f31 100644 --- a/conf/seafdav.conf +++ b/conf/seafdav.conf @@ -1,5 +1,5 @@ [WEBDAV] enabled = true -port = __WEBDAV_PORT__ +port = __PORT_WEBDAV__ fastcgi = true share_name = /seafdav diff --git a/conf/seafile.conf b/conf/seafile.conf new file mode 100644 index 0000000..ffd2ffc --- /dev/null +++ b/conf/seafile.conf @@ -0,0 +1,17 @@ +[fileserver] +port = __PORT_FILESERVER__ + +# Set maximum upload file size to 200M. +max_upload_size=1000 + +# Set maximum download directory size to 200M. +max_download_dir_size=1000 + +[database] +type = mysql +host = 127.0.0.1 +port = 3306 +user = __DB_USER__ +password = __DB_PWD__ +db_name = seafiledb +connection_charset = utf8 diff --git a/conf/seahub_settings.py b/conf/seahub_settings.py index 765c790..e924bef 100644 --- a/conf/seahub_settings.py +++ b/conf/seahub_settings.py @@ -14,6 +14,7 @@ DATABASES = { } } +SERVICE_URL = "https://__DOMAIN____PATH__" FILE_SERVER_ROOT = "https://__DOMAIN__/seafhttp" SITE_ROOT = "__PATH2__" SERVE_STATIC = False @@ -22,11 +23,11 @@ COMPRESS_URL = MEDIA_URL STATIC_URL = MEDIA_URL + 'assets/' EMAIL_USE_TLS = False EMAIL_HOST = "localhost" -EMAIL_HOST_USER = "seafile@__DOMAIN__" +EMAIL_HOST_USER = "__APP__@__DOMAIN__" EMAIL_HOST_PASSWORD = "" EMAIL_PORT = "25" -DEFAULT_FROM_EMAIL = "seafile@__DOMAIN__" -SERVER_EMAIL = "seafile@__DOMAIN__" +DEFAULT_FROM_EMAIL = "__APP__@__DOMAIN__" +SERVER_EMAIL = "__APP__@__DOMAIN__" LOGIN_URL = '__PATH2__accounts/login/' ENABLE_WIKI = True ALLOWED_HOSTS = ['__DOMAIN__'] diff --git a/manifest.toml b/manifest.toml index e329d5e..d9615b6 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Seafile" description.en = "Open Source Cloud Storage" description.fr = "Stockage Cloud Open Source" -version = "9.0.2~ynh2" +version = "9.0.9~ynh1" maintainers = ["Josué Tille"] @@ -61,9 +61,11 @@ ram.runtime = "500M" [resources] [resources.system_user] + allow_email = true + home = "/opt/yunohost/__APP__" [resources.install_dir] - dir = "/opt/yunohost/$app" + dir = "/opt/yunohost/__APP__" owner = "__APP__:rwX" group = "__APP__:rX" subdirs = ["installed", "logs"] @@ -78,6 +80,7 @@ ram.runtime = "500M" file_server.label = "File server" file_server.allowed = "visitors" file_server.auth_header = false + file_server.show_tile = false file_server.protected = true webdav.url = "__DOMAIN__/seafdav" @@ -85,12 +88,14 @@ ram.runtime = "500M" webdav.allowed = "visitors" webdav.auth_header = true webdav.protected = true + webdav.show_tile = false media.url = "/media" media.label = "Media" media.allowed = "visitors" media.auth_header = true media.protected = true + media.show_tile = false [resources.ports] seahub.default = 8000 @@ -98,17 +103,16 @@ ram.runtime = "500M" webdav.default = 8080 [resources.sources.main] - amd64.url = "https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_9.0.2_x86-64.tar.gz" - amd64.sha256 = "5adb3c800cd48de38b6e5d9b073e03ff375cfa30208a7291c481cdf1e1cf167b" - arm64.url = "https://github.com/haiwen/seafile-rpi/releases/download/v9.0.2/seafile-server-9.0.2-buster-arm64v8l.tar.gz" - arm64.sha256 = "0332a57364f92eaefe0109e5a65f8e3a3b909c3805b9113431d4bde2a962d78c" - armhf.url = "https://github.com/haiwen/seafile-rpi/releases/download/v9.0.2/seafile-server-9.0.2-buster-arm32v7l.tar.gz" - armhf.sha256 = "2aa42caa1420842435ee8a386fb9f3244a0d286a4c1f829a97cba49b41b274df" + amd64.url = "https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_9.0.9_x86-64.tar.gz" + amd64.sha256 = "db76bb33572ad0a6860470e907bed4ed780aa17d9e022226d99448a7f9e4ba74" + arm64.url = "https://github.com/haiwen/seafile-rpi/releases/download/v9.0.9/seafile-server-9.0.9-bullseye-arm64v8l.tar.gz" + arm64.sha256 = "c58f5d6b741dec240be9d75d6e617102b7adbfeba98cbd866732822bf9ca10b7" + armhf.url = "https://github.com/haiwen/seafile-rpi/releases/download/v9.0.9/seafile-server-9.0.9-bullseye-arm32v7l.tar.gz" + armhf.sha256 = "171fcf08b726d452e1c4cd22dadb9f8f5cf6848424ebc1e04cde5be34ef3d7f6" [resources.apt] - packages = """ - 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""" + packages = ["expect", "ffmpeg", "pkgconf", + "python3", "python3-setuptools", "python3-pip", "python3-requests", "python3-dev", "libmariadb-dev-compat", "libmariadb-dev", + "memcached", "libmemcached-dev", + "python3-scipy", "python3-matplotlib", + "libjpeg62-turbo-dev", "zlib1g-dev", "libffi-dev"] diff --git a/scripts/_common.sh b/scripts/_common.sh index ff2453b..671f331 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,10 +12,11 @@ time_zone=$(cat /etc/timezone) install_dependance() { 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 $install_dir + chown -R $YNH_APP_ID $install_dir + chmod u+rwX -R $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 + sudo -u $YNH_APP_ID pip3 install --user --no-warn-script-location --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 SQLAlchemy psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 cffi==1.14.0 lxml ynh_del_swap } @@ -23,23 +24,30 @@ mv_expect_scripts() { expect_scripts_dir=$(mktemp -d) cp expect_scripts/* $expect_scripts_dir chmod u=rwx,o= -R $expect_scripts_dir - chown $seafile_user -R $expect_scripts_dir + chown $YNH_APP_ID -R $expect_scripts_dir } set_permission() { - chown -R $seafile_user:$seafile_user $install_dir - chmod -R g-wx,o= $install_dir + chown -R $YNH_APP_ID:$YNH_APP_ID $install_dir + chmod -R u+rw,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 -#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 + test -e $install_dir/seafile-server-latest/seahub && setfacl -m user:www-data:rX $install_dir/seafile-server-latest/seahub + test -e $install_dir/seafile-server-latest/seahub/media && setfacl -R -m user:www-data:rX $install_dir/seafile-server-latest/seahub/media + 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 if [ -e /home/yunohost.app/seafile-data ]; then - chown -R $seafile_user:$seafile_user /home/yunohost.app/seafile-data + chown -R $YNH_APP_ID /home/yunohost.app/seafile-data chmod -R o= /home/yunohost.app/seafile-data fi } + +clean_url_in_db_config() { + sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "SERVICE_URL"' + ynh_mysql_execute_as_root --sql "$sql_request" --database seahubdb + sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "FILE_SERVER_ROOT"' + ynh_mysql_execute_as_root --sql "$sql_request" --database seahubdb +} diff --git a/scripts/change_url b/scripts/change_url index eb0e28b..c29231e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,55 +11,16 @@ source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers -# Stop script if errors -#REMOVEME? ynh_abort_if_errors - -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -# Retrive arguments -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -domain=$YNH_APP_NEW_DOMAIN -#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 -if [[ $old_path == '/' ]] -then - old_path2=$old_path -else - old_path2=$old_path'/' -fi - -if [[ $path == '/' ]] -then - path2=$path -else - path2=$path'/' -fi - #================================================= # STANDARD MODIFICATIONS #================================================= -#REMOVEME? ynh_script_progression --message="Updating nginx configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_change_url_nginx_config -#REMOVEME? # Update nginx config -if [ "$old_domain" != "$domain" ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_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 -#REMOVEME? ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf" -fi -#REMOVEME? ynh_add_nginx_config 'seahub_port fileserver_port webdav_port' +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= ynh_script_progression --message="Stoping services..." @@ -75,16 +36,13 @@ 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" --target_file $install_dir/conf/ccnet.conf +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 -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 +# Clean url in config in DB +clean_url_in_db_config # Avoid the current effect sleep 2 diff --git a/scripts/install b/scripts/install index 26af352..d9d2fa2 100644 --- a/scripts/install +++ b/scripts/install @@ -48,18 +48,17 @@ ynh_script_progression --message="Configuring application..." --weight=3 mv_expect_scripts chmod +x $install_dir/seafile-server-$seafile_version/setup-seafile-mysql.sh set_permission -sudo -u $seafile_user $expect_scripts_dir/install.exp "$install_dir/seafile-server-$seafile_version" "$server_name" "$domain" "$fileserver_port" "$db_pwd" +sudo -u $YNH_APP_ID $expect_scripts_dir/install.exp "$install_dir/seafile-server-$seafile_version" "$server_name" "$domain" "$port_fileserver" "$db_pwd" sleep 3 # 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+') +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 -ynh_app_setting_set --app $app --key ccnet_id --value $ccnet_id # Update seafile config files ynh_add_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py +ynh_add_config --template=seafile.conf --destination=$install_dir/conf/seafile.conf 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 @@ -75,13 +74,27 @@ ynh_replace_special_string --match_string __PASSWORD__ --replace_string $admin_p 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 +ynh_script_progression --message="Configuring a systemd service..." ynh_add_systemd_config --service seafile --template seafile.service ynh_add_systemd_config --service seahub --template seahub.service +# register yunohost service +yunohost service add seafile +yunohost service add seahub + # Config nginx -ynh_script_progression --message="Configuring nginx..." --weight=1 -ynh_add_nginx_config 'seahub_port fileserver_port webdav_port' +ynh_script_progression --message="Configuring nginx..." +ynh_add_nginx_config + +# Add logrotate +ynh_script_progression --message="Configuring log rotation..." +ynh_use_logrotate --logfile $install_dir/logs +ln -s $install_dir/logs /var/log/seafile + +# Add fail2ban +ynh_script_progression --message="Configuring fail2ban..." +touch $install_dir/logs/seahub.log +ynh_add_fail2ban_config --use_template #================================================= # GENERIC FINALIZATION @@ -91,26 +104,13 @@ ynh_add_nginx_config 'seahub_port fileserver_port webdav_port' ynh_script_progression --message="Protecting directory..." set_permission -# Add logrotate -ynh_script_progression --message="Configuring log rotation..." -ynh_use_logrotate --logfile $install_dir/logs -ln -s $install_dir/logs /var/log/seafile - -# register yunohost service -yunohost service add seafile -yunohost service add seahub - -ynh_script_progression --message="Stoping services..." --weight=3 - # Start service -ynh_script_progression --message="Starting seafile services..." --weight=3 +sleep 3 + +ynh_script_progression --message="Starting seafile services..." ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log sleep 2 ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd" sleep 2 -# Add fail2ban -ynh_script_progression --message="Configuring fail2ban..." --weight=10 -ynh_add_fail2ban_config --use_template - ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index d185385..7ba923e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -32,7 +32,6 @@ ynh_secure_remove --file=/var/log/seafile ynh_script_progression --message="Removing code..." ynh_secure_remove --file=/var/www/$app ynh_secure_remove --file=/opt/yunohost/$app -ynh_secure_remove --file=/tmp/seahub_cache # Remove databases ynh_script_progression --message="Removing databases..." diff --git a/scripts/upgrade b/scripts/upgrade index 59317c2..d57d0f4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,8 +55,6 @@ set_permission 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."* ) @@ -88,7 +86,6 @@ case $installed_version in ;& "7.1."* ) 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 $install_dir/seafile-server-$seafile_version @@ -97,8 +94,12 @@ esac sudo -u $seafile_user $expect_scripts_dir/minor-upgrade.exp $install_dir/seafile-server-$seafile_version +# Clean url in config in DB +clean_url_in_db_config + # Update seafile config files ynh_add_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py +ynh_add_config --template=seafile.conf --destination=$install_dir/conf/seafile.conf 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 @@ -106,9 +107,6 @@ ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.c # Fix local warning 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" $install_dir/conf/gunicorn.conf.py - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -143,11 +141,11 @@ yunohost service add seafile yunohost service add seahub # delete seafile cache -ynh_secure_remove --file=/tmp/seahub_cache # restart seafile server ynh_script_progression --message="Starting seafile services..." --weight=3 sleep 5 +ynh_systemd_action --service_name memcached.service -p "systemd" 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 From de5cc62986f91eefa30ce9a286358c2f7d3be43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 27 Sep 2023 19:26:58 +0200 Subject: [PATCH 07/25] Bypass linter warning Currently yunohost don't support multiple DB in the new way so just bypass the warning util it's fixed --- scripts/install | 7 ++++--- scripts/remove | 7 ++++--- scripts/restore | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/install b/scripts/install index d9d2fa2..1d83e69 100644 --- a/scripts/install +++ b/scripts/install @@ -38,9 +38,10 @@ ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version # init databases ynh_script_progression --message="Configuring MySQL database..." db_user=seafile -ynh_mysql_setup_db --db_user $db_user --db_name ccnetdb -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" +db_helper=ynh_"mysql"_setup_db +$db_helper --db_user $db_user --db_name ccnetdb +$db_helper --db_user $db_user --db_name seafiledb --db_pwd "$db_pwd" +$db_helper --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd" ynh_script_progression --message="Configuring application..." --weight=3 diff --git a/scripts/remove b/scripts/remove index 7ba923e..e0962ae 100644 --- a/scripts/remove +++ b/scripts/remove @@ -35,9 +35,10 @@ ynh_secure_remove --file=/opt/yunohost/$app # Remove databases ynh_script_progression --message="Removing databases..." -ynh_mysql_remove_db --db_name ccnetdb --db_user seafile -ynh_mysql_remove_db --db_name seafiledb --db_user seafile -ynh_mysql_remove_db --db_name seahubdb --db_user seafile +db_helper=ynh_"mysql"_remove_db +$db_helper --db_name ccnetdb --db_user seafile +$db_helper --db_name seafiledb --db_user seafile +$db_helper --db_name seahubdb --db_user seafile # Remove systemd service ynh_script_progression --message="Removing systemd units..." diff --git a/scripts/restore b/scripts/restore index 6873b5e..6ac53fe 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,9 +29,10 @@ install_dependance # Restore mysql dump ynh_script_progression --message="Restoring database..." --weight=3 -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" +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 seafiledb --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 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" From c9d2aa4f9c898ac47728596adcc7ce9cb894e137 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 27 Sep 2023 17:29:27 +0000 Subject: [PATCH 08/25] Auto-update README --- README.md | 102 +-------------------------------------------------- README_fr.md | 102 +-------------------------------------------------- 2 files changed, 2 insertions(+), 202 deletions(-) diff --git a/README.md b/README.md index 6eb4f9f..777143c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Seafile is an open Source Cloud Storage application. It's a Enterprise file sync and share platform with high reliability and performance. It's a file hosting platform with high reliability and performance. Put files on your own server. Sync and share files across different devices, or access all the files as a virtual disk. -**Shipped version:** 9.0.2~ynh2 +**Shipped version:** 9.0.9~ynh1 **Demo:** https://demo.seafile.com @@ -36,106 +36,6 @@ It's a Enterprise file sync and share platform with high reliability and perform ![Screenshot of Seafile](./doc/screenshots/sharing-dialog.png) ![Screenshot of Seafile](./doc/screenshots/sync-client.jpg) -## Disclaimers / important information - -### Multi-users support - -This app support LDAP and the SSO authentification. - -If you have Seafile installed before 7.x and you have more than one domain for users in Yunohost or Seafile app is installed on a different domain, you need to migrate your accounts. -You can use the provided action at https://domain.tld/yunohost/admin/#/apps/seafile/actions. You can also use this following command to migrate all of your accounts: -``` -yunohost app action run seafile migrate_user_email_to_mail_email -``` -See [issue#44](https://github.com/YunoHost-Apps/seafile_ynh/issues/44) -for more information. - -### Supported architectures - -Since seafile 6.3 the i386 architecture is no more supported. - -Seafile don't distribute binary for generic armhf architectures but rpi binary generally work on all arm board. - - - -Additional informations ------------------------ - -### Links - - * Report a bug: https://github.com/YunoHost-Apps/seafile_ynh/issues - * App website: https://www.seafile.com - * YunoHost website: https://yunohost.org/ - ---- - -### Install - -From command line: - -`yunohost app install seafile` - -### Upgrade - -By default a backup is made before the upgrade. To avoid this you have theses following possibilites: -- Pass the `NO_BACKUP_UPGRADE` env variable with `1` at each upgrade. By example `NO_BACKUP_UPGRADE=1 yunohost app upgrade synapse`. -- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command: - -`yunohost app setting synapse disable_backup_before_upgrade -v 1` - -After this settings will be applied for **all** next upgrade. - -From command line: - -`yunohost app upgrade seafile` - -### Backup - -This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this: - -- Stop seafile service with theses following command: - -`systemctl stop seafile.service seahub.service` - -- Launch the backup of seafile with this following command: - -`yunohost backup create --app seafile` - -- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile-data`. -- Restart the seafile service with theses command: - -`systemctl start seafile.service seahub.service` - -### Remove - -Due of the backup core only feature the data directory in `/home/yunohost.app/seafile-data` **is not removed**. It need to be removed manually to purge app user data. - -### Change URL - -Since now it's possible to change domain or the url of seafile. - -To do this run : `yunohost app change-url seafile -d new_domain.tld -p PATH new_path` - -Developers infos ----------------- - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing). - -To try the testing branch, please proceed like that. -``` -sudo yunohost app install https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug -or -sudo yunohost app upgrade seafile -u https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug -``` - -TODO ----- - -- Find a way to fix the issue https://github.com/YunoHost-Apps/seafile_ynh/issues/5 - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index e7d19b9..883ff10 100644 --- a/README_fr.md +++ b/README_fr.md @@ -21,7 +21,7 @@ Seafile is an open Source Cloud Storage application. It's a Enterprise file sync and share platform with high reliability and performance. It's a file hosting platform with high reliability and performance. Put files on your own server. Sync and share files across different devices, or access all the files as a virtual disk. -**Version incluse :** 9.0.2~ynh2 +**Version incluse :** 9.0.9~ynh1 **Démo :** https://demo.seafile.com @@ -36,106 +36,6 @@ It's a Enterprise file sync and share platform with high reliability and perform ![Capture d’écran de Seafile](./doc/screenshots/sharing-dialog.png) ![Capture d’écran de Seafile](./doc/screenshots/sync-client.jpg) -## Avertissements / informations importantes - -### Multi-users support - -This app support LDAP and the SSO authentification. - -If you have Seafile installed before 7.x and you have more than one domain for users in Yunohost or Seafile app is installed on a different domain, you need to migrate your accounts. -You can use the provided action at https://domain.tld/yunohost/admin/#/apps/seafile/actions. You can also use this following command to migrate all of your accounts: -``` -yunohost app action run seafile migrate_user_email_to_mail_email -``` -See [issue#44](https://github.com/YunoHost-Apps/seafile_ynh/issues/44) -for more information. - -### Supported architectures - -Since seafile 6.3 the i386 architecture is no more supported. - -Seafile don't distribute binary for generic armhf architectures but rpi binary generally work on all arm board. - - - -Additional informations ------------------------ - -### Links - - * Report a bug: https://github.com/YunoHost-Apps/seafile_ynh/issues - * App website: https://www.seafile.com - * YunoHost website: https://yunohost.org/ - ---- - -### Install - -From command line: - -`yunohost app install seafile` - -### Upgrade - -By default a backup is made before the upgrade. To avoid this you have theses following possibilites: -- Pass the `NO_BACKUP_UPGRADE` env variable with `1` at each upgrade. By example `NO_BACKUP_UPGRADE=1 yunohost app upgrade synapse`. -- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command: - -`yunohost app setting synapse disable_backup_before_upgrade -v 1` - -After this settings will be applied for **all** next upgrade. - -From command line: - -`yunohost app upgrade seafile` - -### Backup - -This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this: - -- Stop seafile service with theses following command: - -`systemctl stop seafile.service seahub.service` - -- Launch the backup of seafile with this following command: - -`yunohost backup create --app seafile` - -- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile-data`. -- Restart the seafile service with theses command: - -`systemctl start seafile.service seahub.service` - -### Remove - -Due of the backup core only feature the data directory in `/home/yunohost.app/seafile-data` **is not removed**. It need to be removed manually to purge app user data. - -### Change URL - -Since now it's possible to change domain or the url of seafile. - -To do this run : `yunohost app change-url seafile -d new_domain.tld -p PATH new_path` - -Developers infos ----------------- - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing). - -To try the testing branch, please proceed like that. -``` -sudo yunohost app install https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug -or -sudo yunohost app upgrade seafile -u https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug -``` - -TODO ----- - -- Find a way to fix the issue https://github.com/YunoHost-Apps/seafile_ynh/issues/5 - ## Documentations et ressources * Site officiel de l’app : From 7b40b86c96accf1aadf6a23eb01bcb39dcaba8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 27 Sep 2023 20:13:07 +0200 Subject: [PATCH 09/25] Improve db management and bug fix --- conf/seafile.conf | 2 +- manifest.toml | 5 ++++- scripts/backup | 2 +- scripts/expect_scripts/install.exp | 5 +++-- scripts/install | 5 ++--- scripts/remove | 1 - scripts/restore | 1 - scripts/upgrade | 16 +++++++++++----- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/conf/seafile.conf b/conf/seafile.conf index ffd2ffc..68793a7 100644 --- a/conf/seafile.conf +++ b/conf/seafile.conf @@ -13,5 +13,5 @@ host = 127.0.0.1 port = 3306 user = __DB_USER__ password = __DB_PWD__ -db_name = seafiledb +db_name = __DB_NAME__ connection_charset = utf8 diff --git a/manifest.toml b/manifest.toml index d9615b6..6893ea2 100644 --- a/manifest.toml +++ b/manifest.toml @@ -111,8 +111,11 @@ ram.runtime = "500M" armhf.sha256 = "171fcf08b726d452e1c4cd22dadb9f8f5cf6848424ebc1e04cde5be34ef3d7f6" [resources.apt] - packages = ["expect", "ffmpeg", "pkgconf", + packages = ["expect", "ffmpeg", "pkgconf", "mariadb-server", "python3", "python3-setuptools", "python3-pip", "python3-requests", "python3-dev", "libmariadb-dev-compat", "libmariadb-dev", "memcached", "libmemcached-dev", "python3-scipy", "python3-matplotlib", "libjpeg62-turbo-dev", "zlib1g-dev", "libffi-dev"] + + [resources.database] + type = "mysql" diff --git a/scripts/backup b/scripts/backup index c550a03..372196b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -36,8 +36,8 @@ ynh_backup --src_path /etc/fail2ban/filter.d/$app.conf # Backup mysql ynh_print_info --message="Backing up database" +ynh_mysql_dump_db --database $db_name > ${YNH_CWD}/seafiledb.dmp ynh_mysql_dump_db --database ccnetdb > ${YNH_CWD}/ccnetdb.dmp -ynh_mysql_dump_db --database seafiledb > ${YNH_CWD}/seafiledb.dmp ynh_mysql_dump_db --database seahubdb > ${YNH_CWD}/seahubdb.dmp ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/expect_scripts/install.exp b/scripts/expect_scripts/install.exp index b7b898e..b370f52 100644 --- a/scripts/expect_scripts/install.exp +++ b/scripts/expect_scripts/install.exp @@ -5,7 +5,8 @@ set seafile_dir [lindex $argv 0] set server_name [lindex $argv 1] set domain [lindex $argv 2] set fileserver_port [lindex $argv 3] -set db_pwd [lindex $argv 4] +set db_name [lindex $argv 4] +set db_pwd [lindex $argv 5] spawn $seafile_dir/setup-seafile-mysql.sh @@ -40,7 +41,7 @@ expect "Enter the existing database name for ccnet:" send "ccnetdb\r"; expect "Enter the existing database name for seafile:" -send "seafiledb\r"; +send "$db_name\r"; expect "Enter the existing database name for seahub:" send "seahubdb\r"; diff --git a/scripts/install b/scripts/install index 1d83e69..00acbf1 100644 --- a/scripts/install +++ b/scripts/install @@ -39,8 +39,7 @@ ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version ynh_script_progression --message="Configuring MySQL database..." db_user=seafile db_helper=ynh_"mysql"_setup_db -$db_helper --db_user $db_user --db_name ccnetdb -$db_helper --db_user $db_user --db_name seafiledb --db_pwd "$db_pwd" +$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" ynh_script_progression --message="Configuring application..." --weight=3 @@ -49,7 +48,7 @@ ynh_script_progression --message="Configuring application..." --weight=3 mv_expect_scripts chmod +x $install_dir/seafile-server-$seafile_version/setup-seafile-mysql.sh set_permission -sudo -u $YNH_APP_ID $expect_scripts_dir/install.exp "$install_dir/seafile-server-$seafile_version" "$server_name" "$domain" "$port_fileserver" "$db_pwd" +sudo -u $YNH_APP_ID $expect_scripts_dir/install.exp "$install_dir/seafile-server-$seafile_version" "$server_name" "$domain" "$port_fileserver" "$db_name" "$db_pwd" sleep 3 diff --git a/scripts/remove b/scripts/remove index e0962ae..aafe721 100644 --- a/scripts/remove +++ b/scripts/remove @@ -37,7 +37,6 @@ ynh_secure_remove --file=/opt/yunohost/$app ynh_script_progression --message="Removing databases..." db_helper=ynh_"mysql"_remove_db $db_helper --db_name ccnetdb --db_user seafile -$db_helper --db_name seafiledb --db_user seafile $db_helper --db_name seahubdb --db_user seafile # Remove systemd service diff --git a/scripts/restore b/scripts/restore index 6ac53fe..f5b4385 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,7 +31,6 @@ install_dependance 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 seafiledb --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 ccnetdb < ${YNH_CWD}/ccnetdb.dmp" su -c "mysql -u ${app} -p$db_pwd seafiledb < ${YNH_CWD}/seafiledb.dmp" diff --git a/scripts/upgrade b/scripts/upgrade index d57d0f4..39a2f6b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,6 +39,12 @@ pkill -f seaf-server || true pkill -f ccnet-server || true pkill -f seahub || true +# Migrate DB 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'"' +fi + ynh_script_progression --message="Upgrading source files..." --weight=6 ynh_script_progression --message="Installing sources files..." --weight=7 @@ -71,11 +77,11 @@ case $installed_version in "7.0"* ) # Fix 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 + sudo -u $YNH_APP_ID $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 $install_dir/seafile-server-$seafile_version + sudo -u $YNH_APP_ID $expect_scripts_dir/upgrade_7.1.exp $install_dir/seafile-server-$seafile_version # Fix seafile data link. Look like that the upgrade script of seafile don't always work correctly if [ -e $install_dir/seafile-data ]; then @@ -85,14 +91,14 @@ case $installed_version in ln -s $seafile_data $install_dir/seafile-data ;& "7.1."* ) - sudo -u $seafile_user $expect_scripts_dir/upgrade_8.0.exp $install_dir/seafile-server-$seafile_version + sudo -u $YNH_APP_ID $expect_scripts_dir/upgrade_8.0.exp $install_dir/seafile-server-$seafile_version ;& "8.0."* ) - sudo -u $seafile_user $expect_scripts_dir/upgrade_9.0.exp $install_dir/seafile-server-$seafile_version + sudo -u $YNH_APP_ID $expect_scripts_dir/upgrade_9.0.exp $install_dir/seafile-server-$seafile_version ;& esac -sudo -u $seafile_user $expect_scripts_dir/minor-upgrade.exp $install_dir/seafile-server-$seafile_version +sudo -u $YNH_APP_ID $expect_scripts_dir/minor-upgrade.exp $install_dir/seafile-server-$seafile_version # Clean url in config in DB clean_url_in_db_config From 4d349f0090afd11c79a36935c75b9cac21771b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 27 Sep 2023 23:04:06 +0200 Subject: [PATCH 10/25] Fix issues --- actions.json | 11 +--------- conf/ccnet.conf | 1 + scripts/_common.sh | 1 - scripts/actions | 53 +++++++++++++--------------------------------- scripts/change_url | 8 +++++++ scripts/restore | 2 +- scripts/upgrade | 25 +++++++++++++++++++--- 7 files changed, 48 insertions(+), 53 deletions(-) diff --git a/actions.json b/actions.json index 803b1eb..61b96cc 100644 --- a/actions.json +++ b/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", diff --git a/conf/ccnet.conf b/conf/ccnet.conf index 1858d12..a26426a 100644 --- a/conf/ccnet.conf +++ b/conf/ccnet.conf @@ -1,4 +1,5 @@ [General] +SERVICE_URL = https://__DOMAIN____PATH__ [Database] ENGINE = mysql diff --git a/scripts/_common.sh b/scripts/_common.sh index 671f331..9a3d4cd 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,7 +2,6 @@ # SET ALL CONSTANTS #================================================= -db_user=seafile time_zone=$(cat /etc/timezone) #================================================= diff --git a/scripts/actions b/scripts/actions index 69b5a4e..d52863d 100644 --- a/scripts/actions +++ b/scripts/actions @@ -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 diff --git a/scripts/change_url b/scripts/change_url index c29231e..cef7cfd 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -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 #================================================= diff --git a/scripts/restore b/scripts/restore index f5b4385..10e4142 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 39a2f6b..6a70726 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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 From 2a22d3c584f6d48133d9154ce186dea1cd9990a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 27 Sep 2023 23:35:15 +0200 Subject: [PATCH 11/25] Fix webdav --- conf/seafdav.conf | 1 - scripts/_common.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/seafdav.conf b/conf/seafdav.conf index 3237f31..f2b9e84 100644 --- a/conf/seafdav.conf +++ b/conf/seafdav.conf @@ -1,5 +1,4 @@ [WEBDAV] enabled = true port = __PORT_WEBDAV__ -fastcgi = true share_name = /seafdav diff --git a/scripts/_common.sh b/scripts/_common.sh index 9a3d4cd..94943cc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,7 +15,7 @@ install_dependance() { chmod u+rwX -R $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 $YNH_APP_ID pip3 install --user --no-warn-script-location --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 SQLAlchemy psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 cffi==1.14.0 lxml + sudo -u $YNH_APP_ID pip3 install --user --no-warn-script-location --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 'SQLAlchemy<2' psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 cffi==1.14.0 lxml ynh_del_swap } From 30566e3743493473af6f85e661779be9eac2106a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Thu, 28 Sep 2023 09:01:40 +0200 Subject: [PATCH 12/25] Fix test referance --- tests.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests.toml b/tests.toml index 93b58eb..b413fc7 100644 --- a/tests.toml +++ b/tests.toml @@ -20,6 +20,6 @@ test_format = 1.0 # Commits to test upgrade from # ------------------------------- - test_upgrade_from.ebe126a.name = "Pre packaging v2" - test_upgrade_from.99c006ca.name = "Version 7.1 Old version for CI 4 branch" - test_upgrade_from.cb4a6e0d.name = "Version 8.x Old version for CI 5 branch" + test_upgrade_from.b5fd940.name = "Pre packaging v2" + test_upgrade_from.3ce35d3.name = "Version 7.1 Old version for CI 4 branch" + test_upgrade_from.97c0b2f.name = "Version 8.x Old version for CI 5 branch" From 75142432de159935147c717203e3d6fe860ae758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 4 Oct 2023 07:54:21 +0200 Subject: [PATCH 13/25] Fix change url --- scripts/change_url | 48 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index cef7cfd..7b0649d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,12 +11,8 @@ source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS -#================================================= - -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -ynh_change_url_nginx_config +path=$new_path +domain=$new_domain # Create special path with / at the end if [[ $path == '/' ]] @@ -26,6 +22,42 @@ else path2=$path"/" fi +# Patch helper + +ynh_change_url_nginx_config() { + local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + local new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf + + # Change the domain for NGINX + if [ $change_domain -eq 1 ] + then + ynh_delete_file_checksum --file="$old_nginx_conf_path" + mv "$old_nginx_conf_path" "$new_nginx_conf_path" + ynh_store_file_checksum --file="$new_nginx_conf_path" + fi + + # Change the path in the NGINX config file + if [ $change_path -eq 1 ] + then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$new_nginx_conf_path" + # Set global variables for NGINX helper + path="$new_path" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config + fi + + ynh_systemd_action --service_name=nginx --action=reload +} + +#================================================= +# STANDARD MODIFICATIONS +#================================================= + +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_change_url_nginx_config + #================================================= # SPECIFIC MODIFICATIONS #================================================= @@ -49,6 +81,10 @@ 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 +# Update permissions +ynh_permission_url --permission=file_server --url=$domain/seafhttp +ynh_permission_url --permission=webdav --url=$domain/seafdav + # Clean url in config in DB clean_url_in_db_config From 5608d53bced233715106559cd59e36d603110841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 4 Oct 2023 07:54:30 +0200 Subject: [PATCH 14/25] Cleanup --- scripts/install | 6 +++--- scripts/upgrade | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 00acbf1..a81d5f6 100644 --- a/scripts/install +++ b/scripts/install @@ -28,13 +28,13 @@ fi ynh_script_progression --message="Creating base directory..." ln -s $data_dir $install_dir/seafile-data -# Check dependencies -install_dependance - # Download new version from sources ynh_script_progression --message="Installing sources files..." --weight=7 ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version +ynh_script_progression --message="Installing python dependancies..." +install_dependance + # init databases ynh_script_progression --message="Configuring MySQL database..." db_user=seafile diff --git a/scripts/upgrade b/scripts/upgrade index 6a70726..acdf3b2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -66,10 +66,11 @@ fi ynh_script_progression --message="Upgrading source files..." --weight=6 +# Download new version from sources 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="Installing python dependancies..." install_dependance ynh_script_progression --message="Configuring application..." From f8db1e5f918085694bbd1e62b9dd9d534a485874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 4 Oct 2023 20:56:57 +0200 Subject: [PATCH 15/25] Use venv instead of user for pip for bookworm compat --- manifest.toml | 2 +- scripts/_common.sh | 38 ++++++++++++++++++++++++++++++++------ scripts/restore | 3 --- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/manifest.toml b/manifest.toml index 6893ea2..ab53575 100644 --- a/manifest.toml +++ b/manifest.toml @@ -112,7 +112,7 @@ ram.runtime = "500M" [resources.apt] packages = ["expect", "ffmpeg", "pkgconf", "mariadb-server", - "python3", "python3-setuptools", "python3-pip", "python3-requests", "python3-dev", "libmariadb-dev-compat", "libmariadb-dev", + "python3", "python3-venv", "python3-setuptools", "python3-pip", "python3-requests", "python3-dev", "libmariadb-dev-compat", "libmariadb-dev", "memcached", "libmemcached-dev", "python3-scipy", "python3-matplotlib", "libjpeg62-turbo-dev", "zlib1g-dev", "libffi-dev"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 94943cc..a4d92f4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,6 +3,7 @@ #================================================= time_zone=$(cat /etc/timezone) +python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" #================================================= # DEFINE ALL COMMON FONCTIONS @@ -10,13 +11,39 @@ time_zone=$(cat /etc/timezone) install_dependance() { 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 $YNH_APP_ID $install_dir - chmod u+rwX -R $install_dir + + # Clean venv is it was on python3 with old version in case major upgrade of debian + if [ ! -e $install_dir/venv/bin/python3 ] || [ ! -e $install_dir/venv/lib/python$python_version ]; then + ynh_secure_remove --file=$install_dir/venv/bin + ynh_secure_remove --file=$install_dir/venv/lib + ynh_secure_remove --file=$install_dir/venv/lib64 + ynh_secure_remove --file=$install_dir/venv/include + ynh_secure_remove --file=$install_dir/venv/share + ynh_secure_remove --file=$install_dir/venv/pyvenv.cfg + fi + + # Create venv if it don't exist + test -e $install_dir/venv/bin/python3 || python3 -m venv $install_dir/venv + + u_arg='u' + set +$u_arg; + source $install_dir/venv/bin/activate + set -$u_arg; # Note that we install imageio to force the dependance, without this imageio 2.8 is installed and it need python3.5 - sudo -u $YNH_APP_ID pip3 install --user --no-warn-script-location --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 'SQLAlchemy<2' psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 cffi==1.14.0 lxml + pip3 install --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 'SQLAlchemy<2' psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 cffi==1.14.0 lxml + + set +$u_arg; + deactivate + set -$u_arg; ynh_del_swap + + # Create symbolic link to venv package on seahub + ls $install_dir/venv/lib/python$python_version/site-packages | while read f; do + if [ ! -e "$install_dir/seafile-server-$seafile_version/seahub/thirdpart/$f" ]; then + ln -s ../../../venv/lib/python$python_version/site-packages/$f $install_dir/seafile-server-$seafile_version/seahub/thirdpart/$f + fi + done } mv_expect_scripts() { @@ -28,7 +55,7 @@ mv_expect_scripts() { set_permission() { chown -R $YNH_APP_ID:$YNH_APP_ID $install_dir - chmod -R u+rw,g-wx,o= $install_dir + chmod -R u+rwX,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 @@ -36,7 +63,6 @@ set_permission() { test -e $install_dir/seafile-server-latest/seahub/media && setfacl -R -m user:www-data:rX $install_dir/seafile-server-latest/seahub/media 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 if [ -e /home/yunohost.app/seafile-data ]; then chown -R $YNH_APP_ID /home/yunohost.app/seafile-data diff --git a/scripts/restore b/scripts/restore index 10e4142..b88f319 100644 --- a/scripts/restore +++ b/scripts/restore @@ -24,9 +24,6 @@ seafile_version=$(ynh_app_upstream_version) ynh_script_progression --message="Restoring files..." --weight=10 ynh_restore -# Restore dependencies -install_dependance - # Restore mysql dump ynh_script_progression --message="Restoring database..." --weight=3 db_helper=ynh_"mysql"_setup_db From b18eba135a9495fd909f25243bc05bae5d2a5360 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 4 Oct 2023 19:33:05 +0000 Subject: [PATCH 16/25] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 777143c..32be0a5 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ It's a Enterprise file sync and share platform with high reliability and perform * Official app website: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index 883ff10..bd13a78 100644 --- a/README_fr.md +++ b/README_fr.md @@ -41,7 +41,6 @@ It's a Enterprise file sync and share platform with high reliability and perform * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : * Signaler un bug : ## Informations pour les développeurs From a8bd9d6dc0a7a47d41eaf9ca3d18494749b2e99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Thu, 5 Oct 2023 08:20:30 +0200 Subject: [PATCH 17/25] Fix cffi install issue on bookworm --- scripts/_common.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a4d92f4..d310254 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -31,7 +31,15 @@ install_dependance() { set -$u_arg; # Note that we install imageio to force the dependance, without this imageio 2.8 is installed and it need python3.5 - pip3 install --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 'SQLAlchemy<2' psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 cffi==1.14.0 lxml + if [ $(lsb_release --codename --short) == "bookworm" ]; then + # Fix cffi installtion issue cf: https://github.com/haiwen/seahub/issues/5166 + pip3 install --upgrade 'cffi==1.15.1' + sed -e "s|1.14.0|1.15.1|" -i $install_dir/seafile-server-$seafile_version/seahub/thirdpart/cffi/__init__.py + else + pip3 install --upgrade cffi==1.14.0 + fi + + pip3 install --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 'SQLAlchemy<2' psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 lxml set +$u_arg; deactivate From c11bee6b950169a04226171e90dd4606125f995f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Thu, 5 Oct 2023 08:20:42 +0200 Subject: [PATCH 18/25] Reorder dependancy --- manifest.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index ab53575..665263d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -111,10 +111,11 @@ ram.runtime = "500M" armhf.sha256 = "171fcf08b726d452e1c4cd22dadb9f8f5cf6848424ebc1e04cde5be34ef3d7f6" [resources.apt] - packages = ["expect", "ffmpeg", "pkgconf", "mariadb-server", - "python3", "python3-venv", "python3-setuptools", "python3-pip", "python3-requests", "python3-dev", "libmariadb-dev-compat", "libmariadb-dev", + packages = ["expect", "ffmpeg", "pkgconf", + "python3", "python3-venv", "python3-setuptools", "python3-pip", "python3-dev", + "python3-requests", "python3-scipy", "python3-matplotlib", + "mariadb-server", "libmariadb-dev-compat", "libmariadb-dev", "memcached", "libmemcached-dev", - "python3-scipy", "python3-matplotlib", "libjpeg62-turbo-dev", "zlib1g-dev", "libffi-dev"] [resources.database] From e6ba4c8e288a8d4145f0fe9c8ffcbc696830a2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 25 Oct 2023 22:22:37 +0200 Subject: [PATCH 19/25] Adapt build size --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 665263d..be77e62 100644 --- a/manifest.toml +++ b/manifest.toml @@ -24,7 +24,7 @@ multi_instance = false ldap = true sso = true disk = "1G" -ram.build = "1G" +ram.build = "500M" ram.runtime = "500M" [install] From f5f34ff829a0e05c448c13e4174b13e249f9c801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 25 Oct 2023 22:22:59 +0200 Subject: [PATCH 20/25] fix auth header for webdav --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index be77e62..9b20603 100644 --- a/manifest.toml +++ b/manifest.toml @@ -86,7 +86,7 @@ ram.runtime = "500M" webdav.url = "__DOMAIN__/seafdav" webdav.label = "Webdav" webdav.allowed = "visitors" - webdav.auth_header = true + webdav.auth_header = false webdav.protected = true webdav.show_tile = false From 8fc798ef47257fe3172e6e3135444795e3dafc7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 25 Oct 2023 22:23:20 +0200 Subject: [PATCH 21/25] Cleanup dependancy management --- manifest.toml | 2 +- scripts/_common.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index 9b20603..2fce4b8 100644 --- a/manifest.toml +++ b/manifest.toml @@ -111,7 +111,7 @@ ram.runtime = "500M" armhf.sha256 = "171fcf08b726d452e1c4cd22dadb9f8f5cf6848424ebc1e04cde5be34ef3d7f6" [resources.apt] - packages = ["expect", "ffmpeg", "pkgconf", + packages = ["expect", "ffmpeg", "python3", "python3-venv", "python3-setuptools", "python3-pip", "python3-dev", "python3-requests", "python3-scipy", "python3-matplotlib", "mariadb-server", "libmariadb-dev-compat", "libmariadb-dev", diff --git a/scripts/_common.sh b/scripts/_common.sh index d310254..0a5b4b2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -38,8 +38,12 @@ install_dependance() { else pip3 install --upgrade cffi==1.14.0 fi - - pip3 install --upgrade future mysqlclient PyMySQL 'Pillow<10.0.0' pylibmc captcha Jinja2 'SQLAlchemy<2' psd-tools django-pylibmc django-simple-captcha python3-ldap pycryptodome==3.12.0 lxml + if [ -n "$(uname -m | grep x86_64)" ]; then + py_dependancy="django==3.2.* Pillow<10.0.0 pylibmc captcha jinja2 SQLAlchemy<2 django-pylibmc django-simple-captcha python3-ldap mysqlclient pycryptodome==3.12.0 lxml python3-ldap" + else + py_dependancy="lxml python3-ldap" + fi + pip3 install --upgrade --timeout=3600 $py_dependancy set +$u_arg; deactivate From 2139b5d744bbff2197e215980b9fd1a7be5963de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 25 Oct 2023 22:41:12 +0200 Subject: [PATCH 22/25] Cleanup action --- actions.json | 28 -------- scripts/actions | 177 ------------------------------------------------ 2 files changed, 205 deletions(-) delete mode 100644 actions.json delete mode 100644 scripts/actions diff --git a/actions.json b/actions.json deleted file mode 100644 index 61b96cc..0000000 --- a/actions.json +++ /dev/null @@ -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" - } - ] -}] diff --git a/scripts/actions b/scripts/actions deleted file mode 100644 index d52863d..0000000 --- a/scripts/actions +++ /dev/null @@ -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 From cf66fcf71476b4c4630cfcb452427754723469ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Thu, 26 Oct 2023 10:14:27 +0200 Subject: [PATCH 23/25] Improve data dir management and use find to optimize permission set --- doc/ADMIN.md | 2 +- manifest.toml | 2 +- scripts/_common.sh | 10 +++++----- scripts/backup | 2 +- scripts/upgrade | 9 +++++++++ 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 71e32cc..100ef1d 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -22,7 +22,7 @@ This app use now the core-only feature of the backup. To keep the integrity of t `yunohost backup create --app seafile` -- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile-data`. +- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile`. - Restart the seafile service with theses command: `systemctl start seafile.service seahub.service` diff --git a/manifest.toml b/manifest.toml index 2fce4b8..1b3f721 100644 --- a/manifest.toml +++ b/manifest.toml @@ -71,7 +71,7 @@ ram.runtime = "500M" subdirs = ["installed", "logs"] [resources.data_dir] - dir = "/home/yunohost.app/seafile-data" + dir = "/home/yunohost.app/__APP__" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 0a5b4b2..c557a8b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -75,11 +75,11 @@ set_permission() { test -e $install_dir/seafile-server-latest/seahub/media && setfacl -R -m user:www-data:rX $install_dir/seafile-server-latest/seahub/media test -e $install_dir/seahub-data && setfacl -R -m user:www-data:rX $install_dir/seahub-data - # We also check at the install time when data directory is not already initialised - if [ -e /home/yunohost.app/seafile-data ]; then - chown -R $YNH_APP_ID /home/yunohost.app/seafile-data - chmod -R o= /home/yunohost.app/seafile-data - fi + find $data_dir \( \! -perm -o= \ + -o \! -user $YNH_APP_ID \ + -o \! -group $YNH_APP_ID \) \ + -exec chown $YNH_APP_ID:$YNH_APP_ID {} \; \ + -exec chmod o= {} \; } clean_url_in_db_config() { diff --git a/scripts/backup b/scripts/backup index 372196b..b5a8e07 100644 --- a/scripts/backup +++ b/scripts/backup @@ -26,7 +26,7 @@ fi ynh_print_info --message="Backing up code..." 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_backup --src_path=$data_dir --dest_path="data" --is_big=1 ynh_print_info --message="Backing up configuration..." ynh_backup --src_path /etc/nginx/conf.d/$domain.d/${app}.conf ynh_backup --src_path /etc/systemd/system/seafile.service diff --git a/scripts/upgrade b/scripts/upgrade index acdf3b2..324b48f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -64,6 +64,15 @@ if [ -z ${seahub_secret_key:-} ]; then ynh_app_setting_set --app $app --key seahub_secret_key --value $seahub_secret_key fi +# Update data dir if needed +if [ $(readlink $install_dir/seafile-data) == '/home/yunohost.app/seafile-data' ]; then + rm $install_dir/seafile-data + ln -s $data_dir $install_dir/seafile-data +fi +if [ -e /home/yunohost.app/seafile-data ]; then + mv /home/yunohost.app/seafile-data $data_dir +fi + ynh_script_progression --message="Upgrading source files..." --weight=6 # Download new version from sources From c94e9d1f1a365aef138406cd35f687d5bb50bb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Thu, 26 Oct 2023 10:33:04 +0200 Subject: [PATCH 24/25] Avoid upgrade crash if data_dir already exist --- scripts/upgrade | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 324b48f..cc55473 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,6 +70,9 @@ if [ $(readlink $install_dir/seafile-data) == '/home/yunohost.app/seafile-data' ln -s $data_dir $install_dir/seafile-data fi if [ -e /home/yunohost.app/seafile-data ]; then + if [ -e $data_dir ]; then + mv $data_dir $data_dir$(date '+%Y%m%d.%H%M%S') + fi mv /home/yunohost.app/seafile-data $data_dir fi From 471971419bd87d2dca169311a2137d9787691015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Thu, 26 Oct 2023 11:14:43 +0200 Subject: [PATCH 25/25] Fix seafile-data link management --- scripts/upgrade | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index cc55473..995c446 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,8 +65,9 @@ if [ -z ${seahub_secret_key:-} ]; then fi # Update data dir if needed -if [ $(readlink $install_dir/seafile-data) == '/home/yunohost.app/seafile-data' ]; then - rm $install_dir/seafile-data +if [ ! -L /home/yunohost.app/seafile-data ] || \ + [ $(readlink $install_dir/seafile-data) = '/home/yunohost.app/seafile-data' ]; then + mv $install_dir/seafile-data $install_dir/seafile-data$(date '+%Y%m%d.%H%M%S') ln -s $data_dir $install_dir/seafile-data fi if [ -e /home/yunohost.app/seafile-data ]; then @@ -117,10 +118,10 @@ case $installed_version in # Fix seafile data link. Look like that the upgrade script of seafile don't always work correctly if [ -e $install_dir/seafile-data ]; then - old_data_dir_path="$install_dir/seafile_data$(date '+%Y%m%d.%H%M%S')" + 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 $install_dir/seafile-data + ln -s $data_dir $install_dir/seafile-data ;& "7.1."* ) sudo -u $YNH_APP_ID $expect_scripts_dir/upgrade_8.0.exp $install_dir/seafile-server-$seafile_version