1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lychee_ynh.git synced 2024-09-03 19:36:36 +02:00
* #39

* Update upgrade

* Update manifest.json

* Auto-update README

* Update _common.sh

* Update _common.sh

* Cleaning up

* Fix

* Create DESCRIPTION.md

* Auto-update README

* Create updater.sh

* Update updater.sh

* Create updater.yml (#42)

* Update upgrade

* Update upgrade

* Auto-update README

* Update upgrade

* Update upgrade

* Apply example_ynh (#43)

* Auto-update README

* Apply example_ynh

* Auto-update README

* fix missing datadir

* Fix missing phpversion

* Update upgrade

* Update check_process

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Auto-update README

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: yalh76 <yalh@yahoo.com>
This commit is contained in:
Éric Gaspar 2022-08-09 10:57:57 +02:00 committed by GitHub
parent a87e16f7ca
commit f1a571b9e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 385 additions and 192 deletions

137
.github/workflows/updater.sh vendored Executable file
View file

@ -0,0 +1,137 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
# Remove this exit command when you are ready to run this Action
#exit 1
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"Lychee.zip")
src="app"
;;
*"update"*)
src="app-upgrade"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
EOT
echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

50
.github/workflows/updater.yml vendored Normal file
View file

@ -0,0 +1,50 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 6:00 UTC
schedule:
- cron: '0 6 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to v$VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
base: testing
branch: ci-auto-update-v${{ env.VERSION }}
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
[See upstream release page](https://github.com/${{ env.REPO }}/releases/tag/v${{ env.VERSION }})
draft: false

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Lychee for YunoHost
[![Integration level](https://dash.yunohost.org/integration/lychee.svg)](https://dash.yunohost.org/appci/app/lychee) ![](https://ci-apps.yunohost.org/ci/badges/lychee.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lychee.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/lychee.svg)](https://dash.yunohost.org/appci/app/lychee) ![Working status](https://ci-apps.yunohost.org/ci/badges/lychee.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/lychee.maintain.svg)
[![Install Lychee with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lychee)
*[Lire ce readme en français.](./README_fr.md)*
@ -15,33 +15,35 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
Photo-management-system to manage and share photos
Lychee is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely.
**Shipped version:** 4.4.0~ynh4
**Shipped version:** 4.4~ynh3
**Demo:** https://lycheeorg.github.io/demo/
## Screenshots
![](./doc/screenshots/screenshot.jpg)
![Screenshot of Lychee](./doc/screenshots/screenshot.jpg)
## Documentation and resources
* Official app website: https://lycheeorg.github.io/
* Official admin documentation: https://lycheeorg.github.io/docs/
* Upstream app code repository: https://github.com/LycheeOrg/Lychee
* YunoHost documentation for this app: https://yunohost.org/app_lychee
* Report a bug: https://github.com/YunoHost-Apps/lychee_ynh/issues
* Official app website: <https://lycheeorg.github.io/>
* Official admin documentation: <https://lycheeorg.github.io/docs/>
* Upstream app code repository: <https://github.com/LycheeOrg/Lychee>
* YunoHost documentation for this app: <https://yunohost.org/app_lychee>
* Report a bug: <https://github.com/YunoHost-Apps/lychee_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/lychee_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/lychee_ynh/tree/testing --debug
or
sudo yunohost app upgrade lychee -u https://github.com/YunoHost-Apps/lychee_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,43 +1,49 @@
<!--
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.
-->
# Lychee pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/lychee.svg)](https://dash.yunohost.org/appci/app/lychee) ![](https://ci-apps.yunohost.org/ci/badges/lychee.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lychee.maintain.svg)
[![Niveau d'intégration](https://dash.yunohost.org/integration/lychee.svg)](https://dash.yunohost.org/appci/app/lychee) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/lychee.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/lychee.maintain.svg)
[![Installer Lychee avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lychee)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Lychee 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.*
## Vue d'ensemble
Système de gestion de photos pour gérer et partager des photos
Lychee is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely.
**Version incluse :** 4.4.0~ynh4
**Version incluse :** 4.4~ynh3
**Démo :** https://lycheeorg.github.io/demo/
## Captures d'écran
![](./doc/screenshots/screenshot.jpg)
![Capture d'écran de Lychee](./doc/screenshots/screenshot.jpg)
## Documentations et ressources
* Site officiel de l'app : https://lycheeorg.github.io/
* Documentation officielle de l'admin : https://lycheeorg.github.io/docs/
* Dépôt de code officiel de l'app : https://github.com/LycheeOrg/Lychee
* Documentation YunoHost pour cette app : https://yunohost.org/app_lychee
* Signaler un bug : https://github.com/YunoHost-Apps/lychee_ynh/issues
* Site officiel de l'app : <https://lycheeorg.github.io/>
* Documentation officielle de l'admin : <https://lycheeorg.github.io/docs/>
* Dépôt de code officiel de l'app : <https://github.com/LycheeOrg/Lychee>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_lychee>
* Signaler un bug : <https://github.com/YunoHost-Apps/lychee_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/lychee_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/lychee_ynh/tree/testing --debug
ou
sudo yunohost app upgrade lychee -u https://github.com/YunoHost-Apps/lychee_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

@ -11,17 +11,12 @@
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=2a2fd5b9a9e81ff8e157cf1747418fd11f4211a2
upgrade=1 from_commit=1fa062d50aaa810deeba6426405fbe2e2671492a
# 4.4~ynh3
upgrade=1 from_commit=a87e16f7ca7e6645610745970bc7c3daa263b2b7
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=2a2fd5b9a9e81ff8e157cf1747418fd11f4211a2
name= Fix linter (#13) 11 Dec 2020
; commit=1fa062d50aaa810deeba6426405fbe2e2671492a
name= Merge branch 'testing' (#26)
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&

View file

@ -25,7 +25,7 @@ DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=__DB_NAME__
DB_USERNAME=__DB_NAME__
DB_USERNAME=__DB_USER__
DB_PASSWORD=__DB_PWD__
DB_LOG_SQL=false
@ -33,7 +33,7 @@ TIMEZONE=UTC
# folders in which the files will be stored
LYCHEE_DIST="__FINALPATH__/public/dist/"
LYCHEE_UPLOADS="__PUBLIC_PATH__/uploads/"
LYCHEE_UPLOADS="__DATADIR__/uploads/"
# url to access those files
# LYCHEE_DIST_URL="dist/"

View file

@ -3,3 +3,5 @@ SOURCE_SUM=2d451033e392e6c3287f8962524e9b4f5581d8e3dfcc9040690d2dc190274c26
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
; Additional php.ini defines, specific to this pool of workers.
php_admin_value[upload_max_filesize] = 512M
php_admin_value[post_max_size] = 512M
php_admin_value[memory_limit] = 256M
php_admin_value[post_max_size] = 512M
php_admin_value[max_execution_time] = 200

View file

@ -2,37 +2,33 @@
location ^~ __PATH__/ {
# Path to source
alias __FINALPATH__/public/ ;
alias __FINALPATH__/public/;
index index.php;
# setup for image upload
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
client_max_body_size 512M;
try_files $uri $uri/ __PATH__/__PATH__/index.php?$query_string;
location ~ \.php$ {
if (!-e $request_filename) {
rewrite ^__PATH__/?(.*)$ __PATH__/index.php?/$1 last;
break;
}
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
if (!-e $request_filename) {
rewrite ^__PATH__/?(.*)$ __PATH__/index.php?/$1 last;
break;
}
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
location __PATH__/uploads/ {
alias __PUBLIC_PATH__/uploads/ ;
alias __DATADIR__/uploads/ ;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
location @lychee {
rewrite __PATH__/(.*)$ __PATH__/index.php?/$1 last;
}

View file

@ -419,12 +419,12 @@ chdir = __FINALPATH__
;php_admin_value[memory_limit] = 32M
; Common values to change to increase file upload limit
; php_admin_value[upload_max_filesize] = 50M
; php_admin_value[post_max_size] = 50M
php_admin_value[upload_max_filesize] = 512M
php_admin_value[post_max_size] = 512M
; php_admin_flag[mail.add_x_header] = Off
; Other common parameters
; php_admin_value[max_execution_time] = 600
php_admin_value[max_execution_time] = 200
; php_admin_value[max_input_time] = 300
; php_admin_value[memory_limit] = 256M
php_admin_value[memory_limit] = 256M
; php_admin_flag[short_open_tag] = On

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Lychee is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely.

View file

@ -6,7 +6,7 @@
"en": "Photo-management-system to manage and share photos",
"fr": "Système de gestion de photos pour gérer et partager des photos"
},
"version": "4.4~ynh3",
"version": "4.4.0~ynh4",
"url": "https://lycheeorg.github.io/",
"upstream": {
"license": "MIT",
@ -30,20 +30,20 @@
"mysql"
],
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain"
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"name": "path",
"type": "path",
"example": "/lychee",
"default": "/lychee"
},
{
"name": "is_public",
"type": "boolean",
"name": "is_public",
"type": "boolean",
"help": {
"en": "If enabled, Lychee will be accessible by people who do not have an account. This can be changed later via the webadmin.",
"fr": "Si cette case est cochée, Lychee sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."

View file

@ -7,18 +7,11 @@
YNH_PHP_VERSION="8.0"
# Composer version
YNH_COMPOSER_VERSION="2.3.3"
YNH_COMPOSER_VERSION="2.3.5"
# dependencies used by the app
pkg_dependencies="ffmpeg php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-exif php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysqli php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-intl"
# # needed for raw upload and video playback
# # ufraw-batch is not supported in bullseye
# if ! (apt-cache -q=0 show ufraw-batch |& grep ': No packages found' &>/dev/null); then
# pkg_dependencies="ffmpeg"
# else
# pkg_dependencies="ufraw-batch ffmpeg"
# fi
#=================================================
# PERSONAL HELPERS
#=================================================

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
@ -24,10 +25,10 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
public_path=$(ynh_app_setting_get --app=$app --key=public_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -41,10 +42,10 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP MEDIA FOLDER
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$public_path" --is_big
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -9,9 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
@ -31,12 +28,14 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
public_path=$(ynh_app_setting_get --app=$app --key=public_path)
# Add settings here as needed by your application
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Lychee before changing its URL..." --weight=2
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=2
# Backup the current version of the app
ynh_backup_before_upgrade
@ -44,7 +43,7 @@ ynh_clean_setup () {
# 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

@ -22,7 +22,6 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME
@ -31,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
datadir=/home/yunohost.app/$app
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -44,7 +44,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
#=================================================
# INSTALL DEPENDENCIES
@ -86,19 +85,13 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# CREATE DATA DIRECTORY
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
public_path=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=public_path --value=$public_path
mkdir -p $public_path/uploads
mkdir -p $public_path/uploads/{big,import,medium,raw,small,thumb}
chmod 750 "$public_path"
chmod -R o-rwx "$public_path"
chown -R $app:www-data "$public_path"
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
@ -109,17 +102,35 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
# SPECIFIC SETUP
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/uploads
mkdir -p $datadir/uploads/{big,import,medium,raw,small,thumb}
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# INSTALL LYCHEE WITH COMPOSER
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Installing $app with Composer..." --weight=15
ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env"
chmod 400 "$final_path/.env"
chown $app:$app "$final_path/.env"
#=================================================
# INSTALL APP WITH COMPOSER
#=================================================
ynh_script_progression --message="Installing app with Composer..." --weight=15
ynh_install_composer --install_args="--ignore-platform-reqs"
@ -128,10 +139,6 @@ ynh_install_composer --install_args="--ignore-platform-reqs"
#=================================================
ynh_script_progression --message="Building..." --weight=10
# Setup application config
ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env"
# Setup application config
pushd $final_path
php$phpversion artisan key:generate -n --force --env
php$phpversion artisan migrate -n --force
@ -143,19 +150,23 @@ popd
# Setup custom user.css file
ynh_add_config --template="../conf/user.css.example" --destination="$final_path/public/dist/user.css"
ynh_replace_string --match_string="\$ffmpeg = FFMpeg::create();" --replace_string="\$ffmpeg = FFMpeg::create(array(\
'ffmpeg.binaries' => '/usr/bin/ffmpeg',\
'ffprobe.binaries' => '/usr/bin/ffprobe',\
));" --target_file="$final_path/app/Actions/Photo/Extensions/VideoEditing.php"
ynh_replace_string \
--match_string="\$ffmpeg = FFMpeg::create();" \
--replace_string="\$ffmpeg = FFMpeg::create(array('ffmpeg.binaries' => '/usr/bin/ffmpeg','ffprobe.binaries' => '/usr/bin/ffprobe',));" \
--target_file="$final_path/app/Actions/Photo/Extensions/VideoEditing.php"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP SSOWAT
#=================================================
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

@ -17,13 +17,21 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
public_path=$(ynh_app_setting_get --app=$app --key=public_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -36,21 +44,13 @@ ynh_secure_remove --file="$final_path"
# REMOVE DATA DIR
#=================================================
# Remove the app data directory with the command `yunohost app remove lychee --purge`
if [ "$YNH_APP_PURGE" == true ]
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing $app data directory..." --weight=2
ynh_secure_remove --file="$public_path"
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================

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
@ -13,6 +14,7 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
@ -25,26 +27,21 @@ app=$YNH_APP_INSTANCE_NAME
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)
public_path=$(ynh_app_setting_get --app=$app --key=public_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
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_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -66,18 +63,17 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# RESTORE DATA
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..."
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
ynh_restore_file --origin_path="$public_path" --not_mandatory
ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p $public_path
mkdir -p $datadir
chmod 755 "$public_path"
chmod -R o-rwx "$public_path"
chown -R $app:www-data "$public_path"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# REINSTALL DEPENDENCIES
@ -90,13 +86,16 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring PHP-FPM configuration..."
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
# Restore the file first, so it can have a backup if different
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Recreate a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
#=================================================
# RESTORE 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"
#=================================================
# RESTORE THE MYSQL DATABASE

View file

@ -19,31 +19,35 @@ app=$YNH_APP_INSTANCE_NAME
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)
public_path=$(ynh_app_setting_get --app=$app --key=public_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
phpversion=$YNH_PHP_VERSION
#=================================================
# 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 Lychee before upgrading..." --weight=3
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# 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
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -61,23 +65,23 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# If public_path doesn't exist, create it
if [ -z "$public_path" ]; then
public_path=/home/yunohost.app/$app
mkdir -p $public_path
chmod 755 $public_path
chown -R $app:www-data $public_path
ynh_app_setting_set --app=$app --key=public_path --value=$public_path
# If datadir doesn't exist, create it
if [ -z "$datadir" ]; then
datadir=/home/yunohost.app/$app
mkdir -p $datadir
chmod 755 $datadir
chown -R $app:www-data $datadir
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi
# If new "/home/yunohost.app/$app" doesn't exist, create it
if [ -z "/home/yunohost.app/$app" ]; then
public_path=/home/yunohost.app/$app
mkdir -p $public_path
chmod 755 $public_path
chown -R $app:www-data $public_path
ynh_app_setting_set --app=$app --key=public_path --value=$public_path
cp -a "$final_path/public/uploads" "$public_path/uploads"
datadir=/home/yunohost.app/$app
mkdir -p $datadir
chmod 755 $datadir
chown -R $app:www-data $datadir
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
cp -a "$final_path/public/uploads" "$datadir/uploads"
fi
# Cleaning legacy permissions
@ -104,7 +108,7 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=4
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.env $final_path/public/dist/user.css"
ynh_setup_source --dest_dir="$final_path" --keep=".env public/dist/user.css"
fi
chmod 750 "$final_path"
@ -112,14 +116,6 @@ chmod 750 "$final_path/bootstrap/cache"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
@ -134,42 +130,54 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# PHP-FPM CONFIGURATION
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Installing Composer..." --weight=1
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env"
chmod 400 "$final_path/.env"
chown $app:$app "$final_path/.env"
#=================================================
# INSTALL APP WITH COMPOSER
#=================================================
ynh_script_progression --message="Installing app with Composer..." --weight=1
ynh_install_composer --install_args="--ignore-platform-reqs"
#=================================================
# SETUP APPLICATION CONFIG
# BUILDING
#=================================================
ynh_script_progression --message="Setting $app config..."
# Setup application config
#ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env"
ynh_replace_string --match_string="\$ffmpeg = FFMpeg::create();" --replace_string="\$ffmpeg = FFMpeg::create(array(\
'ffmpeg.binaries' => '/usr/bin/ffmpeg',\
'ffprobe.binaries' => '/usr/bin/ffprobe',\
));" --target_file="$final_path/app/Actions/Photo/Extensions/VideoEditing.php"
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
ynh_script_progression --message="Upgrading $app source files..." --weight=4
ynh_script_progression --message="Building..." --weight=4
ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload"
pushd $final_path
#php$phpversion artisan key:generate
php$phpversion artisan migrate -n --force
php$phpversion artisan config:clear -n
php$phpversion artisan config:cache -n
php$phpversion artisan view:clear
popd
ynh_replace_string \
--match_string="\$ffmpeg = FFMpeg::create();" \
--replace_string="\$ffmpeg = FFMpeg::create(array('ffmpeg.binaries' => '/usr/bin/ffmpeg','ffprobe.binaries' => '/usr/bin/ffprobe',));" \
--target_file="$final_path/app/Actions/Photo/Extensions/VideoEditing.php"
chmod 750 "$final_path"
chmod 750 "$final_path/bootstrap/cache"
chmod -R o-rwx "$final_path"