1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/droppy_ynh.git synced 2024-09-03 18:26:27 +02:00

Merge pull request #24 from YunoHost-Apps/testing

Fix #21
This commit is contained in:
yalh76 2022-06-08 01:33:12 +02:00 committed by GitHub
commit fe40bff63b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 131 additions and 119 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Droppy for YunoHost
[![Integration level](https://dash.yunohost.org/integration/droppy.svg)](https://dash.yunohost.org/appci/app/droppy) ![](https://ci-apps.yunohost.org/ci/badges/droppy.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/droppy.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/droppy.svg)](https://dash.yunohost.org/appci/app/droppy) ![Working status](https://ci-apps.yunohost.org/ci/badges/droppy.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/droppy.maintain.svg)
[![Install Droppy with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=droppy)
*[Lire ce readme en français.](./README_fr.md)*
@ -20,11 +20,9 @@ Droppy is a self-hosted file storage server with a web interface and capabilitie
**Shipped version:** 12.2.0~ynh10
## Screenshots
![](./doc/screenshots/screenshot.png)
![Screenshot of Droppy](./doc/screenshots/screenshot.png)
## Disclaimers / important information
@ -38,19 +36,20 @@ Shared files are stored in the following directory: `/home/yunohost.app/droppy/f
## Documentation and resources
* Upstream app code repository: https://github.com/silverwind/droppy
* YunoHost documentation for this app: https://yunohost.org/app_droppy
* Report a bug: https://github.com/YunoHost-Apps/droppy_ynh/issues
* Upstream app code repository: <https://github.com/silverwind/droppy>
* YunoHost documentation for this app: <https://yunohost.org/app_droppy>
* Report a bug: <https://github.com/YunoHost-Apps/droppy_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/droppy_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/droppy_ynh/tree/testing --debug
or
sudo yunohost app upgrade droppy -u https://github.com/YunoHost-Apps/droppy_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
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.
-->
# Droppy pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/droppy.svg)](https://dash.yunohost.org/appci/app/droppy) ![](https://ci-apps.yunohost.org/ci/badges/droppy.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/droppy.maintain.svg)
[![Niveau d'intégration](https://dash.yunohost.org/integration/droppy.svg)](https://dash.yunohost.org/appci/app/droppy) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/droppy.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/droppy.maintain.svg)
[![Installer Droppy avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=droppy)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Droppy rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@ -16,11 +20,9 @@ Droppy est un serveur de stockage de fichiers auto-hébergé avec une interface
**Version incluse :** 12.2.0~ynh10
## Captures d'écran
![](./doc/screenshots/screenshot.png)
![Capture d'écran de Droppy](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
@ -33,19 +35,20 @@ Les fichiers partagés sont stockés dans le répertoire suivant : `/home/yunoho
## Documentations et ressources
* Dépôt de code officiel de l'app : https://github.com/silverwind/droppy
* Documentation YunoHost pour cette app : https://yunohost.org/app_droppy
* Signaler un bug : https://github.com/YunoHost-Apps/droppy_ynh/issues
* Dépôt de code officiel de l'app : <https://github.com/silverwind/droppy>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_droppy>
* Signaler un bug : <https://github.com/YunoHost-Apps/droppy_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/droppy_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/droppy_ynh/tree/testing --debug
ou
sudo yunohost app upgrade droppy -u https://github.com/YunoHost-Apps/droppy_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -2,7 +2,6 @@
; Manifest
domain="domain.tld"
path="/path"
admin="john"
is_public=1
; Checks
pkg_linter=1
@ -13,8 +12,11 @@
setup_public=1
upgrade=1
#upgrade=1 from_commit=cf621e81a3df37b77cdc97a305e10dfb27631c6a
# 12.2.0~ynh10
upgrade=1 from_commit=88e894a01858a723ea62b154103867cafb49dfa8
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=

View file

@ -3,11 +3,12 @@ Description=Droppy: self-hosted file storage server
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
WorkingDirectory=__FINALPATH__/
Environment="NODE_ENV=production"
Environment="PATH=__ENV_PATH__"
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart= __FINALPATH__/droppy.js start -c __FINALPATH__/config -f /home/yunohost.app/__APP__/files
AmbientCapabilities=CAP_NET_BIND_SERVICE
Restart=always

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -14,7 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -41,18 +42,18 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_path" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================

View file

@ -31,17 +31,18 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before changing its URL (may take a while)..." --weight=1
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script

View file

@ -56,7 +56,7 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_script_progression --message="Finding an available port..." --weight=2
# Find an available port
port=$(ynh_find_port --port=8989)
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
@ -64,7 +64,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=2
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
@ -73,7 +72,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -82,7 +81,12 @@ ynh_script_progression --message="Setting up source files..." --weight=5
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path
ynh_setup_source --dest_dir="$final_path"
mkdir -p $final_path/config
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -94,57 +98,47 @@ ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#==============================================
# INSTALL DROPPY
#==============================================
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=26
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=26
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install
popd
#=================================================
# CREATE DIRECTORY FOR DATA AND CONFIG
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating the data directory..." --weight=1
ynh_script_progression --message="Creating a data directory..." --weight=1
# Define app's data directory
data_path=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
# Create datadir folder
mkdir -p $data_path
# Give permission to the datadir
chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:www-data "$data_path"
chown -R $app:$app "$data_path"
#=================================================
# SETUP SYSTEMD
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
env_path="$PATH"
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
# Create config folder
mkdir -p $final_path/config
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json"
chmod 600 "$final_path/config/config.json"
chown $app:$app "$final_path/config/config.json"
chmod 755 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app: "$final_path"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
@ -176,9 +170,11 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi

View file

@ -27,9 +27,10 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path)
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
@ -41,13 +42,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -66,6 +60,7 @@ then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$data_path"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -74,6 +69,13 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -22,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -36,14 +37,15 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -53,15 +55,32 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..." --weight=20
ynh_script_progression --message="Restoring the app main directory..." --weight=20
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_path" --not_mandatory
mkdir -p $data_path
chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:$app "$data_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
@ -80,23 +99,6 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_path" --not_mandatory
mkdir -p $data_path
chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:www-data "$data_path"
chmod 755 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app: "$final_path"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================

View file

@ -20,27 +20,39 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=2
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=9
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -53,22 +65,17 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=9
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
if [ -z "$data_path" ]; then
data_path=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -79,9 +86,13 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=10
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path --keep="$final_path/config/config.json"
ynh_setup_source --dest_dir=$final_path --keep="config/config.json"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -95,35 +106,29 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=2
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# SPECIFIC UPGRADE
#==============================================
# INSTALL DROPPY
# BUILD APP
#==============================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=25
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=25
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install
popd
fi
chmod 755 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app: "$final_path"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
env_path="$PATH"
# Create a dedicated systemd config
ynh_add_systemd_config