Merge pull request #78 from YunoHost-Apps/testing

Testing
This commit is contained in:
yalh76 2021-08-14 22:55:26 +02:00 committed by GitHub
commit 9daf0c2263
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 463 additions and 275 deletions

55
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,55 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install the_app
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

View file

@ -14,7 +14,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. 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:** 7.0.4 **Shipped version:** 8.0.5
Screenshots Screenshots
----------- -----------
@ -88,6 +88,14 @@ From command line:
### Upgrade ### 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: From command line:
`yunohost app upgrade seafile` `yunohost app upgrade seafile`

View file

@ -19,7 +19,7 @@
upgrade=1 upgrade=1
upgrade=1 from_commit=db11d890922564dfdcb7937a3a682957082fbb31 upgrade=1 from_commit=db11d890922564dfdcb7937a3a682957082fbb31
upgrade=1 from_commit=67e0869de25f4f58710c3d30d5533356745ea676 upgrade=1 from_commit=67e0869de25f4f58710c3d30d5533356745ea676
upgrade=1 from_commit=637a32aa57bc2dc6421e0e79d52862f0924be1cf upgrade=1 from_commit=6786d9f65e60b2d2a96b9ea4c43897dde3a66199
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
wrong_user=1 wrong_user=1
@ -30,23 +30,11 @@
port_already_use=1 (8000) port_already_use=1 (8000)
final_path_already_use=1 final_path_already_use=1
change_url=1 change_url=1
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# https://github.com/YunoHost-Apps/seafile_ynh/issues/1
Level 4=1
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Upgrade options ;;; Upgrade options
; commit=db11d890922564dfdcb7937a3a682957082fbb31 ; commit=db11d890922564dfdcb7937a3a682957082fbb31
name=Version 6.3.4 - branch Old_version_for_CI_3 name=Version 6.3.4 - branch Old_version_for_CI_3
; commit=67e0869de25f4f58710c3d30d5533356745ea676 ; commit=67e0869de25f4f58710c3d30d5533356745ea676
name=Before move main dir to opt - branch Old_version_for_CI_2 name=Before move main dir to opt - branch Old_version_for_CI_2
; commit=637a32aa57bc2dc6421e0e79d52862f0924be1cf ; commit=6786d9f65e60b2d2a96b9ea4c43897dde3a66199
name=The oldest installable version - branch Old_version_for_CI name=The oldest installable version - branch Old_version_for_CI

View file

@ -1,12 +0,0 @@
import json
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
if "skipped_urls" in data:
data["skipped_urls"].append("/seafhttp")
else:
data["skipped_urls"] = ["/seafhttp"]
data["skipped_urls"].append("/seafdav")
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,8 +0,0 @@
import json
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
data["skipped_urls"].append("/seafdav")
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v7.0.5/seafile-server_7.0.5_stable_pi.tar.gz SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v8.0.5/seafile-server-8.0.5-buster-armv7l.tar.gz
SOURCE_SUM=dae9ab5d232a2b56f129aa29e7e54d2de05d838f0479955543cebcb14c9417db SOURCE_SUM=53a909c0bcb796b21fec3518e9092ec20f8a8b933dc61ea26f3a04aab66efc79
# (Optional) Program to check the integrity (sha256sum, md5sum...) # (Optional) Program to check the integrity (sha256sum, md5sum...)
# default: sha256 # default: sha256
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum

11
conf/arm64.src Normal file
View file

@ -0,0 +1,11 @@
SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v8.0.5/seafile-server-8.0.5-buster-armv7l.tar.gz
SOURCE_SUM=53a909c0bcb796b21fec3518e9092ec20f8a8b933dc61ea26f3a04aab66efc79
# (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

11
conf/arm64_7_0.src Normal file
View file

@ -0,0 +1,11 @@
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

11
conf/arm_7_0.src Normal file
View file

@ -0,0 +1,11 @@
SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v7.0.5/seafile-server_7.0.5_stable_pi.tar.gz
SOURCE_SUM=dae9ab5d232a2b56f129aa29e7e54d2de05d838f0479955543cebcb14c9417db
# (Optional) Program to check the integrity (sha256sum, md5sum...)
# default: sha256
SOURCE_SUM_PRG=sha256sum
# (Optional) Archive format
# default: tar.gz
SOURCE_FORMAT=tar.gz
# (Optional) Put false if sources are directly in the archive root
# default: true
SOURCE_IN_SUBDIR=true

1
conf/create_admin.json Normal file
View file

@ -0,0 +1 @@
{"email": "__ADMIN__", "password": "__PASSWORD__"}

View file

