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

* Apply example_ynh

* Fix melange-de-versions

https://forum.yunohost.org/t/melange-de-versions-de-moodle-detectees/19985

* Update manifest.json

* Auto-update README

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

* 4.0.2 (#71)

* 4.0.2

* Auto-update README

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

* Auto-update README

* Bullseye (#73)

* Update manifest.json

* Auto-update README

* Update upgrade

* Fix

* Auto-update README

* Auto-update README

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

* 4.0.3 (#74)

* 4.0.3

* Auto-update README

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

* 4.0.4

* Auto-update README

* 4.1.0 (#77)

* 4.1.0

* Auto-update README

* fix PHP

* Update config_panel.toml

* Update config_panel.toml

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

* Auto-update README

* 4.1.1

* Auto-update README

* Update extra_php-fpm.conf

* Update extra_php-fpm.conf

* Auto-update README

* Update manifest.json

* Update extra_php-fpm.conf

* Update _common.sh

* Version 2 (#80)

* v2

* Fix

* Auto-update README

* fix

* Fix

* Update tests.toml

* Update manifest.toml

* Update _common.sh

* Update upgrade

* Update upgrade

* Update manifest.toml

* fix

* upgrade: remove unused code

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>

* Update manifest.toml

---------

Co-authored-by: yalh76 <yalh@yahoo.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>
This commit is contained in:
Éric Gaspar 2023-03-02 16:32:11 +01:00 committed by GitHub
parent 3217d11c78
commit 5761526a7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 108 additions and 542 deletions

View file

@ -29,19 +29,6 @@ Moodle is widely used around the world by universities, schools, companies and a
![Screenshot of Moodle](./doc/screenshots/Moodle_2.0_on_Firefox_4.0.png)
## Disclaimers / important information
## Configuration
How to configure this app: by an admin panel.
## YunoHost specific features
#### Multi-user support
* Are LDAP and HTTP auth supported? **Yes**
* Can the app be used by multiple users? **Yes**
## Documentation and resources
* Official app website: <https://moodle.org/>

View file

@ -29,10 +29,6 @@ Moodle est largement utilisé dans le monde entier par les universités, les éc
![Capture décran de Moodle](./doc/screenshots/Moodle_2.0_on_Firefox_4.0.png)
## Avertissements / informations importantes
- Cette app est intégrée avec le LDAP / SSO de Yunohost
## Documentations et ressources
* Site officiel de lapp : <https://moodle.org/>

View file

@ -18,7 +18,7 @@ $CFG->dboptions = array(
);
$CFG->wwwroot = 'https://__DOMAIN__';
$CFG->dataroot = '__DATADIR__';
$CFG->dataroot = '__DATA_DIR__';
$CFG->admin = 'admin';
$CFG->directorypermissions = 02777;

View file

@ -18,7 +18,7 @@ $CFG->dboptions = array(
);
$CFG->wwwroot = 'https://__DOMAIN____PATH__';
$CFG->dataroot = '__DATADIR__';
$CFG->dataroot = '__DATA_DIR__';
$CFG->admin = 'admin';
$CFG->directorypermissions = 02777;

View file

@ -1 +1 @@
*/15 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINALPATH__/admin/cli/cron.php >/dev/null
*/15 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __INSTALL_DIR__/admin/cli/cron.php >/dev/null

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
alias __INSTALL_DIR__/;
index index.php;

View file

@ -1,10 +0,0 @@
## Configuration
How to configure this app: by an admin panel.
## YunoHost specific features
#### Multi-user support
* Are LDAP and HTTP auth supported? **Yes**
* Can the app be used by multiple users? **Yes**

View file

@ -1 +0,0 @@
- Cette app est intégrée avec le LDAP / SSO de Yunohost

View file

@ -1,64 +0,0 @@
{
"name": "Moodle",
"id": "moodle",
"packaging_format": 1,
"description": {
"en": "Online learning platform",
"fr": "Plateforme d'apprentissage en ligne"
},
"version": "4.1.1~ynh1",
"url": "https://moodle.org/",
"upstream": {
"license": "GPL-3.0-or-later",
"website": "https://moodle.org/",
"demo": "https://sandbox.moodledemo.net/",
"admindoc": "https://docs.moodle.org/400/en/Main_page",
"code": "https://github.com/moodle/moodle"
},
"license": "GPL-3.0-or-later",
"maintainer": {
"name": "Anmol Sharma",
"email": "anmol@datamol.org"
},
"requirements": {
"yunohost": ">= 11.1.11"
},
"multi_instance": true,
"services": [
"nginx",
"php8.0-fpm"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/moodle",
"default": "/moodle"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "admin",
"type": "user"
},
{
"name": "site_name",
"type": "string",
"ask": {
"en": "Choose a name for the site you want to create",
"fr": "Choisissez un nom pour le site que vous voulez créer"
},
"default": "moodle",
"example": "moodle"
}
]
}
}

65
manifest.toml Normal file
View file

@ -0,0 +1,65 @@
packaging_format = 2
id = "moodle"
name = "Moodle"
description.en = "Online learning platform"
description.fr = "Plateforme d'apprentissage en ligne"
version = "4.1.1~ynh2"
maintainers = ["Anmol Sharma"]
[upstream]
license = "GPL-3.0-or-later"
website = "https://moodle.org/"
demo = "https://sandbox.moodledemo.net/"
admindoc = "https://docs.moodle.org/400/en/Main_page"
code = "https://github.com/moodle/moodle"
[integration]
yunohost = ">= 11.1.12"
architectures = "all"
multi_instance = true
ldap = true
sso = true
disk = "50M"
ram.build = "2000M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/moodle"
[install.init_main_permission]
type = "group"
default = "visitors"
[install.admin]
type = "user"
[install.site_name]
ask.en = "Choose a name for the site you want to create"
ask.fr = "Choisissez un nom pour le site que vous voulez créer"
type = "string"
default = "moodle"
example = "moodle"
[resources]
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "postgresql php7.4-common php7.4-mbstring php7.4-curl php7.4-xmlrpc php7.4-soap php7.4-zip php7.4-gd php7.4-xml php7.4-intl php7.4-pgsql php7.4-ldap"
[resources.database]
type = "postgresql"

View file

@ -4,13 +4,6 @@
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.4"
# dependencies used by the app
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}-pgsql php${YNH_PHP_VERSION}-ldap"
pkg_dependencies="postgresql $php_dependencies"
#=================================================
# PERSONAL HELPERS
#=================================================

View file

@ -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

View file

@ -9,93 +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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# 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=1
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
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
@ -108,22 +27,15 @@ domain=${new_domain%/}
path=${new_path%/}
dir="__DIR__"
ynh_backup_if_checksum_is_different --file="$final_path/config.php"
ynh_backup_if_checksum_is_different --file="$install_dir/config.php"
if [ "$new_path" == "/" ]; then
ynh_add_config --template="../conf/config-domain.php" --destination="$final_path/config.php"
ynh_add_config --template="../conf/config-domain.php" --destination="$install_dir/config.php"
else
ynh_add_config --template="../conf/config-path.php" --destination="$final_path/config.php"
ynh_add_config --template="../conf/config-path.php" --destination="$install_dir/config.php"
fi
ynh_store_file_checksum --file="$final_path/config.php"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_store_file_checksum --file="$install_dir/config.php"
#=================================================
# END OF SCRIPT

View file

@ -9,95 +9,35 @@
source _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
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
site_name=$YNH_APP_ARG_SITE_NAME
app=$YNH_APP_INSTANCE_NAME
email=$(ynh_user_get_info --username=$admin --key=mail)
password=$(ynh_string_random --length=30)
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
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=admin --value=$admin
ynh_app_setting_set --app=$app --key=site_name --value=$site_name
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
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_exec_warn_less 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 POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=4
ynh_psql_test_if_first_run
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_psql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=6
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 -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
@ -106,7 +46,6 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# 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
@ -116,31 +55,15 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# SETUP APPLICATION
#=================================================
ynh_script_progression --message="Setting up the application..." --weight=19
php${phpversion} "$final_path/admin/cli/install.php" --wwwroot="https://${domain}${path_url%/}" --dataroot="$datadir" --dbtype='pgsql' --dbname="$db_name" --dbuser="$db_name" --dbpass="$db_pwd" --adminuser="$admin" --adminpass="$password" --adminemail="$email" --fullname="$site_name" --shortname="$site_name" --non-interactive --agree-license
php${phpversion} "$install_dir/admin/cli/install.php" --wwwroot="https://${domain}${path%/}" --dataroot="$data_dir" --dbtype='pgsql' --dbname="$db_name" --dbuser="$db_name" --dbpass="$db_pwd" --adminuser="$admin" --adminpass="$password" --adminemail="$email" --fullname="$site_name" --shortname="$site_name" --non-interactive --agree-license
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/config.php"
ynh_store_file_checksum "$install_dir/config.php"
#=================================================
# ACTIVATE LDAP SUPPORT
@ -160,11 +83,11 @@ ynh_psql_execute_as_root --database="$db_name" --sql="UPDATE public.mdl_config_p
# 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';"
php$phpversion "$final_path/admin/cli/purge_caches.php"
php$phpversion "$install_dir/admin/cli/purge_caches.php"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# ADD CRON JOB
@ -175,28 +98,6 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# 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=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -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 POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2
# 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..." --weight=1
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -67,14 +25,6 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=20
# 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
#=================================================
# SPECIFIC REMOVE
#=================================================
@ -85,16 +35,6 @@ ynh_script_progression --message="Removing various files..." --weight=2
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# 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
#=================================================

View file

@ -10,81 +10,24 @@
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 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
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=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
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..." --weight=1
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"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=3
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
chown -R $app:www-data "$data_dir"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -108,10 +51,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=47
ynh_psql_test_if_first_run
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================

View file

@ -9,26 +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)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
site_name=$(ynh_app_setting_get --app=$app --key=site_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
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
#=================================================
@ -36,21 +16,6 @@ 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=10
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -58,58 +23,35 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# If the admin is not defined, We can't upgrade this app
if [ -z "$admin" ]; then
if [ -z "${admin:-}" ]; then
ynh_die --message="This app can't be upgraded from a very old version of the package. Please remove and reinstall Moodle"
fi
# If the site_name is not defined
if [ -z "$site_name" ]; then
if [ -z "${site_name:-}" ]; then
site_name="YunoHost"
ynh_app_setting_set --app=$app --key=site_name --value=$site_name
fi
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
if [ -z "${fpm_footprint:-}" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
# If fpm_free_footprint doesn't exist, create it
if [ -z "$fpm_free_footprint" ]; then
if [ -z "${fpm_free_footprint:-}" ]; then
fpm_free_footprint=0
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
fi
# If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then
if [ -z "${fpm_usage:-}" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# If datadir doesn't exist, create it
if [ -z "$datadir" ]; then
datadir=$(ynh_app_setting_get --app=$app --key=data_path)
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
ynh_app_setting_delete --app=$app --key=data_path
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=4
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -122,31 +64,23 @@ then
tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir
cp -a "$final_path/config.php" "$tmpdir/config.php"
cp -a "$install_dir/config.php" "$tmpdir/config.php"
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="$install_dir"
# 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"
# Copy the admin saved settings from tmp directory to final path
cp -a "$tmpdir/config.php" "$final_path/config.php"
cp -a "$tmpdir/config.php" "$install_dir/config.php"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
@ -184,11 +118,11 @@ ynh_psql_execute_as_root --database="$db_name" --sql="UPDATE public.mdl_config_p
# 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';"
php${phpversion} "$final_path/admin/cli/purge_caches.php"
php${phpversion} "$install_dir/admin/cli/purge_caches.php"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# ADD CRON JOB
@ -199,15 +133,6 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

3
tests.toml Normal file
View file

@ -0,0 +1,3 @@
test_format = 1.0
[default]