Merge pull request #121 from YunoHost-Apps/improve_data_dir_struct

Improve data dir struct
This commit is contained in:
Josue-T 2024-04-29 17:40:29 +02:00 committed by GitHub
commit 7a4d00ad98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 365 additions and 132 deletions

4
.gitignore vendored
View file

@ -129,10 +129,6 @@ publish/
*.pubxml
*.publishproj
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef

7
ALL_README.md Normal file
View file

@ -0,0 +1,7 @@
# All available README files by language
- [Read the README in English](README.md)
- [Irakurri README euskaraz](README_eu.md)
- [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md)
- [阅读中文(简体)的 README](README_zh_Hans.md)

View file

@ -1,5 +1,5 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
N.B.: This README was automatically generated by <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
It shall NOT be edited by hand.
-->
@ -9,10 +9,10 @@ It shall NOT be edited by hand.
[![Install Seafile with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=seafile)
*[Lire ce readme en français.](./README_fr.md)*
*[Read this README in other languages.](./ALL_README.md)*
> *This package allows you to install Seafile quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
> *This package allows you to install Seafile quickly and simply on a YunoHost server.*
> *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.*
## Overview
@ -21,9 +21,9 @@ 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.9~ynh2
**Shipped version:** 9.0.9~ynh3
**Demo:** https://demo.seafile.com
**Demo:** <https://demo.seafile.com>
## Screenshots
@ -38,19 +38,19 @@ It's a Enterprise file sync and share platform with high reliability and perform
## Documentation and resources
* Official app website: <https://www.seafile.com>
* Official admin documentation: <https://manual.seafile.com>
* Upstream app code repository: <https://github.com/haiwen/seafile-server>
* YunoHost Store: <https://apps.yunohost.org/app/seafile>
* Report a bug: <https://github.com/YunoHost-Apps/seafile_ynh/issues>
- Official app website: <https://www.seafile.com>
- Official admin documentation: <https://manual.seafile.com>
- Upstream app code repository: <https://github.com/haiwen/seafile-server>
- YunoHost Store: <https://apps.yunohost.org/app/seafile>
- Report a bug: <https://github.com/YunoHost-Apps/seafile_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing).
Please send 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.
To try the `testing` branch, please proceed like that:
``` bash
```bash
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

59
README_eu.md Normal file
View file

@ -0,0 +1,59 @@
<!--
Ohart ongi: README hau automatikoki sortu da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>ri esker
EZ editatu eskuz.
-->
# Seafile YunoHost-erako
[![Integrazio maila](https://dash.yunohost.org/integration/seafile.svg)](https://dash.yunohost.org/appci/app/seafile) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/seafile.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/seafile.maintain.svg)
[![Instalatu Seafile YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=seafile)
*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)*
> *Pakete honek Seafile YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.*
> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.*
## Aurreikuspena
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.
**Paketatutako bertsioa:** 9.0.9~ynh3
**Demoa:** <https://demo.seafile.com>
## Pantaila-argazkiak
![Seafile(r)en pantaila-argazkia](./doc/screenshots/mobile-ios-client.jpg)
![Seafile(r)en pantaila-argazkia](./doc/screenshots/drive-client.png)
![Seafile(r)en pantaila-argazkia](./doc/screenshots/file-locking.jpg)
![Seafile(r)en pantaila-argazkia](./doc/screenshots/access-logs.jpg)
![Seafile(r)en pantaila-argazkia](./doc/screenshots/file-history.png)
![Seafile(r)en pantaila-argazkia](./doc/screenshots/wiki_en.png)
![Seafile(r)en pantaila-argazkia](./doc/screenshots/sharing-dialog.png)
![Seafile(r)en pantaila-argazkia](./doc/screenshots/sync-client.jpg)
## Dokumentazioa eta baliabideak
- Aplikazioaren webgune ofiziala: <https://www.seafile.com>
- Administratzaileen dokumentazio ofiziala: <https://manual.seafile.com>
- Jatorrizko aplikazioaren kode-gordailua: <https://github.com/haiwen/seafile-server>
- YunoHost Denda: <https://apps.yunohost.org/app/seafile>
- Eman errore baten berri: <https://github.com/YunoHost-Apps/seafile_ynh/issues>
## Garatzaileentzako informazioa
Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing).
`testing` abarra probatzeko, ondorengoa egin:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
edo
sudo yunohost app upgrade seafile -u https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
```
**Informazio gehiago aplikazioaren paketatzeari buruz:** <https://yunohost.org/packaging_apps>

View file

@ -1,6 +1,6 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
Nota bene: ce README est automatiquement généré par <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
Il NE doit PAS être modifié à la main.
-->
# Seafile pour YunoHost
@ -9,10 +9,10 @@ It shall NOT be edited by hand.
[![Installer Seafile avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=seafile)
*[Read this readme in english.](./README.md)*
*[Lire le README dans d'autres langues.](./ALL_README.md)*
> *Ce package vous permet dinstaller Seafile rapidement et simplement sur un serveur YunoHost.
Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
> *Ce package vous permet dinstaller Seafile rapidement et simplement sur un serveur YunoHost.*
> *Si vous navez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment linstaller et en profiter.*
## Vue densemble
@ -21,9 +21,9 @@ 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.9~ynh2
**Version incluse:** 9.0.9~ynh3
**Démo :** https://demo.seafile.com
**Démo:** <https://demo.seafile.com>
## Captures décran
@ -38,22 +38,22 @@ It's a Enterprise file sync and share platform with high reliability and perform
## Documentations et ressources
* Site officiel de lapp : <https://www.seafile.com>
* Documentation officielle de ladmin : <https://manual.seafile.com>
* Dépôt de code officiel de lapp : <https://github.com/haiwen/seafile-server>
* YunoHost Store: <https://apps.yunohost.org/app/seafile>
* Signaler un bug : <https://github.com/YunoHost-Apps/seafile_ynh/issues>
- Site officiel de lapp: <https://www.seafile.com>
- Documentation officielle de ladmin: <https://manual.seafile.com>
- Dépôt de code officiel de lapp: <https://github.com/haiwen/seafile-server>
- YunoHost Store: <https://apps.yunohost.org/app/seafile>
- Signaler un bug: <https://github.com/YunoHost-Apps/seafile_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing).
Merci de faire vos pull request sur la [branche `testing`](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
Pour essayer la branche `testing`, procédez comme suit:
``` bash
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
ou
sudo yunohost app upgrade seafile -u https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
```
**Plus dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>
**Plus dinfos sur le packaging dapplications:** <https://yunohost.org/packaging_apps>

59
README_gl.md Normal file
View file

@ -0,0 +1,59 @@
<!--
NOTA: Este README foi creado automáticamente por <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
NON debe editarse manualmente.
-->
# Seafile para YunoHost
[![Nivel de integración](https://dash.yunohost.org/integration/seafile.svg)](https://dash.yunohost.org/appci/app/seafile) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/seafile.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/seafile.maintain.svg)
[![Instalar Seafile con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=seafile)
*[Le este README en outros idiomas.](./ALL_README.md)*
> *Este paquete permíteche instalar Seafile de xeito rápido e doado nun servidor YunoHost.*
> *Se non usas YunoHost, le a [documentación](https://yunohost.org/install) para saber como instalalo.*
## Vista xeral
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.
**Versión proporcionada:** 9.0.9~ynh3
**Demo:** <https://demo.seafile.com>
## Capturas de pantalla
![Captura de pantalla de Seafile](./doc/screenshots/mobile-ios-client.jpg)
![Captura de pantalla de Seafile](./doc/screenshots/drive-client.png)
![Captura de pantalla de Seafile](./doc/screenshots/file-locking.jpg)
![Captura de pantalla de Seafile](./doc/screenshots/access-logs.jpg)
![Captura de pantalla de Seafile](./doc/screenshots/file-history.png)
![Captura de pantalla de Seafile](./doc/screenshots/wiki_en.png)
![Captura de pantalla de Seafile](./doc/screenshots/sharing-dialog.png)
![Captura de pantalla de Seafile](./doc/screenshots/sync-client.jpg)
## Documentación e recursos
- Web oficial da app: <https://www.seafile.com>
- Documentación oficial para admin: <https://manual.seafile.com>
- Repositorio de orixe do código: <https://github.com/haiwen/seafile-server>
- Tenda YunoHost: <https://apps.yunohost.org/app/seafile>
- Informar dun problema: <https://github.com/YunoHost-Apps/seafile_ynh/issues>
## Info de desenvolvemento
Envía a túa colaboración á [rama `testing`](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing).
Para probar a rama `testing`, procede deste xeito:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
ou
sudo yunohost app upgrade seafile -u https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
```
**Máis info sobre o empaquetado da app:** <https://yunohost.org/packaging_apps>

59
README_zh_Hans.md Normal file
View file

@ -0,0 +1,59 @@
<!--
注意:此 README 由 <https://github.com/YunoHost/apps/tree/master/tools/readme_generator> 自动生成
请勿手动编辑。
-->
# YunoHost 的 Seafile
[![集成程度](https://dash.yunohost.org/integration/seafile.svg)](https://dash.yunohost.org/appci/app/seafile) ![工作状态](https://ci-apps.yunohost.org/ci/badges/seafile.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/seafile.maintain.svg)
[![使用 YunoHost 安装 Seafile](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=seafile)
*[阅读此 README 的其它语言版本。](./ALL_README.md)*
> *通过此软件包,您可以在 YunoHost 服务器上快速、简单地安装 Seafile。*
> *如果您还没有 YunoHost请参阅[指南](https://yunohost.org/install)了解如何安装它。*
## 概况
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.
**分发版本:** 9.0.9~ynh3
**演示:** <https://demo.seafile.com>
## 截图
![Seafile 的截图](./doc/screenshots/mobile-ios-client.jpg)
![Seafile 的截图](./doc/screenshots/drive-client.png)
![Seafile 的截图](./doc/screenshots/file-locking.jpg)
![Seafile 的截图](./doc/screenshots/access-logs.jpg)
![Seafile 的截图](./doc/screenshots/file-history.png)
![Seafile 的截图](./doc/screenshots/wiki_en.png)
![Seafile 的截图](./doc/screenshots/sharing-dialog.png)
![Seafile 的截图](./doc/screenshots/sync-client.jpg)
## 文档与资源
- 官方应用网站: <https://www.seafile.com>
- 官方管理文档: <https://manual.seafile.com>
- 上游应用代码库: <https://github.com/haiwen/seafile-server>
- YunoHost 商店: <https://apps.yunohost.org/app/seafile>
- 报告 bug <https://github.com/YunoHost-Apps/seafile_ynh/issues>
## 开发者信息
请向 [`testing` 分支](https://github.com/YunoHost-Apps/seafile_ynh/tree/testing) 发送拉取请求。
如要尝试 `testing` 分支,请这样操作:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
sudo yunohost app upgrade seafile -u https://github.com/YunoHost-Apps/seafile_ynh/tree/testing --debug
```
**有关应用打包的更多信息:** <https://yunohost.org/packaging_apps>

View file

@ -1,5 +1,4 @@
location __PATH__ {
proxy_redirect http:// https://;
proxy_pass http://127.0.0.1:__PORT_SEAHUB__;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

View file

@ -5,7 +5,7 @@ name = "Seafile"
description.en = "Open Source Cloud Storage"
description.fr = "Stockage Cloud Open Source"
version = "9.0.9~ynh2"
version = "9.0.9~ynh3"
maintainers = ["Josué Tille"]

View file

@ -5,10 +5,26 @@
time_zone=$(cat /etc/timezone)
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
# Create special path with / at the end
if [[ $path == '/' ]]
then
path2="$path"
else
path2="$path/"
fi
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
install_pkg_conf() {
# Install manually pkgconf
# WARNING don't move this to dependencies
# We install this manually because we have an issue between pkgconf and pkg-config.
# If pkg-config is already installed on the system we can't declare pkgconf as dependency as pkg-config need to be removed to install pkgconf (note that pkgconf replace pkg-config and both can't be installed)
ynh_apt install pkgconf
}
install_dependance() {
ynh_add_swap --size=2000
@ -59,19 +75,20 @@ install_dependance() {
}
set_permission() {
chown -R $YNH_APP_ID:$YNH_APP_ID $install_dir
chown -R $app:$app $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 $install_dir/seafile-server-$seafile_version/seahub && setfacl -m user:www-data:rX $install_dir/seafile-server-$seafile_version/seahub
test -e $install_dir/seafile-server-$seafile_version/seahub/media && setfacl -R -m user:www-data:rX $install_dir/seafile-server-$seafile_version/seahub/media
test -e $install_dir/seahub-data && setfacl -R -m user:www-data:rX $install_dir/seahub-data
test -e $install_dir/seahub-data && setfacl -m user:www-data:rX $data_dir
test -e $install_dir/seahub-data && setfacl -R -m user:www-data:rX $data_dir/seahub-data
find $data_dir \( \! -perm -o= \
-o \! -user $YNH_APP_ID \
-o \! -group $YNH_APP_ID \) \
-exec chown $YNH_APP_ID:$YNH_APP_ID {} \; \
-o \! -user $app \
-o \! -group $app \) \
-exec chown $app:$app {} \; \
-exec chmod o= {} \;
}

View file

@ -11,10 +11,9 @@ source ../settings/scripts/_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# retrieve useful param
seafile_version=$(ynh_app_upstream_version)
if [[ ! "$(systemctl status seafile)" =~ "Active: inactive (dead)" ]] || [[ ! "$(systemctl status seahub)" =~ "Active: failed (Result: signal)" ]]; then
if systemctl is-active seafile --quiet || systemctl is-active seahub --quiet; 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'"
fi
@ -24,20 +23,23 @@ fi
# # Backup app files
ynh_print_info --message="Backing up code..."
ynh_backup --src_path $install_dir
ynh_backup --src_path "$install_dir"
ynh_print_info --message="Backing up user data..."
ynh_backup --src_path=$data_dir --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/nginx/conf.d/$domain.d/${app}.conf"
ynh_backup --src_path /etc/systemd/system/seafile.service
ynh_backup --src_path /etc/systemd/system/seahub.service
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/jail.d/"$app".conf
ynh_backup --src_path /etc/fail2ban/filter.d/"$app".conf
# Backup logs
ynh_backup --src_path="/var/log/$app"
# 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 seahubdb > ${YNH_CWD}/seahubdb.dmp
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 seahubdb > "${YNH_CWD}"/seahubdb.dmp
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -11,6 +11,8 @@ source ./_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
seafile_version=$(ynh_app_upstream_version)
# Create special path with / at the end
if [[ $path == '/' ]]
then

View file

@ -13,29 +13,24 @@ source /usr/share/yunohost/helpers
seafile_version=$(ynh_app_upstream_version)
# Create special path with / at the end
if [[ $path == '/' ]]
then
path2=$path
else
path2=$path"/"
fi
install_pkg_conf
#=================================================
# STANDARD MODIFICATIONS
#=================================================
ynh_script_progression --message="Creating base directory..."
ln -s $data_dir $install_dir/seafile-data
mkdir -p $install_dir/logs
if [ -n "$(ls -A $data_dir)" ]; then
if [ -n "$(ls -A "$data_dir")" ]; then
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path"
mkdir -p $old_data_dir_path
mkdir -p "$old_data_dir_path"
mv -t "$old_data_dir_path" "$data_dir"/*
fi
mkdir -p /var/log/"$app"
mkdir -p "$data_dir"/{seafile-data,seahub-data}
# Download new version from sources
ynh_script_progression --message="Installing sources files..." --weight=7
ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version
@ -46,9 +41,8 @@ install_dependance
# init databases
ynh_script_progression --message="Configuring MySQL database..."
db_user=seafile
db_helper=ynh_"mysql"_setup_db
$db_helper --db_user $db_user --db_name ccnetdb --db_pwd "$db_pwd"
$db_helper --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd"
ynh_''mysql_setup_db --db_user "$db_user" --db_name ccnetdb --db_pwd "$db_pwd"
ynh_''mysql_setup_db --db_user "$db_user" --db_name seahubdb --db_pwd "$db_pwd"
ynh_script_progression --message="Configuring application..." --weight=3
@ -56,23 +50,23 @@ ynh_script_progression --message="Configuring application..." --weight=3
set_permission
ynh_replace_special_string --match_string 'seafile_config.seafile_dir = seafile_config.validate_seafile_dir(seafile_dir)' \
--replace_string 'seafile_config.seafile_dir = seafile_dir' \
--target_file $install_dir/seafile-server-$seafile_version/setup-seafile-mysql.py
sudo -u $YNH_APP_ID bash $install_dir/seafile-server-$seafile_version/setup-seafile-mysql.sh auto \
--target_file "$install_dir/seafile-server-$seafile_version/setup-seafile-mysql.py"
sudo -u "$app" bash "$install_dir/seafile-server-$seafile_version/setup-seafile-mysql.sh" auto \
--server-name "$server_name" \
--server-ip $domain \
--fileserver-port $port_fileserver \
--server-ip "$domain" \
--fileserver-port "$port_fileserver" \
--use-existing-db 1 \
--mysql-host localhost \
--mysql-port 3306 \
--mysql-user $db_user \
--mysql-user "$db_user" \
--mysql-user-passwd "$db_pwd" \
--seafile-db "$db_name" \
--ccnet-db ccnetdb \
--seahub-db seahubdb
# 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
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"
# Update seafile config files
ynh_add_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py
@ -83,10 +77,27 @@ ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.c
# Configure admin info
# It will be used the first start
admin_email=$(ynh_user_get_info --username $admin --key 'mail')
admin_email=$(ynh_user_get_info --username "$admin" --key 'mail')
cp ../conf/create_admin.json $install_dir/conf/admin.txt
ynh_replace_string --match_string __ADMIN__ --replace_string $admin_email --target_file $install_dir/conf/admin.txt
ynh_replace_special_string --match_string __PASSWORD__ --replace_string $admin_password --target_file $install_dir/conf/admin.txt
ynh_replace_string --match_string __ADMIN__ --replace_string "$admin_email" --target_file $install_dir/conf/admin.txt
ynh_replace_special_string --match_string __PASSWORD__ --replace_string "$admin_password" --target_file $install_dir/conf/admin.txt
# Use symlink to store data
if [ -e "$install_dir"/seafile-data ]; then
mv -t "$data_dir"/seafile-data "$install_dir"/seafile-data/*
ynh_secure_remove --file="$install_dir"/seafile-data
fi
if [ -e "$install_dir"/seahub-data ]; then
mv -t "$data_dir"/seahub-data "$install_dir"/seahub-data/*
ynh_secure_remove --file="$install_dir"/seahub-data
fi
if [ -e "$install_dir"/logs ]; then
mv -t /var/log/"$app" "$install_dir"/logs/*
ynh_secure_remove --file="$install_dir"/logs
fi
ln -s "$data_dir"/seafile-data "$install_dir"/seafile-data
ln -s "$data_dir"/seahub-data "$install_dir"/seahub-data
ln -s /var/log/"$app" "$install_dir"/logs
# Fix local warning
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $install_dir/seafile-server-$seafile_version/seahub.sh
@ -97,8 +108,8 @@ ynh_add_systemd_config --service seafile --template seafile.service
ynh_add_systemd_config --service seahub --template seahub.service
# register yunohost service
yunohost service add seafile
yunohost service add seahub
yunohost service add seafile --description 'Main service for seafile server.'
yunohost service add seahub --description 'Seafile server web interface.'
# Config nginx
ynh_script_progression --message="Configuring nginx..."
@ -106,8 +117,7 @@ ynh_add_nginx_config
# Add logrotate
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile $install_dir/logs
ln -s $install_dir/logs /var/log/seafile
ynh_use_logrotate --logfile=/var/log/"$app"
# Add fail2ban
ynh_script_progression --message="Configuring fail2ban..."

View file

@ -11,6 +11,8 @@ source ./_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
seafile_version=$(ynh_app_upstream_version)
#=================================================
# STANDARD REMOVE
#=================================================
@ -27,8 +29,10 @@ pkill -f seaf-server || true
pkill -f ccnet-server || true
pkill -f seahub || true
ynh_script_progression --message="Removing logs..."
ynh_secure_remove --file=/var/log/seafile
if [ "$YNH_APP_PURGE" -eq 1 ]; then
ynh_script_progression --message="Removing logs..."
ynh_secure_remove --file=/var/log/"$app"
fi
ynh_script_progression --message="Removing code..."
ynh_secure_remove --file=/var/www/$app
ynh_secure_remove --file=/opt/yunohost/$app

View file

@ -11,6 +11,8 @@ source ../settings/scripts/_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
seafile_version=$(ynh_app_upstream_version)
ynh_script_progression --message="Loading settings..."
# Retrieve arguments
@ -27,8 +29,8 @@ ynh_restore
# Restore mysql dump
ynh_script_progression --message="Restoring database..." --weight=3
db_helper=ynh_"mysql"_setup_db
$db_helper --db_user $db_user --db_name ccnetdb --db_pwd "$db_pwd"
$db_helper --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd"
$db_helper --db_user "$db_user" --db_name ccnetdb --db_pwd "$db_pwd"
$db_helper --db_user "$db_user" --db_name seahubdb --db_pwd "$db_pwd"
su -c "mysql -u ${app} -p$db_pwd $db_name < ${YNH_CWD}/seafiledb.dmp"
su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${YNH_CWD}/ccnetdb.dmp"
su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
@ -39,8 +41,8 @@ su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
# Add logrotate
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile $install_dir/logs
ln -s $install_dir/logs /var/log/seafile
mkdir -p /var/log/"$app"
ynh_use_logrotate --logfile "$install_dir"/logs
# Set all permissions
ynh_script_progression --message="Protecting directory..."
@ -54,8 +56,8 @@ systemctl enable seahub --quiet
# Add Seafile to YunoHost's monitored services
ynh_script_progression --message="Register seafile service..."
yunohost service add seafile
yunohost service add seahub
yunohost service add seafile --description 'Main service for seafile server.'
yunohost service add seahub --description 'Seafile server web interface.'
ynh_script_progression --message="Reloading services..."

View file

@ -11,36 +11,21 @@ source ./_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve arguments
installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/}
seafile_version=$(ynh_app_upstream_version)
# Create special path with / at the end
if [[ $path == '/' ]]
then
path2=$path
else
path2=$path"/"
fi
# Retrieve arguments
installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/}
if [ "$YNH_APP_CURRENT_VERSION" == '-' ]; then
if [ "$YNH_APP_CURRENT_VERSION" == '-' ] || ynh_compare_current_package_version --comparison=le --version='7.0~ynh1'; then
ynh_die "Upgrade from this version not supported"
fi
install_pkg_conf
ynh_script_progression --message="Stoping services..."
# stop seafile server
if [ -e /etc/init.d/seafile-server ]
then
# Old init script support
systemctl stop seafile-server --quiet
systemctl disable seafile-server --quiet
ynh_secure_remove --file=/etc/init.d/seafile-server
yunohost service remove seafile-server
else
ynh_systemd_action --service_name seafile --action stop
ynh_systemd_action --service_name seahub --action stop
fi
ynh_systemd_action --service_name seafile --action stop
ynh_systemd_action --service_name seahub --action stop
sleep 5
pkill -f seafile-controller || true
pkill -f seaf-server || true
@ -56,34 +41,66 @@ if mysqlshow | grep -q seafiledb; then
$mysqlconn -e "RENAME TABLE seafiledb.$name to $db_name.$name";
done;
$mysqlconn -e "DROP DATABASE seafiledb"
ynh_replace_string --match_string='db_name = seafiledb' --replace_string='db_name = seafile' --target_file=$install_dir/conf/seafile.conf
sed -i "s|password\s*=\s*.*^|password = $db_pwd|g" $install_dir/conf/seafile.conf
ynh_replace_string --match_string='db_name = seafiledb' --replace_string='db_name = seafile' --target_file="$install_dir"/conf/seafile.conf
sed -i "s|password\s*=\s*.*^|password = $db_pwd|g" "$install_dir"/conf/seafile.conf
fi
# Set missing settings
if [ -z ${seahub_secret_key:-} ]; then
seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*".+"' $install_dir/conf/seahub_settings.py | cut -d'"' -f2)
ynh_app_setting_set --app $app --key seahub_secret_key --value $seahub_secret_key
if [ -z "${seahub_secret_key:-}" ]; then
seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2)
ynh_app_setting_set --app "$app" --key seahub_secret_key --value "$seahub_secret_key"
fi
#
# Update data dir if needed
#
# Create link to /home/yunohost.app/seafile/seafile-data in case of old install with data dir defined in config instead of symlink
# Also update link if not pointing to correct path
if [ ! -L /home/yunohost.app/seafile-data ] || \
[ $(readlink $install_dir/seafile-data) = '/home/yunohost.app/seafile-data' ]; then
mv $install_dir/seafile-data $install_dir/seafile-data$(date '+%Y%m%d.%H%M%S')
ln -s $data_dir $install_dir/seafile-data
[ "$(readlink "$install_dir"/seafile-data)" != "$data_dir/seafile-data" ]; then
mv "$install_dir"/seafile-data "$install_dir/seafile-data_$(date '+%Y%m%d.%H%M%S')"
ln -s "$data_dir"/seafile-data "$install_dir"/seafile-data
fi
# Move if needed old /home/yunohost.app/seafile-data dir to /home/yunohost.app/seafile/seafile-data
if [ -e /home/yunohost.app/seafile-data ]; then
if [ -e $data_dir ]; then
mv $data_dir $data_dir$(date '+%Y%m%d.%H%M%S')
if [ -e "$data_dir" ]; then
mv "$data_dir" "${data_dir}_$(date '+%Y%m%d.%H%M%S')"
fi
mv /home/yunohost.app/seafile-data $data_dir
mkdir -p "$data_dir"
mv /home/yunohost.app/seafile-data "$data_dir"/
fi
# In case of seafile-data content was directly stored in /home/yunohost.app/seafile
if [ -e "$data_dir"/storage ]; then
mkdir -p "$data_dir"/seafile-data
mv -t "$data_dir"/seafile-data "$data_dir"/{commits,fs,httptemp,library-template,storage,tmpfiles,webdavtmp} || true # In case of some of dir don't exist
fi
# Move seahub data to /home/yunohost.app/seafile/seahub-data
if [ ! -L "$install_dir"/seahub-data ]; then
if [ -e "$data_dir"/seahub-data ]; then
mv "$data_dir"/seahub-data "$data_dir/seahub-data_$(date '+%Y%m%d.%H%M%S')"
fi
mv "$install_dir"/seahub-data "$data_dir"/
ln -s "$data_dir"/seahub-data "$install_dir"/seahub-data
fi
# Move logs storage to /var/log/seafile
if [ ! -L "$install_dir"/logs ]; then
if [ -e /var/log/"$app" ]; then
mv /var/log/"$app" /var/log/"${app}_$(date '+%Y%m%d.%H%M%S')"
fi
mv "$install_dir"/logs /var/log/"${app}"
ln -s /var/log/"${app}" "$install_dir"/logs
fi
ynh_script_progression --message="Upgrading source files..." --weight=6
# Download new version from sources
ynh_script_progression --message="Installing sources files..." --weight=7
ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version
ynh_setup_source --dest_dir="$install_dir"/seafile-server-$seafile_version
ynh_script_progression --message="Installing python dependancies..."
install_dependance
@ -109,12 +126,12 @@ case $installed_version in
"7.0"* )
# Fix file comment
pushd $install_dir/seafile-server-$seafile_version
sudo -u $YNH_APP_ID $install_dir/seafile-server-$seafile_version/seahub.sh python-env python3 seahub/manage.py migrate_file_comment
sudo -u $app $install_dir/seafile-server-$seafile_version/seahub.sh python-env python3 seahub/manage.py migrate_file_comment
popd
# Update seafile by script
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file=$install_dir/seafile-server-$seafile_version/upgrade/upgrade_7.0_7.1.sh
sudo -u $YNH_APP_ID bash $install_dir/seafile-server-$seafile_version/upgrade/upgrade_7.0_7.1.sh
sudo -u $app bash $install_dir/seafile-server-$seafile_version/upgrade/upgrade_7.0_7.1.sh
# Fix seafile data link. Look like that the upgrade script of seafile don't always work correctly
if [ -e $install_dir/seafile-data ]; then
@ -125,16 +142,16 @@ case $installed_version in
;&
"7.1."* )
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file=$install_dir/seafile-server-$seafile_version/upgrade/upgrade_8.0_9.0.sh
sudo -u $YNH_APP_ID bash $install_dir/seafile-server-$seafile_version/upgrade/upgrade_8.0_9.0.sh
sudo -u $app bash $install_dir/seafile-server-$seafile_version/upgrade/upgrade_8.0_9.0.sh
;&
"8.0."* )
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file=$install_dir/seafile-server-$seafile_version/upgrade/upgrade_7.1_8.0.sh
sudo -u $YNH_APP_ID bash $install_dir/seafile-server-$seafile_version/upgrade/upgrade_7.1_8.0.sh
sudo -u $app bash $install_dir/seafile-server-$seafile_version/upgrade/upgrade_7.1_8.0.sh
;&
esac
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file=$install_dir/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
sudo -u $YNH_APP_ID bash $install_dir/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
sudo -u $app bash $install_dir/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
# Clean url in config in DB
clean_url_in_db_config
@ -171,7 +188,7 @@ set_permission
# Add logrotate
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile $install_dir/logs --nonappend
ynh_use_logrotate --logfile=/var/log/"$app" --nonappend
# Add fail2ban
ynh_script_progression --message="Configuring fail2ban..." --weight=10
@ -179,8 +196,8 @@ ynh_add_fail2ban_config --use_template
# register yunohost service
ynh_script_progression --message="Register seafile service..."
yunohost service add seafile
yunohost service add seahub
yunohost service add seafile --description 'Main service for seafile server.'
yunohost service add seahub --description 'Seafile server web interface.'
# delete seafile cache

View file

@ -20,6 +20,6 @@ test_format = 1.0
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.b5fd940.name = "Pre packaging v2"
test_upgrade_from.3ce35d3.name = "Version 7.1 Old version for CI 4 branch"
test_upgrade_from.97c0b2f.name = "Version 8.x Old version for CI 5 branch"
test_upgrade_from.ef7eb6f.name = "Pre packaging v2 (Old_version_for_CI_6 branch)"
test_upgrade_from.8d41482.name = "Version 7.1 (Old_version_for_CI_4 branch)"
test_upgrade_from.c11c24b.name = "Version 8.x (Old_version_for_CI_5 branch)"