@ -30,21 +30,13 @@ location __PATH__/media/ {
} }
location /seafdav { location /seafdav {
fastcgi_pass 127.0.0.1:__WEBDAV_PORT__; proxy_pass http://127.0.0.1:__WEBDAV_PORT__/seafdav;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; proxy_set_header Host $host;
fastcgi_param PATH_INFO $fastcgi_script_name; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
fastcgi_param SERVER_PROTOCOL $server_protocol; proxy_set_header X-Forwarded-Host $server_name;
fastcgi_param QUERY_STRING $query_string; proxy_set_header X-Forwarded-Proto $scheme;
fastcgi_param REQUEST_METHOD $request_method; proxy_read_timeout 1200s;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS on;
client_max_body_size 0; client_max_body_size 0;
access_log /var/log/nginx/seafdav.access.log; access_log /var/log/nginx/seafdav.access.log;

View file

@ -1,19 +1,11 @@
location /seafdav { location /seafdav {
fastcgi_pass 127.0.0.1:WEBDAV_PORT; proxy_pass http://127.0.0.1:__WEBDAV_PORT__/seafdav;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; proxy_set_header Host $host;
fastcgi_param PATH_INFO $fastcgi_script_name; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
fastcgi_param SERVER_PROTOCOL $server_protocol; proxy_set_header X-Forwarded-Host $server_name;
fastcgi_param QUERY_STRING $query_string; proxy_set_header X-Forwarded-Proto $scheme;
fastcgi_param REQUEST_METHOD $request_method; proxy_read_timeout 1200s;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS on;
client_max_body_size 0; client_max_body_size 0;
access_log /var/log/nginx/seafdav.access.log; access_log /var/log/nginx/seafdav.access.log;

View file

@ -1,9 +0,0 @@
import json
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
data["skipped_urls"].remove("/seafhttp")
data["skipped_urls"].remove("/seafdav")
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,14 +0,0 @@
import json
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
data["unprotected_urls"].remove("/seafhttp")
data["unprotected_urls"].remove("/seafdav")
if "skipped_urls" in data:
data["skipped_urls"].append("/seafhttp")
else:
data["skipped_urls"] = ["/seafhttp"]
data["skipped_urls"].append("/seafdav")
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://download.seadrive.org/seafile-server_7.0.5_x86-64.tar.gz SOURCE_URL=https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_8.0.5_x86-64.tar.gz
SOURCE_SUM=7eb8814f1bc8ee78c80741fa08cbdce2b5ea8895a87730bde2a1b32d031e8f53 SOURCE_SUM=4065e877e9675afba958aa1007db0d3a53949f8987d7f9849dfa29a6a13a06bf
# (Optional) Program to check the integrity (sha256sum, md5sum...) # (Optional) Program to check the integrity (sha256sum, md5sum...)
# default: sha256 # default: sha256
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum

11
conf/x86-64_7_0.src Normal file
View file

@ -0,0 +1,11 @@
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

View file

@ -4,7 +4,7 @@
"packaging_format": 1, "packaging_format": 1,
"license": "AGPL-3.0,Apache-2.0,MIT,GPL-2.0", "license": "AGPL-3.0,Apache-2.0,MIT,GPL-2.0",
"url": "https://www.seafile.com", "url": "https://www.seafile.com",
"version": "7.0.5~ynh1", "version": "8.0.5~ynh1",
"description": { "description": {
"en": "Open Source Cloud Storage", "en": "Open Source Cloud Storage",
"fr": "Stockage Cloud Open Source" "fr": "Stockage Cloud Open Source"
@ -23,7 +23,7 @@
"mysql" "mysql"
], ],
"requirements": { "requirements": {
"yunohost": ">= 3.5.2.2" "yunohost": ">= 4.1"
}, },
"arguments": { "arguments": {
"install": [ "install": [

View file

@ -3,8 +3,6 @@
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
[[ -e "../settings/manifest.json" ]] || [[ -e "../manifest.json" ]] && \
seafile_version=$(ynh_app_upstream_version)
#================================================= #=================================================
# DEFINE ALL COMMON FONCTIONS # DEFINE ALL COMMON FONCTIONS
@ -19,29 +17,54 @@ install_source() {
ynh_setup_source "$final_path/seafile-server-$seafile_version" "$architecture" ynh_setup_source "$final_path/seafile-server-$seafile_version" "$architecture"
} }
install_dependance() { install_source_7_0() {
if [ "$(lsb_release --codename --short)" == "stretch" ]; then if ! [ -e $final_path/seafile-server-7.0.5 ]; then
ynh_install_app_dependencies python2.7 python-pip libpython2.7 python-setuptools python-ldap python-urllib3 python-simplejson python-imaging python-mysqldb python-flup expect python-requests python-dev ffmpeg python-memcache \ mkdir "$final_path/seafile-server-7.0.5"
libjpeg62-turbo-dev zlib1g-dev # For building pillow if [[ $architecture == "i386" ]]
else then
ynh_install_app_dependencies python2.7 python-pip libpython2.7 python-setuptools python-ldap python-urllib3 python-simplejson python-pil python-mysqldb python-flup expect python-requests python-dev ffmpeg python-memcache \ 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"
libjpeg62-turbo-dev zlib1g-dev # For building pillow fi
ynh_setup_source "$final_path/seafile-server-7.0.5" "$architecture"_7_0
fi 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 # For building pillow
ynh_add_swap 2000 ynh_add_swap 2000
# We need to do that because we can have some issue about the permission access to the pip cache without this # We need to do that because we can have some issue about the permission access to the pip cache without this
set_permission chown -R $seafile_user:$seafile_user $final_path
# Note that we install imageio to force the dependance, without this imageio 2.8 is installed and it need python3.5 # 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 pip install --user --upgrade Pillow 'moviepy<1.0' 'imageio<2.8' certifi idna 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
# TODO add dependance when upgrade to seafile 8: django==2.2.*
ynh_del_swap ynh_del_swap
} }
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
}
set_permission() { set_permission() {
chown -R $seafile_user:$seafile_user $final_path 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
setfacl -m user:www-data:rX $final_path/seafile-server-latest/seahub
setfacl -R -m user:www-data:rX $final_path/seafile-server-latest/seahub/media
# check that this directory exist because in some really old install the data could still be in the main seafile directory # 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 # We also check at the install time when data directory is not already initialised
test -e /home/yunohost.app/seafile-data && chown -R $seafile_user:$seafile_user /home/yunohost.app/seafile-data if [ -e /home/yunohost.app/seafile-data ]; then
# Well need to put this here because if test return false, set_permission also return false and the install fail chown -R $seafile_user:$seafile_user /home/yunohost.app/seafile-data
true chmod -R o= /home/yunohost.app/seafile-data
fi
} }
ynh_clean_setup () { ynh_clean_setup () {

View file

@ -4,16 +4,16 @@
# GENERIC START # GENERIC START
#================================================= #=================================================
# Import common cmd
source scripts/experimental_helper.sh
source scripts/_common.sh
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Stop script if errors # Stop script if errors
ynh_abort_if_errors ynh_abort_if_errors
# Import common cmd
source scripts/experimental_helper.sh
source scripts/_common.sh
ynh_print_info --message="Loading installation settings..." ynh_print_info --message="Loading installation settings..."
# Retrive arguments # Retrive arguments

View file

@ -4,25 +4,26 @@
# GENERIC START # GENERIC START
#================================================= #=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Stop script if errors # Stop script if errors
ynh_abort_if_errors ynh_abort_if_errors
# Import common cmd ynh_print_info --message="Loading installation settings..."
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
ynh_script_progression --message="Loading installation settings..."
# retrieve useful param # retrieve useful param
domain=$(ynh_app_setting_get --app $app --key domain) domain=$(ynh_app_setting_get --app $app --key domain)
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd) db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
final_path=$(ynh_app_setting_get --app $app --key final_path) final_path=$(ynh_app_setting_get --app $app --key final_path)
seafile_version=$(ynh_app_upstream_version)
seafile_user=$app seafile_user=$app
if [[ ! "$(systemctl status seafile)" =~ "Active: inactive (dead)" ]] || [[ ! "$(systemctl status seahub)" =~ "Active: inactive (dead)" ]]; then 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'" 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'"
fi fi
@ -31,11 +32,11 @@ fi
#================================================= #=================================================
# # Backup app files # # Backup app files
ynh_script_progression --message="Backing up code..." --weight=3 ynh_print_info --message="Backing up code..."
ynh_backup --src_path $final_path ynh_backup --src_path $final_path
ynh_script_progression --message="Backing up user data..." --weight=10 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=/home/yunohost.app/seafile-data --dest_path="data" --is_big=1
ynh_script_progression --message="Backing up configuration..." ynh_print_info --message="Backing up configuration..."
ynh_backup --src_path /etc/nginx/conf.d/$domain.d/${app}.conf ynh_backup --src_path /etc/nginx/conf.d/$domain.d/${app}.conf
ynh_backup --src_path /etc/systemd/system/seafile.service ynh_backup --src_path /etc/systemd/system/seafile.service
ynh_backup --src_path /etc/systemd/system/seahub.service ynh_backup --src_path /etc/systemd/system/seahub.service
@ -43,9 +44,9 @@ ynh_backup --src_path /etc/fail2ban/jail.d/$app.conf
ynh_backup --src_path /etc/fail2ban/filter.d/$app.conf ynh_backup --src_path /etc/fail2ban/filter.d/$app.conf
# Backup mysql # Backup mysql
ynh_script_progression --message="Backing up database" ynh_print_info --message="Backing up database"
ynh_mysql_dump_db --database ccnetdb > ${YNH_CWD}/ccnetdb.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 seafiledb > ${YNH_CWD}/seafiledb.dmp
ynh_mysql_dump_db --database seahubdb > ${YNH_CWD}/seahubdb.dmp ynh_mysql_dump_db --database seahubdb > ${YNH_CWD}/seahubdb.dmp
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -4,16 +4,16 @@
# GENERIC START # GENERIC START
#================================================= #=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Stop script if errors # Stop script if errors
ynh_abort_if_errors ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
# Retrive arguments # Retrive arguments

View file

@ -1,20 +0,0 @@
#!/usr/bin/expect
set timeout 10
set seafile_dir [lindex $argv 0]
set admin_email [lindex $argv 1]
spawn $seafile_dir/seahub.sh start
expect "for the admin account?"
send "$admin_email\r";
expect "for the admin account?"
send {__ADMIN_PASSWORD__};
send '\r';
expect "Enter the"
send {__ADMIN_PASSWORD__};
send '\r';
expect eof

View file

@ -4,9 +4,8 @@ set timeout 10
set seafile_dir [lindex $argv 0] set seafile_dir [lindex $argv 0]
set server_name [lindex $argv 1] set server_name [lindex $argv 1]
set domain [lindex $argv 2] set domain [lindex $argv 2]
set seafile_data [lindex $argv 3] set fileserver_port [lindex $argv 3]
set fileserver_port [lindex $argv 4] set db_pwd [lindex $argv 4]
set db_pwd [lindex $argv 5]
spawn $seafile_dir/setup-seafile-mysql.sh spawn $seafile_dir/setup-seafile-mysql.sh
@ -19,9 +18,6 @@ send "$server_name\r";
expect "What is the ip or domain of the server?" expect "What is the ip or domain of the server?"
send "$domain\r"; send "$domain\r";
expect "Where do you want to put your seafile data?"
send "$seafile_data\r";
expect "Which port do you want to use for the seafile fileserver?" expect "Which port do you want to use for the seafile fileserver?"
send "$fileserver_port\r"; send "$fileserver_port\r";

View file

@ -0,0 +1,19 @@
#!/usr/bin/expect
set timeout 5
set seafile_dir [lindex $argv 0]
spawn $seafile_dir/upgrade/upgrade_7.0_7.1.sh
expect "to contiune"
send "\r";
sleep 10;
send "\r";
sleep 1;
send "\r";
interact

View file

@ -0,0 +1,11 @@
#!/usr/bin/expect
set timeout 5
set seafile_dir [lindex $argv 0]
spawn $seafile_dir/upgrade/upgrade_7.1_8.0.sh
expect "to contiune"
send "\r";
interact

View file

@ -1,16 +1,27 @@
# Detect the system architecture to download the right tarball
# NOTE: `uname -m` is more accurate and universal than `arch` # Check the architecture
# See https://en.wikipedia.org/wiki/Uname #
if [ -n "$(uname -m | grep 64)" ]; then # example: architecture=$(ynh_detect_arch)
architecture="x86-64" #
elif [ -n "$(uname -m | grep 86)" ]; then # usage: ynh_detect_arch
architecture="i386" #
elif [ -n "$(uname -m | grep arm)" ]; then # Requires YunoHost version 2.2.4 or higher.
architecture="arm"
else ynh_detect_arch(){
ynh_die --message "Unable to detect your achitecture, please open a bug describing \ local architecture
your hardware and the result of the command \"uname -m\"." 1 if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
fi architecture="arm64"
elif [ -n "$(uname -m | grep 64)" ]; then
architecture="x86-64"
elif [ -n "$(uname -m | grep 86)" ]; then
architecture="i386"
elif [ -n "$(uname -m | grep arm)" ]; then
architecture="arm"
else
architecture="unknown"
fi
echo $architecture
}
# Add swap # Add swap

View file

@ -4,21 +4,21 @@
# GENERIC START # GENERIC START
#================================================= #=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Stop script if errors # Stop script if errors
ynh_abort_if_errors ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
ynh_script_progression --message="Validating installation parameters..." ynh_script_progression --message="Validating installation parameters..."
# Retrieve arguments # Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_ARG_PATH) path_url=$YNH_APP_ARG_PATH
server_name="$YNH_APP_ARG_SERVER_NAME" server_name="$YNH_APP_ARG_SERVER_NAME"
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
@ -26,6 +26,8 @@ seafile_data=/home/yunohost.app/seafile-data
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
seafile_user=$app seafile_user=$app
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
seafile_version=$(ynh_app_upstream_version)
architecture=$(ynh_detect_arch)
# Create special path with / at the end # Create special path with / at the end
if [[ $path_url == '/' ]] if [[ $path_url == '/' ]]
@ -66,7 +68,6 @@ 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 fileserver_port --value $fileserver_port
ynh_app_setting_set --app $app --key webdav_port --value $webdav_port ynh_app_setting_set --app $app --key webdav_port --value $webdav_port
ynh_app_setting_set --app $app --key is_public --value $is_public ynh_app_setting_set --app $app --key is_public --value $is_public
ynh_app_setting_set --app $app --key installed_version --value $seafile_version
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -76,7 +77,8 @@ ynh_script_progression --message="Creating base directory..."
mkdir -p $final_path mkdir -p $final_path
mkdir -p $final_path/installed mkdir -p $final_path/installed
mkdir -p $final_path/logs mkdir -p $final_path/logs
mkdir -p $final_path/seafile-data mkdir -p $seafile_data
ln -s $seafile_data $final_path/seafile-data
# Create User # Create User
ynh_script_progression --message="Configuring system user..." ynh_script_progression --message="Configuring system user..."
@ -86,10 +88,6 @@ ynh_system_user_create --username $seafile_user --home_dir $final_path
ynh_script_progression --message="Installing dependencies..." --weight=7 ynh_script_progression --message="Installing dependencies..." --weight=7
install_dependance install_dependance
# Clean data directory
ynh_script_progression --message="Cleaning data directory..."
test -e $seafile_data && ynh_secure_remove --file="$seafile_data"
# Download new version from sources # Download new version from sources
ynh_script_progression --message="Installing sources files..." --weight=7 ynh_script_progression --message="Installing sources files..." --weight=7
install_source install_source
@ -104,9 +102,9 @@ ynh_mysql_setup_db --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd"
ynh_script_progression --message="Configuring application..." --weight=3 ynh_script_progression --message="Configuring application..." --weight=3
# Run install script # Run install script
chmod +x expect_scripts/install.exp mv_expect_scripts
chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
expect_scripts/install.exp "$final_path/seafile-server-$seafile_version" "$server_name" "$domain" "$seafile_data" "$fileserver_port" "$db_pwd" $expect_scripts_dir/install.exp "$final_path/seafile-server-$seafile_version" "$server_name" "$domain" "$fileserver_port" "$db_pwd"
sleep 3 sleep 3
@ -143,15 +141,33 @@ echo '[LDAP]' | tee -a $final_path/conf/ccnet.conf
echo 'HOST = ldap://localhost:389' | 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 '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 '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 # Enable manually wiki
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
# Enable memcached
cat >> $final_path/conf/seahub_settings.py <<EOF
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
},
}
EOF
# Configure admin info
# It will be used the first start
admin_email=$(ynh_user_get_info --username $admin --key 'mail')
cp ../conf/create_admin.json $final_path/conf/admin.txt
ynh_replace_string --match_string __ADMIN__ --replace_string $admin_email --target_file $final_path/conf/admin.txt
ynh_replace_special_string --match_string __PASSWORD__ --replace_string $admin_password --target_file $final_path/conf/admin.txt
# Fix local warning # Fix local warning
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh
# Update gunicorn config # Update gunicorn config
sed --in-place -r "s@bind = \"127\.0\.0\.1:[[:digit:]]+\"@bind = \"127.0.0.1:$seahub_port\"@g" $final_path/conf/gunicorn.conf sed --in-place -r "s@bind = \"127\.0\.0\.1:[[:digit:]]+\"@bind = \"127.0.0.1:$seahub_port\"@g" $final_path/conf/gunicorn.conf.py
# Add webdav # Add webdav
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
@ -166,27 +182,6 @@ ynh_add_systemd_config --service seahub --template seahub.service
ynh_script_progression --message="Configuring nginx..." --weight=1 ynh_script_progression --message="Configuring nginx..." --weight=1
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port' ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
# Copy first launch script
cp expect_scripts/first_launch.exp $final_path
chmod +x $final_path/first_launch.exp
# Set permissions to seafile directory
chown -R $seafile_user:$seafile_user $final_path
chown -R $seafile_user:$seafile_user $seafile_data
# Sometime we have a current effect. We try to lunch seafile when not all permissions are already set.
# So wait untils all permissions are cleanly set
sleep 5
ynh_debug_exec ls /opt/yunohost/seafile/ccnet
# Start seafile, seahub and populate admin account
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-$seafile_version/seafile.sh start"
# We escape all char witch needed.
ynh_replace_special_string --match_string __ADMIN_PASSWORD__ --replace_string "$admin_password" --target_file $final_path/first_launch.exp
admin_email=$(ynh_user_get_info --username $admin --key 'mail')
su - $seafile_user -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin_email"
ynh_secure_remove --file="$final_path/first_launch.exp"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -195,19 +190,19 @@ ynh_secure_remove --file="$final_path/first_launch.exp"
ynh_script_progression --message="Protecting directory..." ynh_script_progression --message="Protecting directory..."
set_permission set_permission
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav
ynh_script_progression --message="Configuring permissions..." ynh_script_progression --message="Configuring permissions..."
ynh_permission_create --permission=file_server --url=$domain/seafhttp --auth_header=false \
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav do in /etc/ssowat/conf.json.persistent --label="File server" --protected=true --allowed=visitors
python3 ../conf/add_sso_conf.py || ynh_die --message="Your file /etc/ssowat/conf.json.persistent doesn't respect the json syntax. Please fix the syntax to install this app." ynh_permission_create --permission=webdav --url=$domain/seafdav --auth_header=true \
--label="Webdav" --protected=true --allowed=visitors
# unprotect media # unprotect media
ynh_app_setting_set --app $app --key unprotected_uris --value "/media" ynh_permission_create --permission=media --url=/media --auth_header=true \
--label="Media" --protected=true --allowed=visitors
if [ "$is_public" = "0" ] if [ "$is_public" == '1' ];
then then
ynh_app_setting_delete --app seafile --key unprotected_uris ynh_permission_update --permission "main" --add "visitors"
else
ynh_app_setting_set --app $app --key unprotected_uris --value "/"
fi fi
# Add logrotate # Add logrotate
@ -215,29 +210,21 @@ ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile $final_path/logs ynh_use_logrotate --logfile $final_path/logs
ln -s $final_path/logs /var/log/seafile ln -s $final_path/logs /var/log/seafile
# Add fail2ban
ynh_script_progression --message="Configuring fail2ban..." --weight=10
ynh_add_fail2ban_config --use_template --others_var 'final_path'
# register yunohost service # register yunohost service
yunohost service add seafile yunohost service add seafile
yunohost service add seahub yunohost service add seahub
ynh_script_progression --message="Stoping services..." --weight=3 ynh_script_progression --message="Stoping services..." --weight=3
# Kill all services launched for initialisation
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seafile.sh stop"
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seahub.sh stop"
sleep 2
# We kill all process lunched by the script
pkill -f seafile-controller || true
pkill -f seaf-server || true
# Start service # Start service
ynh_script_progression --message="Starting seafile services..." --weight=3 ynh_script_progression --message="Starting seafile services..." --weight=3
ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log 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" ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd"
sleep 2 sleep 2
# Add fail2ban
ynh_script_progression --message="Configuring fail2ban..." --weight=10
ynh_add_fail2ban_config --use_template --others_var 'final_path'
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -4,13 +4,13 @@
# GENERIC START # GENERIC START
#================================================= #=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Import common cmd # Import common cmd
source ./experimental_helper.sh source ./experimental_helper.sh
source ./_common.sh source ./_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
# Retrieve arguments # Retrieve arguments
@ -32,10 +32,6 @@ pkill -f seaf-server || true
pkill -f ccnet-server || true pkill -f ccnet-server || true
pkill -f seahub || true pkill -f seahub || true
# remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent
ynh_script_progression --message="Cleaning SSO configuration..."
python3 ../conf/remove_sso_conf.py
ynh_script_progression --message="Removing logs..." ynh_script_progression --message="Removing logs..."
ynh_secure_remove --file=/var/log/seafile ynh_secure_remove --file=/var/log/seafile
ynh_script_progression --message="Removing code..." ynh_script_progression --message="Removing code..."

View file

@ -0,0 +1,39 @@
import json
import sys
with open("/etc/ssowat/" + "conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
for domain in ("", sys.argv[1]):
for path in ("/seafhttp", "/seafdav"):
url = domain + path
try:
uri_list = data["skipped_urls"]
while url in uri_list:
uri_list.remove(url)
except:
pass
try:
uri_list = data["protected_urls"]
while url in uri_list:
uri_list.remove(url)
except:
pass
try:
uri_list = data["permissions"]["custom_protected"]["uris"]
while url in uri_list:
uri_list.remove(url)
except:
pass
try:
uri_list = data["permissions"]["custom_skipped"]["uris"]
while url in uri_list:
uri_list.remove(url)
except:
pass
with open("/etc/ssowat/" + "conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -4,16 +4,16 @@
# GENERIC START # GENERIC START
#================================================= #=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Stop script if errors # Stop script if errors
ynh_abort_if_errors ynh_abort_if_errors
# Import common cmd
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading settings..."
# Retrieve arguments # Retrieve arguments
@ -22,7 +22,9 @@ path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --
seafile_data=/home/yunohost.app/seafile-data seafile_data=/home/yunohost.app/seafile-data
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd) db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
final_path=$(ynh_app_setting_get --app $app --key final_path) final_path=$(ynh_app_setting_get --app $app --key final_path)
seafile_version=$(ynh_app_upstream_version)
seafile_user=$app seafile_user=$app
architecture=$(ynh_detect_arch)
# Check domain/path availability # Check domain/path availability
ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path." ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path."
@ -57,10 +59,6 @@ su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# Restore sso persistent config
ynh_script_progression --message="Configuring permissions..."
python3 ../settings/conf/add_sso_conf.py || ynh_die --message="Your file /etc/ssowat/conf.json.persistent doesn't respect the json syntax. Please fix the syntax to install this app."
# Add logrotate # Add logrotate
ynh_script_progression --message="Configuring log rotation..." ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile $final_path/logs ynh_use_logrotate --logfile $final_path/logs
@ -73,8 +71,8 @@ set_permission
# Enable service and start seafile # Enable service and start seafile
ynh_script_progression --message="Reconfiguring application..." ynh_script_progression --message="Reconfiguring application..."
systemctl daemon-reload systemctl daemon-reload
systemctl enable seafile systemctl enable seafile --quiet
systemctl enable seahub systemctl enable seahub --quiet
# Add Seafile to YunoHost's monitored services # Add Seafile to YunoHost's monitored services
ynh_script_progression --message="Register seafile service..." ynh_script_progression --message="Register seafile service..."

View file

@ -4,27 +4,35 @@
# GENERIC START # GENERIC START
#================================================= #=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Stop script if errors # Stop script if errors
ynh_abort_if_errors ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
# Retrieve arguments # Retrieve arguments
domain=$(ynh_app_setting_get --app $app --key domain) domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path)) path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
installed_version=$(ynh_app_setting_get --app $app --key installed_version)
seahub_port=$(ynh_app_setting_get --app $app --key seahub_port) seahub_port=$(ynh_app_setting_get --app $app --key seahub_port)
fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port) fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port)
webdav_port=$(ynh_app_setting_get --app $app --key webdav_port) webdav_port=$(ynh_app_setting_get --app $app --key webdav_port)
final_path=$(ynh_app_setting_get --app $app --key final_path) final_path=$(ynh_app_setting_get --app $app --key final_path)
seafile_user=$app seafile_user=$app
seafile_data=/home/yunohost.app/seafile-data
installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/}
seafile_version=$(ynh_app_upstream_version)
architecture=$(ynh_detect_arch)
if [ "$YNH_APP_CURRENT_VERSION" == '-' ]; then
YNH_APP_CURRENT_VERSION="6.0.9~ynh0"
installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/}
fi
ynh_script_progression --message="Stoping services..." ynh_script_progression --message="Stoping services..."
@ -32,20 +40,33 @@ ynh_script_progression --message="Stoping services..."
if [ -e /etc/init.d/seafile-server ] if [ -e /etc/init.d/seafile-server ]
then then
# Old init script support # Old init script support
systemctl stop seafile-server systemctl stop seafile-server --quiet
systemctl disable seafile-server systemctl disable seafile-server --quiet
ynh_secure_remove --file=/etc/init.d/seafile-server ynh_secure_remove --file=/etc/init.d/seafile-server
yunohost service remove seafile-server yunohost service remove seafile-server
else else
ynh_systemd_action --service_name seafile --action stop ynh_systemd_action --service_name seafile --action stop
ynh_systemd_action --service_name seahub --action stop ynh_systemd_action --service_name seahub --action stop
fi fi
sleep 2 sleep 5
pkill -f seafile-controller || true pkill -f seafile-controller || true
pkill -f seaf-server || true pkill -f seaf-server || true
pkill -f ccnet-server || true pkill -f ccnet-server || true
pkill -f seahub || true pkill -f seahub || true
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30
# Backup the current version of the app
if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ] \
&& (ynh_compare_current_package_version --comparison=ge --version='7.0.5~ynh1')
then
ynh_backup_before_upgrade
ynh_clean_setup () {
# Clean installation remainings that are not handled by the remove script.
ynh_clean_check_starting
ynh_restore_upgradebackup
}
fi
#================================================= #=================================================
# MIGRATION FROM OLD VERSION # MIGRATION FROM OLD VERSION
#================================================= #=================================================
@ -93,10 +114,10 @@ install_dependance
ynh_script_progression --message="Configuring application..." ynh_script_progression --message="Configuring application..."
# permission to execute update script and expect helper # permission to execute update script and expect helper
chmod +x expect_scripts/upgrade_*.exp mv_expect_scripts
chmod +x expect_scripts/minor-upgrade.exp set_permission
chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh chmod u+x,o= $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh
chmod +x $final_path/seafile-server-$seafile_version/upgrade/minor-upgrade.sh chmod u+x,o= $final_path/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
# do the upgrade ( the ";&" syntax mean when it go in the first case which is true it do all the next case) # 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 case $installed_version in
@ -106,47 +127,55 @@ case $installed_version in
;& ;&
"4.1."* ) "4.1."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_4.2.1.exp $final_path/seafile-server-7.0.5
;& ;&
"4.3."* ) "4.3."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_4.4.3.exp $final_path/seafile-server-7.0.5
;& ;&
"4.4."* ) "4.4."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_5.0.3.exp $final_path/seafile-server-7.0.5
;& ;&
"5.0."* ) "5.0."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_5.1.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_5.1.exp $final_path/seafile-server-7.0.5
;& ;&
"5.1."* ) "5.1."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_6.0.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_6.0.exp $final_path/seafile-server-7.0.5
;& ;&
"6.0."* ) "6.0."* )
python3 ../conf/update_sso_conf.py || true install_source_7_0
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_6.1.exp $final_path/seafile-server-$seafile_version $expect_scripts_dir/upgrade_6.1.exp $final_path/seafile-server-7.0.5
# Enable manually wiki # Enable manually wiki
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
;& ;&
"6.1."* ) "6.1."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_6.2.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_6.2.exp $final_path/seafile-server-7.0.5
;& ;&
"6.2."* ) "6.2."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_6.3.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_6.3.exp $final_path/seafile-server-7.0.5
# Update logrotate to have the last version # Update logrotate to have the last version
ynh_use_logrotate --logfile $final_path/logs --nonappend ynh_use_logrotate --logfile $final_path/logs --nonappend
;& ;&
"6.3."* ) "6.3."* )
# Update seafile by script # Update seafile by script
expect_scripts/upgrade_7.0.exp $final_path/seafile-server-$seafile_version install_source_7_0
$expect_scripts_dir/upgrade_7.0.exp $final_path/seafile-server-7.0.5
# SSO authentication # SSO authentication
echo 'ENABLE_REMOTE_USER_AUTHENTICATION = True' | tee -a $final_path/conf/seahub_settings.py 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_HEADER = 'HTTP_EMAIL'" | tee -a $final_path/conf/seahub_settings.py
@ -158,9 +187,40 @@ case $installed_version in
ynh_print_warn --message "To be able to continue to use the SSO you probybly need to migrate your account. You can use the command 'yunohost app action run seafile migrate_user_email_to_mail_email' to migrate all of theses account. Note that after this migratation you need to reconfigure all your client with the official email of the user." ynh_print_warn --message "To be able to continue to use the SSO you probybly need to migrate your account. You can use the command 'yunohost app action run seafile migrate_user_email_to_mail_email' to migrate all of theses account. Note that after this migratation you need to reconfigure all your client with the official email of the user."
;& ;&
"7.0"* )
# Fix file comment
pushd $final_path/seafile-server-$seafile_version
sudo -u $seafile_user $final_path/seafile-server-$seafile_version/seahub.sh python-env python3 seahub/manage.py migrate_file_comment
popd
# Update seafile by script
sudo -u $seafile_user $expect_scripts_dir/upgrade_7.1.exp $final_path/seafile-server-$seafile_version
ynh_secure_remove --file="$final_path/seafile-server-7.0.5"
# Enable memcached
cat >> $final_path/conf/seahub_settings.py <<EOF
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
},
}
EOF
# Fix seafile data link. Look like that the upgrade script of seafile don't always work correctly
if [ -e $final_path/seafile-data ]; then
old_data_dir_path="$final_path/seafile_data$(date '+%Y%m%d.%H%M%S')"
mv "$final_path/seafile-data" "$old_data_dir_path"
fi
ln -s $seafile_data $final_path/seafile-data
;&
"7.1."* )
sudo -u $seafile_user $expect_scripts_dir/upgrade_8.0.exp $final_path/seafile-server-$seafile_version
echo "FILTER = permission=cn=$app.main,ou=permission,dc=yunohost,dc=org" | tee -a $final_path/conf/ccnet.conf
;&
esac esac
expect_scripts/minor-upgrade.exp $final_path/seafile-server-$seafile_version sudo -u $seafile_user $expect_scripts_dir/minor-upgrade.exp $final_path/seafile-server-$seafile_version
## Install webdav and logrotate if not installed ## Install webdav and logrotate if not installed
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]] if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
@ -179,9 +239,6 @@ then
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
ynh_replace_string --match_string __WEBDAV_PORT__ --replace_string $webdav_port --target_file $final_path/conf/seafdav.conf ynh_replace_string --match_string __WEBDAV_PORT__ --replace_string $webdav_port --target_file $final_path/conf/seafdav.conf
# Add sso config to unprotect domain.tld/seafdav in /etc/ssowat/conf.json.persistent
python3 ../conf/add_sso_conf_webdav.py
# Update seafile config # Update seafile config
echo 'COMPRESS_URL = MEDIA_URL' | 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 "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py
@ -202,7 +259,7 @@ fi
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh
# Update gunicorn config # Update gunicorn config
sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $final_path/conf/gunicorn.conf sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $final_path/conf/gunicorn.conf.py
# In the 3.x seafile version package the seahub_port and fileserver_port wasn't saved in the settings. If the settings is empty we try to get it and save in the settings # In the 3.x seafile version package the seahub_port and fileserver_port wasn't saved in the settings. If the settings is empty we try to get it and save in the settings
@ -243,6 +300,26 @@ ynh_use_logrotate --logfile $final_path/logs --nonappend
ynh_script_progression --message="Configuring fail2ban..." --weight=10 ynh_script_progression --message="Configuring fail2ban..." --weight=10
ynh_add_fail2ban_config --use_template --others_var 'final_path' ynh_add_fail2ban_config --use_template --others_var 'final_path'
ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_legacy_permissions_delete_all
if ! ynh_permission_exists --permission=file_server; then
ynh_permission_create --permission=file_server --url=$domain/seafhttp --auth_header=false \
--label="File server" --protected=true --allowed=visitors
ynh_permission_create --permission=webdav --url=$domain/seafdav --auth_header=true \
--label="Webdav" --protected=true --allowed=visitors
ynh_permission_create --permission=media --url=/media --auth_header=true \
--label="Media" --protected=true --allowed=visitors
python3 remove_sso_conf_persistent.py $domain \
|| ynh_print_warn --message="Your file /etc/ssowat/""conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually."
else
ynh_permission_url --permission=file_server --url=$domain/seafhttp --auth_header=false
ynh_permission_update --permission=file_server --label="File server" --show_tile=false --protected=true
ynh_permission_url --permission=webdav --url=$domain/seafdav --auth_header=false
ynh_permission_update --permission=webdav --label="Webdav" --show_tile=false --protected=true
ynh_permission_url --permission=media --url=/media --auth_header=true
ynh_permission_update --permission=media --label="Media" --show_tile=false --protected=true
fi
# register yunohost service # register yunohost service
ynh_script_progression --message="Register seafile service..." ynh_script_progression --message="Register seafile service..."
yunohost service add seafile yunohost service add seafile
@ -266,7 +343,4 @@ do
ynh_secure_remove --file=$final_path/$f ynh_secure_remove --file=$final_path/$f
done done
# store new installed version
ynh_app_setting_set --app $app --key installed_version --value $seafile_version
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of $app completed" --last