mirror of
https://github.com/YunoHost-Apps/galette_ynh.git
synced 2024-09-03 18:36:28 +02:00
1ère tentative pour donner le choix du moteur de base de données.
- ajouté le choix dans manifest.toml, variable db_type - initialisation de la base de données dans install, car je ne sais pas si on peut mettre des tests n'importe où dans manifest (si oui, ce serait plus simple de le faire là - modifications en conséquence des appels yunohost-XXXX-sql dans install, backup et restore. - modifié install pour ne pas faire la copie du fichier de confog galette et laisser galette s'en charger. - modifier els instructions "curl" de install pour indiquer la bonne base de données et le bon port à galette. Utilisation d'une nouvelle variable locale db_port.
This commit is contained in:
parent
e0b5e6a375
commit
e2e2e54723
4 changed files with 72 additions and 11 deletions
|
@ -7,7 +7,7 @@ name = "Galette"
|
|||
description.en = "Membership management web application for non profit organizations"
|
||||
description.fr = "Outil de gestion d'adhérents et de cotisation en ligne pour associations"
|
||||
|
||||
version = "1.1.3~ynh1"
|
||||
version = "1.1.3~ynh2"
|
||||
|
||||
maintainers = []
|
||||
|
||||
|
@ -49,6 +49,22 @@ ram.runtime = "50M"
|
|||
[install.password]
|
||||
type = "password"
|
||||
|
||||
[install.db_type]
|
||||
ask.fr = "quel moteur de base de données souhaitez-vous"
|
||||
ask.en = "which data base engine do you prefer"
|
||||
help.fr : "Si vous ne savez pas quoi chosir, c'est que ça n'a aucune importance;"
|
||||
help.en = "If you don't know what to choose ... don't choose ;-) "
|
||||
type = "select"
|
||||
choices = ["mysql","postgresql"]
|
||||
default = "postgresql"
|
||||
|
||||
[install.tb_prefix]
|
||||
ask.fr = "voulez-vous utiliser un préfixe de table différent du défaut (galette_)?"
|
||||
ask.help = "si oui, veillez à le terminer par un _ ("souligné", "tiret du 8",...)
|
||||
type = "string"
|
||||
default = "galette_"
|
||||
|
||||
|
||||
[resources]
|
||||
[resources.sources.main]
|
||||
url = "https://www.galette.eu/download/galette-1.1.3.tar.bz2"
|
||||
|
@ -66,7 +82,19 @@ ram.runtime = "50M"
|
|||
main.url = "/"
|
||||
|
||||
[resources.apt]
|
||||
packages = "postgresql, php8.3-tidy, php8.3-intl, php8.3-mbstring, php8.3-xml, php8.3-gd, php8.3-curl, php8.3-pgsql"
|
||||
|
||||
packages = "php8.3-tidy, php8.3-intl, php8.3-mbstring, php8.3-xml, php8.3-gd, php8.3-curl"
|
||||
packages_from_raw_bash = """
|
||||
if [[ "$db_type" == "mysql" ]]; then
|
||||
echo "mariadb-server, php8.3-mysql"
|
||||
fi
|
||||
elif [[ "$db_type" == "postgresql" ]]; then
|
||||
echo "postgresql, php8.3-pgsql"
|
||||
fi
|
||||
"""
|
||||
|
||||
[resources.database]
|
||||
type = "postgresql"
|
||||
|
||||
# seulement une de ces lignes est possible. Peut-on faire ça par un test ? ou suffit-il d'initialiser la base dans le scriot d'install ?
|
||||
# [resources.database]
|
||||
# type = "mysql"
|
||||
# type = "postgresql"
|
||||
|
|
|
@ -36,7 +36,11 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
|||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
if [ $db_type == "mysql" ]; then
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
elif [ $db_type == "postgresql" ]; then
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -26,6 +26,23 @@ ynh_setup_source --dest_dir="$install_dir"
|
|||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# DATA BASE CREATION (not done via ressources_database
|
||||
#=================================================
|
||||
ynh_script_progression --message="icréating data base for $app..." --weight=1
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_string_random --length=30)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
|
||||
if [ $db_type == "mysql" ]; then
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
elif [ $db_type == "postgresql" ]; then
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -44,24 +61,32 @@ ynh_use_logrotate
|
|||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
# suppress to let galette create it it's proper way
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
#ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="config.inc.php" --destination="$install_dir/galette/config/config.inc.php"
|
||||
#ynh_add_config --template="config.inc.php" --destination="$install_dir/galette/config/config.inc.php"
|
||||
|
||||
chmod 400 "$install_dir/galette/config/config.inc.php"
|
||||
chown $app:$app "$install_dir/galette/config/config.inc.php"
|
||||
#chmod 400 "$install_dir/galette/config/config.inc.php"
|
||||
#chown $app:$app "$install_dir/galette/config/config.inc.php"
|
||||
|
||||
#=================================================
|
||||
# SETUP APPLICATION WITH CURL
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping application with CURL..."
|
||||
|
||||
if [ $db_type == "mysql" ]; then
|
||||
db_port="3306"
|
||||
elif [ $db_type == "postgresql" ]; then
|
||||
db_port="5432"
|
||||
fi
|
||||
|
||||
|
||||
# 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_dbtype=$db_type" "install_dbhost=localhost" "install_dbport=$db_port" "install_dbuser=$db_user" "install_dbpass=$db_pwd" "install_dbname=$db_name" "install_dbprefix=$tb_prefix"
|
||||
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"
|
||||
|
|
|
@ -31,7 +31,11 @@ chown -R $app:www-data "$install_dir"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
|
||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
if [ $db_type == "mysql" ]; then
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
elif [ $db_type == "postgresql" ]; then
|
||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
|
|
Loading…
Add table
Reference in a new issue