mirror of
https://github.com/YunoHost-Apps/garradin_ynh.git
synced 2024-09-03 18:36:17 +02:00
commit
b878e0603f
11 changed files with 133 additions and 94 deletions
|
@ -1,4 +1,8 @@
|
|||
; Test complet
|
||||
; pre-upgrade
|
||||
if [ "$FROM_COMMIT" == "04e1730ff642a2e48dfb533b2136fe90f9eaf133" ]; then
|
||||
chmod -R o-rwx /var/www/garradin
|
||||
fi
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
|
@ -12,6 +16,7 @@
|
|||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=7205455e0a806a49c48c6d2f005d80d1b74a3355
|
||||
upgrade=1 from_commit=04e1730ff642a2e48dfb533b2136fe90f9eaf133
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
change_url=1
|
||||
|
@ -20,5 +25,8 @@ Email=
|
|||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=7205455e0a806a49c48c6d2f005d80d1b74a3355
|
||||
name=Merge pull request #55 from yunohost-bot/issue-and-pr-template
|
||||
name=Previous version
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||
; commit=04e1730ff642a2e48dfb533b2136fe90f9eaf133
|
||||
name=Version 1.0.6~ynh1
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||
|
|
9
conf/config.local.php
Normal file
9
conf/config.local.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* NE PAS MODIFIER CE FICHIER. Il est regénéré automatiquement à chaque mise à jour de Yunohost
|
||||
*
|
||||
* Pour ajouter vos configurations personnalisées, rendez-vous dans le fichier config.local.user.php
|
||||
*/
|
||||
require '__FINALPATH__/config.local.yunohost.php';
|
||||
require '__FINALPATH__/config.local.user.php';
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Activer la possibilité de faire une mise à jour semi-automatisée
|
||||
* depuis fossil.kd2.org.
|
||||
*
|
||||
* Si mis à TRUE, alors un bouton sera accessible depuis le menu "Configuration"
|
||||
* pour faire une mise à jour en deux clics.
|
||||
*
|
||||
* Il est conseillé de désactiver cette fonctionnalité si vous ne voulez pas
|
||||
* permettre à un utilisateur de casser l'installation !
|
||||
*
|
||||
* Défaut : true, ajout pour l'environement Yunohost défaut : false
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
|
||||
const ENABLE_UPGRADES = false;
|
||||
|
||||
/**
|
||||
* Commande de création de PDF
|
||||
*
|
||||
* Commande qui sera exécutée pour créer un fichier PDF à partir d'un HTML.
|
||||
* Si laissé non spécifié (ou NULL), Garradin essaiera de détecter une solution entre
|
||||
* PrinceXML, Chromium, wkhtmltopdf ou weasyprint.
|
||||
*
|
||||
* %1$s sera remplacé par le chemin du fichier HTML, et %2$s par le chemin du fichier PDF.
|
||||
*
|
||||
* Exemple : chromium --headless --print-to-pdf=%2$s %1$s
|
||||
*
|
||||
* Défaut : null
|
||||
*/
|
||||
//const PDF_COMMAND = 'wkhtmltopdf %2$s %1$s';
|
||||
|
||||
/**
|
||||
* Clé de licence
|
||||
*
|
||||
* Cette clé permet de débloquer certaines fonctionnalités dans des extensions officielles.
|
||||
*
|
||||
* Pour l'obtenir il faut se créer un compte sur Garradin.eu
|
||||
* et faire une contribution financière.
|
||||
* La clé apparaîtra ensuite en dessous des informations
|
||||
* de l'association dans la page "Mon abonnement Garradin.eu".
|
||||
*
|
||||
* Il faut recopier cette clé dans le fichier config.local.php
|
||||
* dans la constante CONTRIBUTOR_LICENSE.
|
||||
*
|
||||
* Merci de ne pas essayer de contourner cette licence et de contribuer au
|
||||
* financement de notre travail :-)
|
||||
*/
|
||||
//const CONTRIBUTOR_LICENSE = 'XXXXX';
|
13
conf/config.local.user.php
Normal file
13
conf/config.local.user.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Ce fichier représente un exemple des constantes de configuration
|
||||
* disponibles pour Garradin.
|
||||
*
|
||||
* Modifiez ce fichier à votre guise, il ne sera pas modifié lors des mises à jour.
|
||||
* Consultez le fichier config.dist.php pour disposer d'un exemple.
|
||||
*
|
||||
*/
|
||||
|
||||
// Nécessaire pour situer les constantes dans le bon namespace
|
||||
namespace Garradin;
|
55
conf/config.local.yunohost.php
Normal file
55
conf/config.local.yunohost.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* NE PAS MODIFIER CE FICHIER!
|
||||
*
|
||||
* Ce fichier sera mis à jour à chaque nouvelle version de Yunohost
|
||||
*
|
||||
* Pour ajouter vos configurations personnalisées, rendez-vous dans le fichier config.local.user.php
|
||||
*
|
||||
*/
|
||||
|
||||
// Nécessaire pour situer les constantes dans le bon namespace
|
||||
namespace Garradin;
|
||||
|
||||
/**
|
||||
* Clé secrète, doit être unique à chaque instance de Garradin
|
||||
*
|
||||
* Ceci est utilisé afin de sécuriser l'envoi de formulaires
|
||||
* (protection anti-CSRF).
|
||||
*
|
||||
* Cette valeur peut être modifiée sans autre impact que la déconnexion des utilisateurs
|
||||
* actuellement connectés.
|
||||
*
|
||||
* Si cette constante n'est définie, Garradin ajoutera automatiquement
|
||||
* une valeur aléatoire dans le fichier config.local.php.
|
||||
*/
|
||||
|
||||
const SECRET_KEY = '__SECRET_KEY__';
|
||||
|
||||
/**
|
||||
* Adresse URI de la racine du site Garradin
|
||||
* (doit se terminer par un slash)
|
||||
*
|
||||
* Défaut : découverte automatique à partir de SCRIPT_NAME
|
||||
*/
|
||||
|
||||
const WWW_URI = '__PATH__/';
|
||||
|
||||
/**
|
||||
* Activer la possibilité de faire une mise à jour semi-automatisée
|
||||
* depuis fossil.kd2.org.
|
||||
*
|
||||
* Si mis à TRUE, alors un bouton sera accessible depuis le menu "Configuration"
|
||||
* pour faire une mise à jour en deux clics.
|
||||
*
|
||||
* Il est conseillé de désactiver cette fonctionnalité si vous ne voulez pas
|
||||
* permettre à un utilisateur de casser l'installation !
|
||||
*
|
||||
* Défaut : true, ajout pour l'environement Yunohost défaut : false
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
|
||||
const ENABLE_UPGRADES = false;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
YNH_PHP_VERSION="7.4"
|
||||
|
||||
extra_php_dependencies="php${YNH_PHP_VERSION}-sqlite3 php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-cli"
|
||||
extra_php_dependencies="php${YNH_PHP_VERSION} php${YNH_PHP_VERSION}-sqlite3 php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-cli"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -20,6 +20,7 @@ new_domain=$YNH_APP_NEW_DOMAIN
|
|||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
secret_key=$(ynh_string_random --length=50)
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
|
@ -81,15 +82,7 @@ then
|
|||
path_url="$new_path"
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# change the config.local.conf
|
||||
if [ $change_path -eq 1 ] && [ "$new_path" == "/" ]; then
|
||||
ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php"
|
||||
elif [ $change_path -eq 1 ] && [ "$old_path" == "/" ]; then
|
||||
ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php"
|
||||
elif [ $change_path -eq 1 ]; then
|
||||
ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php"
|
||||
ynh_add_config --template="config.local.yunohost.php" --destination="$final_path/config.local.yunohost.php"
|
||||
fi
|
||||
|
||||
# Change the domain for NGINX
|
||||
|
|
|
@ -32,7 +32,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
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
|
||||
|
@ -76,25 +76,21 @@ ynh_add_nginx_config
|
|||
ynh_script_progression --message="Configuring PHP-FPM..." --weight=5
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
ynh_install_app_dependencies "$extra_php_dependencies"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=5
|
||||
|
||||
# copy config.dist.php creating config.local.php
|
||||
cp -a $final_path/config.dist.php $final_path/config.local.php
|
||||
# create a key for the secret key CSFR;
|
||||
key=$(ynh_string_random --length=50)
|
||||
# edit config.local.php
|
||||
ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php"
|
||||
if [ "$path_url" == "/" ]; then
|
||||
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php"
|
||||
else
|
||||
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
|
||||
fi
|
||||
ynh_replace_string --match_string="//const ENABLE_UPGRADES = true;" --replace_string="const ENABLE_UPGRADES = false;" --target_file="$final_path/config.local.php"
|
||||
# create a key for the secret key CSFR:
|
||||
secret_key=$(ynh_string_random --length=50)
|
||||
|
||||
# Install configuration files
|
||||
ynh_add_config --template="config.local.php" --destination="$final_path/config.local.php"
|
||||
ynh_add_config --template="config.local.yunohost.php" --destination="$final_path/config.local.yunohost.php"
|
||||
ynh_add_config --template="config.local.user.php" --destination="$final_path/config.local.user.php"
|
||||
|
||||
# Permissions on files and directories
|
||||
chmod -R o-rwx "$final_path"
|
||||
|
@ -103,7 +99,9 @@ find "$final_path" -type d -exec chmod 550 {} +
|
|||
find "$final_path" -type f -exec chmod 440 {} +
|
||||
find "$final_path/data" -type d -exec chmod 770 {} +
|
||||
find "$final_path/data" -type f -exec chmod 660 {} +
|
||||
chmod 660 "$final_path/config.local.php"
|
||||
chmod 440 "$final_path/config.local.php"
|
||||
chmod 440 "$final_path/config.local.yunohost.php"
|
||||
chmod 660 "$final_path/config.local.user.php"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
|
|
|
@ -41,10 +41,13 @@ ynh_remove_nginx_config
|
|||
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
|
||||
|
||||
# Remove the app dependencies installed along with php-fpm
|
||||
# ynh_remove_app_dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
# Remove the dedicated PHP-FPM config
|
||||
ynh_remove_fpm_config --package="$extra_php_dependencies"
|
||||
# NB: If there is a warning because it cannot locate the garradin-ynh-deps package, ignore
|
||||
# It's just it has been removed before.
|
||||
# https://github.com/YunoHost/yunohost/blob/509ba1e8a28e0be598aa0617eda06669b7b0f1d8/data/helpers.d/php#L284-L287
|
||||
ynh_remove_fpm_config 2> >(grep -v 'WARNING E: Unable to locate package')
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -35,7 +35,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|||
ynh_script_progression --message="Validating restoration parameters..." --weight=4
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -71,7 +71,9 @@ find "$final_path" -type d -exec chmod 550 {} +
|
|||
find "$final_path" -type f -exec chmod 440 {} +
|
||||
find "$final_path/data" -type d -exec chmod 770 {} +
|
||||
find "$final_path/data" -type f -exec chmod 660 {} +
|
||||
chmod 660 "$final_path/config.local.php"
|
||||
chmod 440 "$final_path/config.local.php"
|
||||
chmod 440 "$final_path/config.local.yunohost.php"
|
||||
chmod 660 "$final_path/config.local.user.php"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
|
@ -80,7 +82,8 @@ ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=6
|
|||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
ynh_install_app_dependencies "$extra_php_dependencies"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -18,8 +18,9 @@ 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) || ynh_die "This path already contains a folder"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die --message="This path already contains a folder"
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
secret_key=$(ynh_string_random --length=50)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -91,13 +92,14 @@ fi
|
|||
|
||||
if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1
|
||||
then
|
||||
ynh_script_progression --message="Upgrading upgrade to 0.9.8" --weight=5
|
||||
ynh_script_progression --message="Upgrading to 0.9.8" --weight=5
|
||||
# Download, check integrity, uncompress and patch the source from 0.9.8.src
|
||||
ynh_setup_source --keep="config.local.php" --dest_dir="$final_path" --source_id="0.9.8"
|
||||
# Set permissions on app files
|
||||
ynh_system_user_create --username=$app
|
||||
ynh_add_nginx_config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
ynh_install_app_dependencies "$extra_php_dependencies"
|
||||
ynh_add_fpm_config
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
ynh_script_progression --message="restore data..." --weight=10
|
||||
|
||||
|
@ -138,13 +140,14 @@ fi
|
|||
|
||||
if ynh_compare_current_package_version --comparison lt --version 1.1.0~ynh1
|
||||
then
|
||||
ynh_script_progression --message="Upgrading upgrade to 1.1.0" --weight=5
|
||||
ynh_script_progression --message="Upgrading to 1.1.0" --weight=5
|
||||
# Download, check integrity, uncompress and patch the source from 0.9.8.src
|
||||
ynh_setup_source --keep="config.local.php" --dest_dir="$final_path" --source_id="1.1.0"
|
||||
# Set permissions on app files
|
||||
ynh_system_user_create --username=$app
|
||||
ynh_add_nginx_config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
ynh_install_app_dependencies "$extra_php_dependencies"
|
||||
ynh_add_fpm_config
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
ynh_script_progression --message="restore data..." --weight=10
|
||||
|
||||
|
@ -196,7 +199,7 @@ ynh_script_progression --message="Upgrading source files..." --weight=5
|
|||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --keep="config.local.php" --dest_dir="$final_path"
|
||||
ynh_setup_source --keep="config.local.user.php" --dest_dir="$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -213,7 +216,8 @@ ynh_add_nginx_config
|
|||
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
ynh_install_app_dependencies "$extra_php_dependencies"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=======================================================
|
||||
# backup bdd, squelettes directory and config.local.php
|
||||
|
@ -255,9 +259,13 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=5
|
||||
|
||||
ynh_add_config --template="config.local.release.php" --destination="$final_path/config.local.release.php"
|
||||
if ynh_compare_current_package_version --comparison lt --version 1.1.15~ynh1; then
|
||||
ynh_add_config --template="config.local.user.php" --destination="$final_path/config.local.user.php"
|
||||
fi
|
||||
|
||||
echo -e "\n require 'config.local.release.php;'" >> $final_path/config.local.php
|
||||
ynh_add_config --template="config.local.php" --destination="$final_path/config.local.php"
|
||||
ynh_add_config --template="config.local.yunohost.php" --destination="$final_path/config.local.yunohost.php"
|
||||
# NOTE: Don't overwrite config.local.user.php
|
||||
|
||||
# Permissions on files and directories
|
||||
chmod -R o-rwx "$final_path"
|
||||
|
@ -266,8 +274,9 @@ find "$final_path" -type d -exec chmod 550 {} +
|
|||
find "$final_path" -type f -exec chmod 440 {} +
|
||||
find "$final_path/data" -type d -exec chmod 770 {} +
|
||||
find "$final_path/data" -type f -exec chmod 660 {} +
|
||||
chmod 660 "$final_path/config.local.php"
|
||||
chmod 660 "$final_path/config.local.release.php"
|
||||
chmod 440 "$final_path/config.local.php"
|
||||
chmod 440 "$final_path/config.local.yunohost.php"
|
||||
chmod 660 "$final_path/config.local.user.php"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
@ -282,7 +291,6 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
ynh_script_progression --message="Finalise upgrade" --weight=1
|
||||
|
||||
ynh_local_curl "/admin/index.php"
|
||||
chmod 440 "$final_path/config.local.php"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Add table
Reference in a new issue