diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index 4363d38..4a866ff 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch the source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - name: Run the updater script @@ -33,7 +33,7 @@ jobs: - name: Create Pull Request id: cpr if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update to version ${{ env.VERSION }} diff --git a/README.md b/README.md index 3e7442f..d77ae9c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ 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) ![Working status](https://ci-apps.yunohost.org/ci/badges/lychee.status.svg) ![Maintenance status](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)* @@ -17,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in 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.7.0~ynh1 +**Shipped version:** 4.7.0~ynh2 **Demo:** https://lycheeorg.github.io/demo/ diff --git a/README_fr.md b/README_fr.md index e78e840..3782447 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,31 +5,32 @@ 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) ![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) +[![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)* -> *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.* +> *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 +## Vue d’ensemble 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.7.0~ynh1 +**Version incluse :** 4.7.0~ynh2 **Démo :** https://lycheeorg.github.io/demo/ -## Captures d'écran +## Captures d’écran -![Capture d'écran de Lychee](./doc/screenshots/screenshot.jpg) +![Capture d’écran de Lychee](./doc/screenshots/screenshot.jpg) ## Documentations et ressources -* Site officiel de l'app : -* Documentation officielle de l'admin : -* Dépôt de code officiel de l'app : +* Site officiel de l’app : +* Documentation officielle de l’admin : +* Dépôt de code officiel de l’app : * Documentation YunoHost pour cette app : * Signaler un bug : @@ -45,4 +46,4 @@ 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 :** +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/check_process b/check_process deleted file mode 100644 index e0e99ad..0000000 --- a/check_process +++ /dev/null @@ -1,22 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - # 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 diff --git a/conf/.env.example b/conf/.env.example index 3be345a..c4219da 100644 --- a/conf/.env.example +++ b/conf/.env.example @@ -32,8 +32,8 @@ DB_LOG_SQL=false TIMEZONE=UTC # folders in which the files will be stored -LYCHEE_DIST="__FINALPATH__/public/dist/" -LYCHEE_UPLOADS="__DATADIR__/uploads/" +LYCHEE_DIST="__INSTALL_DIR__/public/dist/" +LYCHEE_UPLOADS="__DATA_DIR__/uploads/" # url to access those files # LYCHEE_DIST_URL="dist/" @@ -65,3 +65,5 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +ENABLE_TOKEN_AUTH=false diff --git a/conf/nginx.conf b/conf/nginx.conf index 5527081..ece5e5f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location ^~ __PATH__/ { # Path to source - alias __FINALPATH__/public/; + alias __INSTALL_DIR__/public/; index index.php; @@ -26,7 +26,7 @@ location ^~ __PATH__/ { } location __PATH__/uploads/ { - alias __DATADIR__/uploads/ ; + alias __DATA_DIR__/uploads/ ; } # Include SSOWAT user panel. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e69de29..0000000 diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 461d41f..0000000 --- a/manifest.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "Lychee", - "id": "lychee", - "packaging_format": 1, - "description": { - "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.7.0~ynh1", - "url": "https://lycheeorg.github.io/", - "upstream": { - "license": "MIT", - "website": "https://lycheeorg.github.io/", - "demo": "https://lycheeorg.github.io/demo/", - "admindoc": "https://lycheeorg.github.io/docs/", - "code": "https://github.com/LycheeOrg/Lychee" - }, - "license": "MIT", - "maintainer": { - "name": "eric_G", - "email": "" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx", - "php8.1-fpm", - "mysql" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/lychee", - "default": "/lychee" - }, - { - "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 n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." - }, - "default": true - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..e33388d --- /dev/null +++ b/manifest.toml @@ -0,0 +1,57 @@ +packaging_format = 2 + +id = "lychee" +name = "Lychee" +description.en = "Photo-management-system to manage and share photos" +description.fr = "Système de gestion de photos pour gérer et partager des photos" + +version = "4.7.0~ynh2" + +maintainers = ["eric_G"] + +[upstream] +license = "MIT" +website = "https://lycheeorg.github.io/" +demo = "https://lycheeorg.github.io/demo/" +admindoc = "https://lycheeorg.github.io/docs/" +code = "https://github.com/LycheeOrg/Lychee" + +[integration] +yunohost = ">= 11.1.13" +architectures = "all" +multi_instance = true +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/lychee" + + [install.init_main_permission] + help.en = "If enabled, Lychee will be accessible by people who do not have an account. This can be changed later via the webadmin." + help.fr = "Si cette case est cochée, Lychee sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." + type = "group" + default = "visitors" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = "mariadb-server ffmpeg php8.1-xml php8.1-imagick php8.1-bcmath php8.1-exif php8.1-mbstring php8.1-gd php8.1-mysqli php8.1-zip php8.1-intl" + + [resources.database] + type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 420096a..13781df 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,16 +4,9 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="8.1" - # Composer version YNH_COMPOSER_VERSION="2.3.5" -# dependencies used by the app -php_dependencies="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" - -pkg_dependencies="ffmpeg $php_dependencies" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index f932df9..60cea71 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,26 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_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 #================================================= @@ -39,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 8b24f20..df843ac 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,97 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -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) - -# Add settings here as needed by your application -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -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 -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 - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_change_url_nginx_config #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index e62858c..9d15733 100755 --- a/scripts/install +++ b/scripts/install @@ -9,87 +9,33 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - -app=$YNH_APP_INSTANCE_NAME - fpm_footprint="low" fpm_free_footprint=0 fpm_usage="low" -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -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" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -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=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=3 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=2 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# CREATE A MYSQL DATABASE -#================================================= -ynh_script_progression --message="Creating a MySQL database..." --weight=2 - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 -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="$install_dir" -chmod 750 "$final_path" -chmod 750 "$final_path/bootstrap/cache" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir/bootstrap/cache" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION @@ -98,7 +44,6 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -115,14 +60,12 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +mkdir -p $data_dir/uploads +mkdir -p $data_dir/uploads/{big,import,medium,raw,small,thumb} -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" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # INSTALL APP WITH COMPOSER @@ -136,53 +79,25 @@ ynh_install_composer #================================================= ynh_script_progression --message="Adding a configuration file..." -ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env" +ynh_add_config --template="../conf/.env.example" --destination="$install_dir/.env" -chmod 400 "$final_path/.env" -chown $app:$app "$final_path/.env" +chmod 400 "$install_dir/.env" +chown $app:$app "$install_dir/.env" #================================================= # BUILDING #================================================= ynh_script_progression --message="Building..." --weight=10 -pushd $final_path +pushd $install_dir php$phpversion artisan key:generate -n --force --env php$phpversion artisan migrate -n --force php$phpversion artisan config:clear -n php$phpversion artisan config:cache -n - #patch -p1 < "$YNH_CWD/../conf/ffprobe.patch" 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" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# 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 - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_add_config --template="../conf/user.css.example" --destination="$install_dir/public/dist/user.css" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 285ab44..61db822 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,48 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -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 -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=3 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# 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..." - ynh_secure_remove --file="$datadir" -fi - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -59,32 +17,9 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index e96de69..869b1ca 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,81 +10,25 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -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) -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) - -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - -#================================================= -# 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 " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -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" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=2 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod 750 "$final_path/bootstrap/cache" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir/bootstrap/cache" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" - -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=7 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +chown -R $app:www-data "$data_dir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -96,20 +40,8 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # Recreate a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion -#================================================= -# 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 -#================================================= -ynh_script_progression --message="Restoring the MySQL database..." - -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 12b781f..336ad77 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,47 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -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) -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 - -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - #================================================= # 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 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 - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -57,35 +22,14 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - -# 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 - 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" + data_dir=/home/yunohost.app/$app + mkdir -p $data_dir + chmod 755 $data_dir + chown -R $app:www-data $data_dir +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir + cp -a "$install_dir/public/uploads" "$data_dir/uploads" fi # If fpm_footprint doesn't exist, create it @@ -106,21 +50,6 @@ if [ -z "$fpm_usage" ]; then ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage fi -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -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" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -130,20 +59,12 @@ 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=".env public/dist/user.css" + ynh_setup_source --dest_dir="$install_dir" --keep=".env public/dist/user.css" fi -chmod 750 "$final_path" -chmod 750 "$final_path/bootstrap/cache" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=6 - -ynh_install_app_dependencies $pkg_dependencies +chmod 750 "$install_dir/bootstrap/cache" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION @@ -152,7 +73,6 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -169,10 +89,10 @@ ynh_add_nginx_config #================================================= #ynh_script_progression --message="Updating a configuration file..." -#ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env" +#ynh_add_config --template="../conf/.env.example" --destination="$install_dir/.env" -#chmod 400 "$final_path/.env" -#chown $app:$app "$final_path/.env" +#chmod 400 "$install_dir/.env" +#chown $app:$app "$install_dir/.env" #================================================= # INSTALL APP WITH COMPOSER @@ -188,29 +108,17 @@ ynh_script_progression --message="Building..." --weight=4 ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload" -pushd $final_path +pushd $install_dir 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" -chown -R $app:www-data "$final_path" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +chmod 750 "$install_dir" +chmod 750 "$install_dir/bootstrap/cache" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..91daf17 --- /dev/null +++ b/tests.toml @@ -0,0 +1,7 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ \ No newline at end of file