1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/galette_ynh.git synced 2024-09-03 18:36:28 +02:00

Merge branch 'testing' into pr/21

This commit is contained in:
ericgaspar 2022-04-20 10:00:21 +02:00
commit 7cfd3cda69
No known key found for this signature in database
GPG key ID: 574F281483054D44
17 changed files with 354 additions and 160 deletions

View file

@ -3,7 +3,9 @@
domain="domain.tld"
path="/path"
is_public=1
password="strong-password"
admin="john"
password="1Strong-Password"
database="pgsql"
; Checks
pkg_linter=1
setup_sub_dir=1
@ -12,13 +14,17 @@
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=d05248ceeffca8401dea6ac14bf7af7096345cbe
upgrade=1 from_commit=d05248ceeffca8401dea6ac14bf7af7096345cbe
# 0.9.5.2~ynh1
upgrade=1 from_commit=3c3d7d56540e12245f45dc7c3b9334285ac475ca
backup_restore=1
multi_instance=1
change_url=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=d05248ceeffca8401dea6ac14bf7af7096345cbe
name=Merge pull request #14
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1

View file

@ -3,3 +3,5 @@ SOURCE_SUM=27aa1192180d49bb562f479dafddad0ed67cb819c5aaccc34d2e75741047d9e8
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

25
conf/config.inc.php.mysql Normal file
View file

@ -0,0 +1,25 @@
<?php
/*
This is an example for your configuration file,
read comments and replace the "blanks".
You can then copy the file in GALETTE_CONFIG_PATH/config.inc.php
$Id$
*/
/* choose your database engine, values : pgsql|mysql */
define("TYPE_DB", "mysql");
/* hostname for the database */
define("HOST_DB", "localhost");
/* tcp port for the database */
define("PORT_DB", "3306");
/* the username for the database */
define("USER_DB", "__DB_USER__");
/* password for the username define above */
define("PWD_DB", "__DB_PWD__");
/* the database name */
define("NAME_DB", "__DB_NAME__");
/* tables name prefix (default is galette_) */
define("PREFIX_DB", "galette_");
/* FIXME will disappear soon */
define("STOCK_FILES", "tempimages");

View file

@ -14,7 +14,7 @@ define("HOST_DB", "localhost");
/* tcp port for the database */
define("PORT_DB", "5432");
/* the username for the database */
define("USER_DB", "__DB_NAME__");
define("USER_DB", "__DB_USER__");
/* password for the username define above */
define("PWD_DB", "__DB_PWD__");
/* the database name */

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/galette/webroot/;
alias __FINALPATH__/galette/webroot/ ;
index index.html index.php;
@ -10,7 +10,6 @@ location __PATH__/ {
client_max_body_size 50M;
try_files $uri $uri/ @__APP__;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Galette is a membership management web application towards non profit organizations.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Outil de gestion d'adhérents et de cotisation en ligne pour associations

View file

@ -1,4 +0,0 @@
## Configuration
1. The app will require to complete the registration process after the instllation is complete by visiting the domain on which Galette is installed.
1. The Postgresql database credentials will be sent to the admin mail. Fill these details while doing the registration process.

View file

@ -1,4 +0,0 @@
## Configuration
1. Une fois l'installation terminée, l'application devra terminer le processus d'enregistrement en **visitant le domaine** sur lequel Galette est installé.
1. Les informations d'identification de la base de données Postgresql seront envoyées à **l'email admin**. Remplissez ces détails lors du processus d'inscription.

View file

@ -2,7 +2,7 @@
"name": "Galette",
"id": "galette",
"packaging_format": 1,
"description": {
"description": {
"en": "Membership management web application for non profit organizations",
"fr": "Outil de gestion d'adhérents et de cotisation en ligne pour associations"
},
@ -46,8 +46,25 @@
"help": {
"en": "If enabled, Galette will be accessible by people who do not have an account. This can be changed later via the webadmin.",
"fr": "Si cette case est cochée, Galette sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
},
},
"default": true
},
{
"name": "admin",
"type": "user"
},
{
"name": "password",
"type": "password"
},
{
"name": "database",
"type": "string",
"ask": {
"en": "Choose SQL databe you want"
},
"choices": ["pgsql", "mysql"],
"default": "pgsql"
}
]
}

View file

@ -7,57 +7,18 @@
# dependencies used by the app
YNH_PHP_VERSION="7.4"
pkg_dependencies="postgresql php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-curl"
pkg_dependencies="php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mysql"
pgsql_pkg_dependencies="postgresql php${YNH_PHP_VERSION}-pgsql"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
ynh_send_readme_to_admin() {
local app_message="${1:-...No specific information...}"
local recipients="${2:-root}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$app_message
---
Automatic diagnosis data from YunoHost
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
# Send the email to the recipients
echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -19,6 +20,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -26,6 +28,7 @@ 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)
database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -50,13 +53,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
#=================================================
# SPECIFIC BACKUP
#=================================================
@ -65,6 +61,19 @@ ynh_psql_dump_db --database="$db_name" > db.sql
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP THE SQL DATABASE
#=================================================
if [ $database == "pgsql" ]
then
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
else
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
fi
#=================================================
# END OF SCRIPT
#=================================================

121
scripts/change_url Normal file
View file

@ -0,0 +1,121 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
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..."
# 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
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# 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
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..."
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
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app"

116
scripts/install Executable file → Normal file
View file

