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

remove db choice

This commit is contained in:
Éric Gaspar 2023-11-16 19:59:44 +01:00
parent 53c03f74aa
commit 201d67af8b
9 changed files with 10 additions and 117 deletions

View file

@ -1,25 +0,0 @@
<?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");

1
doc/PRE_UPGRADE.md Normal file
View file

@ -0,0 +1 @@
if you were using a mysql DB, the new version only supports postgres and you should migrate it manually before upgrading.

View file

@ -47,13 +47,6 @@ ram.runtime = "50M"
[install.password]
type = "password"
[install.database]
ask.en = "Choose SQL database you want"
ask.fr = "Choisissez la base de données SQL souhaitée"
type = "select"
choices = ["postgresql", "mysql"]
default = "postgresql"
[resources]
[resources.sources.main]
url = "https://github.com/galette/galette/releases/download/1.0.0rc2/galette-1.0.0-rc2-20231017-a030a93d5e.tar.bz2"
@ -68,13 +61,7 @@ ram.runtime = "50M"
main.url = "/"
[resources.apt]
packages = "php8.2-tidy, php8.2-intl, php8.2-mbstring, php8.2-xml, php8.2-gd, php8.2-curl"
packages = "postgresql, php8.2-tidy, php8.2-intl, php8.2-mbstring, php8.2-xml, php8.2-gd, php8.2-curl, php8.2-pgsql"
packages_from_raw_bash = """
if [[ "$database" == "mysql" ]]; then
echo "mariadb-server, php8.2-mysql"
elif [[ "$database" == "postgresql" ]]; then
echo "postgresql, postgresql-contrib, php8.2-pgsql"
fi
"""
[resources.database]
type = "postgresql"

View file

@ -44,15 +44,9 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP THE SQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
if [ $database == "postgresql" ]
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
ynh_psql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT

View file

@ -15,29 +15,6 @@ source /usr/share/yunohost/helpers
timezone="$(cat /etc/timezone)"
#=================================================
# CREATE A SQL DATABASE
#=================================================
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 [ $database == "postgresql" ]
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
#=================================================
@ -84,12 +61,7 @@ ynh_script_progression --message="Setuping application with CURL..."
ynh_script_progression --message="Finalizing installation..."
ynh_local_curl "/installer.php" "install_permsok=1"
ynh_local_curl "/installer.php" "install_type=i"
if [ $database == "postgresql" ]
then
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_"
else
ynh_local_curl "/installer.php" "install_dbtype=mysql" "install_dbhost=localhost" "install_dbport=3306" "install_dbuser=$db_user" "install_dbpass=$db_pwd" "install_dbname=$db_name" "install_dbprefix=galette_"
fi
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"

View file

@ -23,14 +23,6 @@ ynh_remove_nginx_config
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
if [ $database == "postgresql" ]
then
ynh_script_progression --message="Removing PostgreSQL database..." --weight=2
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
else
ynh_script_progression --message="Removing MySQL database..." --weight=2
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
fi
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -27,21 +27,11 @@ chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE THE SQL DATABASE
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
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)
if [ $database == "postgresql" ]
then
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
else
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
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE SYSTEM CONFIGURATIONS

View file

@ -29,20 +29,7 @@ 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 "$install_dir" "$install_dir.old"
ynh_setup_source --dest_dir="$install_dir" --keep="galette/config/config.inc.php galette/data galette/plugins"
# when running automatic tests, there is no config.inc.php
#if [ -e "$install_dir.old/galette/config/config.inc.php" ]; then
# cp "$install_dir.old/galette/config/config.inc.php" "$install_dir/galette/config/config.inc.php"
# cp -r "$install_dir.old/galette/data" "$install_dir/galette/data"
# cp -r "$install_dir.old/galette/plugins" "$install_dir/galette/plugins"
#fi
# delete temp directory
#ynh_secure_remove "$install_dir.old"
fi
chmod -R o-rwx "$install_dir"

View file

@ -6,13 +6,8 @@ test_format = 1.0
# Default args to use for install
# -------------------------------
args.database="postgresql"
# -------------------------------
# Commits to test upgrade from
# -------------------------------
[mysql_test]
only = ["install.subdir", "backup_restore", "upgrade" ]
args.database = "mysql"