diff --git a/README.md b/README.md index ee8a207..ceb0497 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 cd6324c..f7d5bce 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 : diff --git a/actions.json b/actions.json deleted file mode 100644 index 803b1eb..0000000 --- a/actions.json +++ /dev/null @@ -1,37 +0,0 @@ -[{ - "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", - "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/check_process b/check_process deleted file mode 100644 index 1d329b2..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=3ce35d35ca4a8bac9b3d49d900af6a2b41577f9a - upgrade=1 from_commit=97c0b2f6548c2e415641533c4746682747eacb94 - 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=3ce35d35ca4a8bac9b3d49d900af6a2b41577f9a - name=Version 7.1 Old version for CI 4 branch - ; commit=97c0b2f6548c2e415641533c4746682747eacb94 - name=Version 8.x Old version for CI 5 branch 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/ccnet.conf b/conf/ccnet.conf new file mode 100644 index 0000000..a26426a --- /dev/null +++ b/conf/ccnet.conf @@ -0,0 +1,17 @@ +[General] +SERVICE_URL = https://__DOMAIN____PATH__ + +[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/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 new file mode 100644 index 0000000..7880d8f --- /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:__PORT_SEAHUB__" + +# 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/nginx.conf b/conf/nginx.conf index d21490c..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; @@ -26,11 +26,11 @@ location /seafhttp/ { location __PATH__/media/ { - alias __FINALPATH__/seafile-server-latest/seahub/media/; + alias __INSTALL_DIR__/seafile-server-latest/seahub/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..f2b9e84 100644 --- a/conf/seafdav.conf +++ b/conf/seafdav.conf @@ -1,5 +1,4 @@ [WEBDAV] enabled = true -port = __WEBDAV_PORT__ -fastcgi = true +port = __PORT_WEBDAV__ share_name = /seafdav diff --git a/conf/seafile.conf b/conf/seafile.conf new file mode 100644 index 0000000..68793a7 --- /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 = __DB_NAME__ +connection_charset = utf8 diff --git a/conf/seahub_settings.py b/conf/seahub_settings.py new file mode 100644 index 0000000..e924bef --- /dev/null +++ b/conf/seahub_settings.py @@ -0,0 +1,44 @@ +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', + } + } +} + +SERVICE_URL = "https://__DOMAIN____PATH__" +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 = "__APP__@__DOMAIN__" +EMAIL_HOST_PASSWORD = "" +EMAIL_PORT = "25" +DEFAULT_FROM_EMAIL = "__APP__@__DOMAIN__" +SERVER_EMAIL = "__APP__@__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/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..100ef1d --- /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`. +- 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 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/manifest.toml b/manifest.toml new file mode 100644 index 0000000..1b3f721 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,122 @@ +packaging_format = 2 + +id = "seafile" +name = "Seafile" +description.en = "Open Source Cloud Storage" +description.fr = "Stockage Cloud Open Source" + +version = "9.0.9~ynh1" + +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 = "500M" +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] + allow_email = true + home = "/opt/yunohost/__APP__" + + [resources.install_dir] + dir = "/opt/yunohost/__APP__" + owner = "__APP__:rwX" + group = "__APP__:rX" + subdirs = ["installed", "logs"] + + [resources.data_dir] + dir = "/home/yunohost.app/__APP__" + + [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.show_tile = false + file_server.protected = true + + webdav.url = "__DOMAIN__/seafdav" + webdav.label = "Webdav" + webdav.allowed = "visitors" + webdav.auth_header = false + 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 + 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.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 = ["expect", "ffmpeg", + "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", + "libjpeg62-turbo-dev", "zlib1g-dev", "libffi-dev"] + + [resources.database] + type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index f34215f..c557a8b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,81 +2,89 @@ # SET ALL CONSTANTS #================================================= -app=$YNH_APP_INSTANCE_NAME +time_zone=$(cat /etc/timezone) +python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" #================================================= # 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 + + # 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 $seafile_user 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 - # TODO add dependance when upgrade to seafile 8: django==2.2.* + 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 + 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 + 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() { 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 $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 $YNH_APP_ID:$YNH_APP_ID $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 - 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 + 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 - 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= {} \; } -ynh_clean_setup () { - pkill -f seafile-controller - pkill -f seaf-server - pkill -f ccnet-server - pkill -f seahub +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/actions b/scripts/actions deleted file mode 100644 index 69b5a4e..0000000 --- a/scripts/actions +++ /dev/null @@ -1,200 +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 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 - - # 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 -} - -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/backup b/scripts/backup index f051206..b5a8e07 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,9 +24,9 @@ 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_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 @@ -45,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/change_url b/scripts/change_url index 60023cf..7b0649d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,55 +11,56 @@ source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers -# Stop script if errors -ynh_abort_if_errors - -ynh_script_progression --message="Loading installation settings..." - -# Retrive arguments -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) -seafile_user=$app +path=$new_path +domain=$new_domain # Create special path with / at the end -if [[ $old_path == '/' ]] +if [[ $path == '/' ]] then - old_path2=$old_path + path2=$path else - old_path2=$old_path'/' + path2=$path"/" fi -if [[ $path_url == '/' ]] -then - path_url2=$path_url -else - path_url2=$path_url'/' -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 configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_change_url_nginx_config -# 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" - - 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" -fi -ynh_add_nginx_config 'seahub_port fileserver_port webdav_port' +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= ynh_script_progression --message="Stoping services..." @@ -75,16 +76,17 @@ 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_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 $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 +# 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 # Avoid the current effect sleep 2 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 5023e1b..a81d5f6 100644 --- a/scripts/install +++ b/scripts/install @@ -11,175 +11,90 @@ 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 - -# Check dependencies -ynh_script_progression --message="Installing dependencies..." --weight=7 -install_dependance +ln -s $data_dir $install_dir/seafile-data # 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 + +ynh_script_progression --message="Installing python dependancies..." +install_dependance # 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_pwd "$db_pwd" +$db_helper --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd" 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 $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 -# 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*".+"' $install_dir/conf/seahub_settings.py | cut -d'"' -f2) +ynh_app_setting_set --app $app --key seahub_secret_key --value $seahub_secret_key -# 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 <