@ -23,17 +23,21 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
timezone="$(cat /etc/timezone)"
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
database=$YNH_APP_ARG_DATABASE
app=$YNH_APP_INSTANCE_NAME
timezone="$(cat /etc/timezone)"
#=================================================
# 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 "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
@ -45,24 +49,22 @@ 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=database --value=$database
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=20
if [ $database == "pgsql" ]
then
pkg_dependencies="$pkg_dependencies $pgsql_pkg_dependencies"
fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -71,6 +73,25 @@ ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A SQL DATABASE
#=================================================
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
if [ $database == "pgsql" ]
then
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
else
ynh_script_progression --message="Creating a MySQL database..." --weight=2
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -80,9 +101,9 @@ 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"
chmod 750 $final_path
chmod -R o-rwx $final_path
chown -R $app:www-data $final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -97,18 +118,45 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CONFIGURE GALETTE
# SPECIFIC SETUP
#=================================================
ynh_script_progression --message="Configuring Galette..." --weight=1
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.inc.php.dist" --destination="$final_path/galette/config/config.inc.php"
ynh_add_config --template="../conf/config.inc.php.$database" --destination="$final_path/galette/config/config.inc.php"
chmod 400 "$final_path/galette/config/config.inc.php"
chown $app:$app "$final_path/galette/config/config.inc.php"
#=================================================
# GENERIC FINALIZATION
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Setuping application with CURL..."
# Set the app as temporarily public for curl call
ynh_script_progression --message="Configuring SSOwat..."
# Making the app public for curl
ynh_permission_update --permission="main" --add="visitors"
# Installation with curl
ynh_script_progression --message="Finalizing installation..."
ynh_local_curl "/installer.php" "install_permsok=1"
ynh_local_curl "/installer.php" "install_type=i"
ynh_local_curl "/installer.php" "install_dbtype=pgsql" "install_dbhost=localhost" "install_dbport=5432" "install_dbuser=$db_user" "install_dbpass=$db_pwd" "install_dbname=$db_name" "install_dbprefix=galette_"
ynh_local_curl "/installer.php" "install_dbperms_ok=1"
ynh_local_curl "/installer.php" "install_dbwrite_ok=1"
ynh_local_curl "/installer.php" "install_adminlogin=$admin" "install_adminpass=$password" "install_adminpass_verif=$password"
ynh_local_curl "/installer.php" "install_prefs_ok=1"
# Remove the public access
ynh_permission_update --permission="main" --remove="visitors"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@ -122,6 +170,8 @@ do
chmod g+rwx $final_path/galette/data/$folder
done
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
@ -135,9 +185,11 @@ ynh_use_logrotate
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
@ -148,30 +200,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message="Galette need you to finish the installation manually.
Please open "https://$domain/$path_url/installer.php" and finish the install process.
Database information you'll need:
Type: pgsql
Host: localhost
Port: 5432
User: "$db_name"
Password: "$db_pwd"
Name: "$db_name"
Important! Once done, please remember to run as root or with sudo:
Restrict the rights of the config file \`chmod -R 500 "$final_path/galette/config"\`
\`Remove the install file "$final_path/galette/install"\`
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/galette_ynh"
ynh_send_readme_to_admin "$message"
#=================================================
# END OF SCRIPT
#=================================================

38
scripts/remove Executable file → Normal file
View file

@ -21,22 +21,31 @@ port=$(ynh_app_setting_get --app=$app --key=port)
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)
database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# REMOVE THE POSTGRESQL DATABASE
# STANDARD REMOVE
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE THE SQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
if [ $database == "pgsql" ]
then
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
else
ynh_script_progression --message="Removing the MySQL database..." --weight=2
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
fi
#=================================================
# REMOVE APP MAIN DIR
@ -63,11 +72,12 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=3
ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -20,7 +20,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -29,8 +29,8 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
timezone="$(cat /etc/timezone)"
#=================================================
@ -39,14 +39,14 @@ timezone="$(cat /etc/timezone)"
ynh_script_progression --message="Validating restoration parameters..." --weight=2
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
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -76,6 +76,7 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# REINSTALL DEPENDENCIES
@ -83,16 +84,30 @@ ynh_add_fpm_config
ynh_script_progression --message="Reinstalling dependencies..." --weight=6
# Define and install dependencies
if [ $database == "pgsql" ]
then
pkg_dependencies="$pkg_dependencies $pgsql_pkg_dependencies"
fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE POSTGRESQL DATABASE
# RESTORE THE SQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
if [ $database == "pgsql" ]
then
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
else
ynh_script_progression --message="Restoring the MySQL database..." --weight=6
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
fi
#=================================================
# RESTORE USER RIGHTS

View file

@ -21,13 +21,15 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
timezone="$(cat /etc/timezone)"
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -45,6 +47,8 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -56,10 +60,10 @@ if [ -z "$db_name" ]; then
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# If db_name doesn't exist, create it
# If db_pwd doesn't exist, create it
if [ -z "$db_pwd" ]; then
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
fi
# If final_path doesn't exist, create it
@ -83,14 +87,14 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
mv "$final_path" "$final_path.old"
@ -107,9 +111,9 @@ then
ynh_secure_remove "$final_path.old"
fi
chmod 750 $final_path
chmod -R o-rwx $final_path
chown -R $app:www-data $final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -124,7 +128,12 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
if [ $database == "pgsql" ]
then
pkg_dependencies="$pkg_dependencies $pgsql_pkg_dependencies"
fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
@ -137,16 +146,6 @@ ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@ -161,6 +160,14 @@ done
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# RELOAD NGINX
#=================================================