1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/moodle_ynh.git synced 2024-09-03 19:46:23 +02:00

Merge pull request #21 from YunoHost-Apps/testing

Get ride of sury
This commit is contained in:
Kayou 2020-06-23 13:48:45 +02:00 committed by GitHub
commit 258d9202ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 189 additions and 428 deletions

View file

@ -3,8 +3,8 @@
[![Integration level](https://dash.yunohost.org/integration/moodle.svg)](https://dash.yunohost.org/appci/app/moodle) ![](https://ci-apps.yunohost.org/ci/badges/moodle.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/moodle.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/moodle.svg)](https://dash.yunohost.org/appci/app/moodle) ![](https://ci-apps.yunohost.org/ci/badges/moodle.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/moodle.maintain.svg)
[![Install Moodle with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=moodle) [![Install Moodle with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=moodle)
> *This package allow you to install Moodle quickly and simply on a YunoHost server. > *This package allows you to install Moodle quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
[Moodle](https://moodle.org) is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised learning environments. [Moodle](https://moodle.org) is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised learning environments.
@ -31,7 +31,7 @@ How to configure this app: by an admin panel.
## YunoHost specific features ## YunoHost specific features
#### Multi-users support #### Multi-user support
* Are LDAP and HTTP auth supported? **Yes** * Are LDAP and HTTP auth supported? **Yes**
* Can the app be used by multiple users? **Yes** * Can the app be used by multiple users? **Yes**
@ -50,10 +50,10 @@ How to configure this app: by an admin panel.
--- ---
Developers info Developer info
---------------- ----------------
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/moodle_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/moodle_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
``` ```

View file

@ -12,6 +12,8 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 3.8.2~ynh2
upgrade=1 from_commit=3bdecdeabdcaaf1fdfade6e5b7dcfa30704c665c
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0 port_already_use=0
@ -22,3 +24,6 @@
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none
;;; Upgrade options
; commit=3bdecdeabdcaaf1fdfade6e5b7dcfa30704c665c
name=3.8.2~ynh2

View file

@ -1 +1 @@
*/15 * * * * __APP__ /usr/bin/php__YNH_PHP_VERSION__ -f __FINAL_PATH__/admin/cli/cron.php */15 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINAL_PATH__/admin/cli/cron.php

View file

@ -16,7 +16,7 @@ location __PATH__/ {
try_files $uri $uri/ index.php; try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__YNH_PHP_VERSION__-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;

46
issue_template.md Normal file
View file

@ -0,0 +1,46 @@
---
name: Bug report
about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!*
- *Otherwise, the issue may be due to Moodle itself. Refer to its documentation or repository for help.*
- *If you have a doubt, post here, we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
**Describe the bug**
*A clear and concise description of what the bug is.*
**Versions**
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
**To Reproduce**
*Steps to reproduce the behavior.*
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install moodle
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '....'*
3. *Scroll down to '....'*
4. *See error*
**Expected behavior**
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
**Logs**
*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
*If applicable and useful, add screenshots to help explain your problem.*

View file

@ -18,7 +18,8 @@
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx" "nginx",
"php7.0-fpm"
], ],
"arguments": { "arguments": {
"install" : [ "install" : [

18
pull_request_template.md Normal file
View file

@ -0,0 +1,18 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished.
- [ ] Tested with Package_check.
- [ ] Fix or enhancement tested.
- [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested.
## Package_check results
---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/moodle_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/moodle_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -5,10 +5,16 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
YNH_PHP_VERSION="7.3"
extra_pkg_dependencies="php$YNH_PHP_VERSION-common php$YNH_PHP_VERSION-mbstring php$YNH_PHP_VERSION-curl php$YNH_PHP_VERSION-xmlrpc php$YNH_PHP_VERSION-soap php$YNH_PHP_VERSION-zip php$YNH_PHP_VERSION-gd php$YNH_PHP_VERSION-xml php$YNH_PHP_VERSION-intl php$YNH_PHP_VERSION-json php$YNH_PHP_VERSION-pgsql php$YNH_PHP_VERSION-ldap"
pkg_dependencies="postgresql" pkg_dependencies="postgresql"
YNH_PHP_VERSION="7.3"
extra_php_dependencies="php$YNH_PHP_VERSION-common php$YNH_PHP_VERSION-mbstring php$YNH_PHP_VERSION-curl php$YNH_PHP_VERSION-xmlrpc php$YNH_PHP_VERSION-soap php$YNH_PHP_VERSION-zip php$YNH_PHP_VERSION-gd php$YNH_PHP_VERSION-xml php$YNH_PHP_VERSION-intl php$YNH_PHP_VERSION-json php$YNH_PHP_VERSION-pgsql php$YNH_PHP_VERSION-ldap"
#=================================================
# PERSONAL HELPERS
#=================================================
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
@ -25,3 +31,7 @@ exec_as() {
sudo -u "$USER" "$@" sudo -u "$USER" "$@"
fi fi
} }
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -6,9 +6,8 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source ../settings/scripts/ynh_add_extra_apt_repos
source ../settings/scripts/ynh_install_php
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -21,7 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -29,13 +28,16 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path) data_path=$(ynh_app_setting_get --app=$app --key=data_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# STANDARD BACKUP STEPS # DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Backing up the main app directory..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
@ -44,35 +46,32 @@ ynh_backup --src_path="$data_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up nginx web server configuration..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up php-fpm configuration..."
ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
# BACKUP A CRON FILE # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Backing up the cron file..."
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -7,8 +7,6 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_add_extra_apt_repos
source ynh_install_php
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -26,6 +24,8 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
email=$(ynh_user_get_info $admin mail)
password=$(ynh_string_random --length=30)
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -57,15 +57,9 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=60 ynh_script_progression --message="Installing dependencies..."
if [ "$(lsb_release --codename --short)" = "stretch" ]; then ynh_install_app_dependencies $pkg_dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies"
else
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
ynh_install_app_dependencies $pkg_dependencies
fi
#================================================= #=================================================
# CREATE POSTGRESQL DATABASE # CREATE POSTGRESQL DATABASE
@ -75,8 +69,9 @@ ynh_script_progression --message="Creating a PostgreSQL database..." --weight=4
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
db_name=$(ynh_sanitize_dbid --db_name=$app) 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_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_pwd=$(ynh_app_setting_get $app psqlpwd) db_pwd=$(ynh_app_setting_get $app psqlpwd)
@ -95,7 +90,7 @@ ynh_setup_source --dest_dir="$final_path"
ynh_script_progression --message="Configuring nginx web server..." --weight=2 ynh_script_progression --message="Configuring nginx web server..." --weight=2
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config YNH_PHP_VERSION ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -111,7 +106,8 @@ ynh_system_user_create --username=$app
ynh_script_progression --message="Configuring php-fpm..." --weight=1 ynh_script_progression --message="Configuring php-fpm..." --weight=1
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" ynh_add_fpm_config --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -127,12 +123,9 @@ chown -R "$app": "$final_path"
#================================================= #=================================================
# SETUP APPLICATION # SETUP APPLICATION
#================================================= #=================================================
ynh_script_progression --message="Configuring the application..." --weight=190 ynh_script_progression --message="Setuping the application..." --weight=190
email=$(ynh_user_get_info $admin mail) exec_as "$app" php$phpversion "$final_path/admin/cli/install.php" --wwwroot="https://$domain${path_url%/}" --dataroot=$data_path --dbtype='pgsql' --dbname=$db_name --dbuser=$db_name --dbpass=$db_pwd --adminuser=$admin --adminpass=$password --adminemail=$email --fullname="YunoHost" --shortname="YNH" --non-interactive --agree-license
password=$(ynh_string_random --length=30)
exec_as "$app" php$YNH_PHP_VERSION "$final_path/admin/cli/install.php" --wwwroot="https://$domain${path_url%/}" --dataroot=$data_path --dbtype='pgsql' --dbname=$db_name --dbuser=$db_name --dbpass=$db_pwd --adminuser=$admin --adminpass=$password --adminemail=$email --fullname="YunoHost" --shortname="YNH" --non-interactive --agree-license
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/config.php" ynh_store_file_checksum "$final_path/config.php"
@ -140,6 +133,7 @@ ynh_store_file_checksum "$final_path/config.php"
#================================================= #=================================================
# ACTIVATE LDAP SUPPORT # ACTIVATE LDAP SUPPORT
#================================================= #=================================================
ynh_script_progression --message="Activate ldap support..."
ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config SET value='ldap,email' WHERE name='auth';" ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config SET value='ldap,email' WHERE name='auth';"
ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config_plugins SET value='ldap://127.0.0.1/' WHERE plugin='auth_ldap' AND name='host_url';" ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config_plugins SET value='ldap://127.0.0.1/' WHERE plugin='auth_ldap' AND name='host_url';"
@ -154,26 +148,37 @@ ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config_plu
# The admin is an ldap user # The admin is an ldap user
ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_user SET auth='ldap' WHERE username='$admin';" ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_user SET auth='ldap' WHERE username='$admin';"
exec_as "$app" php$YNH_PHP_VERSION "$final_path/admin/cli/purge_caches.php" exec_as "$app" php$phpversion "$final_path/admin/cli/purge_caches.php"
#================================================= #=================================================
# ADD CRON JOB # ADD CRON JOB
#================================================= #=================================================
ynh_script_progression --message="Adding cron job..."
# Set up poller # Set up poller
sudo cp "../conf/cron" "/etc/cron.d/$app" cp "../conf/cron" "/etc/cron.d/$app"
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app" ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
ynh_replace_string "__FINAL_PATH__" "$final_path" "/etc/cron.d/$app" ynh_replace_string "__FINAL_PATH__" "$final_path" "/etc/cron.d/$app"
ynh_replace_string "__YNH_PHP_VERSION__" "$YNH_PHP_VERSION" "/etc/cron.d/$app" ynh_replace_string "__PHPVERSION__" "$phpversion" "/etc/cron.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R "$app": "$data_path"
chown -R "$app": "$final_path"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring SSOwat..."
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway. # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"

View file

@ -7,8 +7,6 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_add_extra_apt_repos
source ynh_install_php
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -20,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) 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) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path) data_path=$(ynh_app_setting_get --app=$app --key=data_path)
@ -28,10 +27,10 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgresSQL database..." ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_name --db_name=$db_name ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
@ -65,15 +64,12 @@ ynh_script_progression --message="Removing php-fpm configuration..." --weight=20
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
if [ "$(lsb_release --codename --short)" = "stretch" ]; then
ynh_remove_php
fi
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE THE CRON FILE # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..."
# Remove a cron file # Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"

View file

@ -7,8 +7,6 @@
#================================================= #=================================================
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_add_extra_apt_repos
source ../settings/scripts/ynh_install_php
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -30,6 +28,8 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path) data_path=$(ynh_app_setting_get --app=$app --key=data_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -48,6 +48,7 @@ test ! -d $data_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -71,6 +72,7 @@ ynh_system_user_create --username=$app
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files # Restore permissions on app files
chown -R $app: $final_path chown -R $app: $final_path
@ -79,23 +81,22 @@ chown -R $app: $data_path
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Recreate a dedicated php-fpm config
ynh_add_fpm_config --package="$extra_php_dependencies"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=60 ynh_script_progression --message="Reinstalling dependencies..."
if [ "$(lsb_release --codename --short)" = "stretch" ]; then # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies"
else
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
ynh_install_app_dependencies $pkg_dependencies
fi
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
@ -105,12 +106,13 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." --weight
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#================================================= #=================================================
# RESTORE THE CRON FILE # RESTORE THE CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Restoring the cron file..."
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
@ -121,7 +123,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app"
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server and php-fpm..." ynh_script_progression --message="Reloading nginx web server and php-fpm..."
ynh_systemd_action --service_name=php$YNH_PHP_VERSION-fpm --action=reload ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -7,8 +7,6 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_add_extra_apt_repos
source ynh_install_php
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -29,6 +27,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -76,20 +75,14 @@ fi
ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_script_progression --message="Upgrading nginx web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config YNH_PHP_VERSION ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=30 ynh_script_progression --message="Upgrading dependencies..."
if [ "$(lsb_release --codename --short)" = "stretch" ]; then ynh_install_app_dependencies "$pkg_dependencies"
ynh_install_app_dependencies $pkg_dependencies
ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies"
else
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
ynh_install_app_dependencies $pkg_dependencies
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -105,23 +98,23 @@ ynh_system_user_create --username=$app
ynh_script_progression --message="Upgrading php-fpm configuration..." ynh_script_progression --message="Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" ynh_add_fpm_config --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # UPGRADING THE APPLICATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading the application..."
ynh_backup_if_checksum_is_different --file="$final_path/config.php" ynh_backup_if_checksum_is_different --file="$final_path/config.php"
exec_as "$app" php$YNH_PHP_VERSION "$final_path/admin/cli/upgrade.php" --non-interactive exec_as "$app" php$phpversion "$final_path/admin/cli/upgrade.php" --non-interactive
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/config.php" ynh_store_file_checksum --file="$final_path/config.php"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
@ -130,19 +123,10 @@ ynh_store_file_checksum --file="$final_path/config.php"
chown -R "$app": "$data_path" chown -R "$app": "$data_path"
chown -R "$app": "$final_path" chown -R "$app": "$final_path"
#=================================================
# ADD CRON JOB
#=================================================
# Set up poller
sudo cp "../conf/cron" "/etc/cron.d/$app"
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
ynh_replace_string "__FINAL_PATH__" "$final_path" "/etc/cron.d/$app"
ynh_replace_string "__YNH_PHP_VERSION__" "$YNH_PHP_VERSION" "/etc/cron.d/$app"
#================================================= #=================================================
# ACTIVATE LDAP SUPPORT # ACTIVATE LDAP SUPPORT
#================================================= #=================================================
ynh_script_progression --message="Activate ldap support..."
ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config SET value='ldap,email' WHERE name='auth';" ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config SET value='ldap,email' WHERE name='auth';"
ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config_plugins SET value='ldap://127.0.0.1/' WHERE plugin='auth_ldap' AND name='host_url';" ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config_plugins SET value='ldap://127.0.0.1/' WHERE plugin='auth_ldap' AND name='host_url';"
@ -157,7 +141,29 @@ ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_config_plu
# The admin is an ldap user # The admin is an ldap user
ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_user SET auth='ldap' WHERE username='$admin';" ynh_psql_execute_as_root --database=$db_name --sql="UPDATE public.mdl_user SET auth='ldap' WHERE username='$admin';"
exec_as "$app" php$YNH_PHP_VERSION "$final_path/admin/cli/purge_caches.php" exec_as "$app" php$phpversion "$final_path/admin/cli/purge_caches.php"
#=================================================
# ADD CRON JOB
#=================================================
ynh_script_progression --message="Adding cron job..."
# Set up poller
cp "../conf/cron" "/etc/cron.d/$app"
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
ynh_replace_string "__FINAL_PATH__" "$final_path" "/etc/cron.d/$app"
ynh_replace_string "__PHPVERSION__" "$phpversion" "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R "$app": "$data_path"
chown -R "$app": "$final_path"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -1,249 +0,0 @@
# Add dependencies to install with ynh_install_app_dependencies
#
# [internal]
#
# usage: ynh_add_app_dependencies --package=phpversion [--replace]
# | arg: -p, --package - Packages to add as dependencies for the app.
# | arg: -r, --replace - Replace dependencies instead of adding to existing ones.
ynh_add_app_dependencies () {
# Declare an array to define the options of this helper.
local legacy_args=pr
declare -Ar args_array=( [p]=package= [r]=replace)
local package
local replace
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
replace=${replace:-0}
local current_dependencies=""
if [ $replace -eq 0 ]
then
local dep_app=${app//_/-} # Replace all '_' by '-'
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
then
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
fi
current_dependencies=${current_dependencies// | /|}
fi
ynh_install_app_dependencies "${current_dependencies}${package}"
}
# Install packages from an extra repository properly.
#
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
# | arg: -r, --repo - Complete url of the extra repository.
# | arg: -p, --package - The packages to install from this extra repository
# | arg: -k, --key - url to get the public key.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_install_extra_app_dependencies () {
# Declare an array to define the options of this helper.
local legacy_args=rpkn
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
local repo
local package
local key
local name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
key=${key:-0}
# Set a key only if asked
if [ -n "$key" ]
then
key="--key=$key"
fi
# Add an extra repository for those packages
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
# Install requested dependencies from this extra repository.
ynh_add_app_dependencies --package="$package"
# Remove this extra repository after packages are installed
ynh_remove_extra_repo --name=$app
}
# Add an extra repository correctly, pin it and get the key.
#
# [internal]
#
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
# | arg: -r, --repo - Complete url of the extra repository.
# | arg: -k, --key - url to get the public key.
# | arg: -p, --priority - Priority for the pin
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
ynh_install_extra_repo () {
# Declare an array to define the options of this helper.
local legacy_args=rkpna
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
local repo
local key
local priority
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
append=${append:-0}
key=${key:-0}
priority=${priority:-}
if [ $append -eq 1 ]
then
append="--append"
wget_append="tee -a"
else
append=""
wget_append="tee"
fi
# Split the repository into uri, suite and components.
# Remove "deb " at the beginning of the repo.
repo="${repo#deb }"
# Get the uri
local uri="$(echo "$repo" | awk '{ print $1 }')"
# Get the suite
local suite="$(echo "$repo" | awk '{ print $2 }')"
# Get the components
local component="${repo##$uri $suite }"
# Add the repository into sources.list.d
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
# Pin the new repo with the default priority, so it won't be used for upgrades.
# Build $pin from the uri without http and any sub path
local pin="${uri#*://}"
pin="${pin%%/*}"
# Set a priority only if asked
if [ -n "$priority" ]
then
priority="--priority=$priority"
fi
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
# Get the public key for the repo
if [ -n "$key" ]
then
mkdir -p "/etc/apt/trusted.gpg.d"
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
fi
# Update the list of package with the new repo
ynh_package_update
}
# Remove an extra repository and the assiociated configuration.
#
# [internal]
#
# usage: ynh_remove_extra_repo [--name=name]
# | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_remove_extra_repo () {
# Declare an array to define the options of this helper.
local legacy_args=n
declare -Ar args_array=( [n]=name= )
local name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
ynh_secure_remove "/etc/apt/preferences.d/$name"
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
# Update the list of package to exclude the old repo
ynh_package_update
}
# Add a repository.
#
# [internal]
#
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
# | arg: -u, --uri - Uri of the repository.
# | arg: -s, --suite - Suite of the repository.
# | arg: -c, --component - Component of the repository.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
#
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
# uri suite component
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
#
ynh_add_repo () {
# Declare an array to define the options of this helper.
local legacy_args=uscna
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
local uri
local suite
local component
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
append=${append:-0}
if [ $append -eq 1 ]
then
append="tee -a"
else
append="tee"
fi
mkdir -p "/etc/apt/sources.list.d"
# Add the new repo in sources.list.d
echo "deb $uri $suite $component" \
| $append "/etc/apt/sources.list.d/$name.list"
}
# Pin a repository.
#
# [internal]
#
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
# | arg: -i, --pin - Filter for the pin.
# | arg: -p, --priority - Priority for the pin
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
#
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
#
ynh_pin_repo () {
# Declare an array to define the options of this helper.
local legacy_args=pirna
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
local package
local pin
local priority
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
package="${package:-*}"
priority=${priority:-50}
name="${name:-$app}"
append=${append:-0}
if [ $append -eq 1 ]
then
append="tee -a"
else
append="tee"
fi
mkdir -p "/etc/apt/preferences.d"
echo "Package: $package
Pin: $pin
Pin-Priority: $priority
" \
| $append "/etc/apt/preferences.d/$name"
}

View file

@ -1,78 +0,0 @@
#!/bin/bash
# Install another version of php.
#
# usage: ynh_install_php --phpversion=phpversion [--package=packages]
# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3
# | arg: -p, --package - Additionnal php packages to install
ynh_install_php () {
# Declare an array to define the options of this helper.
local legacy_args=vp
declare -Ar args_array=( [v]=phpversion= [p]=package= )
local phpversion
local package
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
package=${package:-}
# Store php_version into the config of this app
ynh_app_setting_set $app php_version $phpversion
if [ "$phpversion" == "7.0" ]
then
ynh_die "Do not use ynh_install_php to install php7.0"
fi
# Store the ID of this app and the version of php requested for it
echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version"
# Add an extra repository for those packages
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version
# Install requested dependencies from this extra repository.
# Install php-fpm first, otherwise php will install apache as a dependency.
ynh_add_app_dependencies --package="php${phpversion}-fpm"
ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package"
# Set php7.0 back as the default version for php-cli.
update-alternatives --set php /usr/bin/php7.0
# Pin this extra repository after packages are installed to prevent sury of doing shit
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version
ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append
# Advertise service in admin panel
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
}
ynh_remove_php () {
# Get the version of php used by this app
local phpversion=$(ynh_app_setting_get $app php_version)
if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ]
then
if [ "$phpversion" == "7.0" ]
then
ynh_print_err "Do not use ynh_remove_php to install php7.0"
fi
return 0
fi
# Remove the line for this app
sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version"
# If no other app uses this version of php, remove it.
if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version"
then
# Purge php dependences for this version.
ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common"
# Remove the service from the admin panel
yunohost service remove php${phpversion}-fpm
fi
# If no other app uses alternate php versions, remove the extra repo for php
if [ ! -s "/etc/php/ynh_app_version" ]
then
ynh_secure_remove /etc/php/ynh_app_version
fi
}