mirror of
https://github.com/YunoHost-Apps/galette_ynh.git
synced 2024-09-03 18:36:28 +02:00
commit
85e23f862b
10 changed files with 96 additions and 14 deletions
|
@ -5,6 +5,7 @@
|
||||||
is_public=1
|
is_public=1
|
||||||
admin="john"
|
admin="john"
|
||||||
password="1Strong-Password"
|
password="1Strong-Password"
|
||||||
|
database="pgsql"
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=1
|
setup_sub_dir=1
|
||||||
|
|
25
conf/config.inc.php.mysql
Normal file
25
conf/config.inc.php.mysql
Normal 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");
|
|
@ -56,6 +56,15 @@
|
||||||
{
|
{
|
||||||
"name": "password",
|
"name": "password",
|
||||||
"type": "password"
|
"type": "password"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "database",
|
||||||
|
"type": "string",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose SQL databe you want"
|
||||||
|
},
|
||||||
|
"choices": ["pgsql", "mysql"],
|
||||||
|
"default": "pgsql"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
YNH_PHP_VERSION="7.3"
|
YNH_PHP_VERSION="7.3"
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
|
pgsql_pkg_dependencies="postgresql php${YNH_PHP_VERSION}-pgsql"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
|
@ -28,6 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
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
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
@ -65,7 +66,12 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||||
|
|
||||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
if [ $database == "pgsql" ]
|
||||||
|
then
|
||||||
|
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||||
|
else
|
||||||
|
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
20
scripts/install
Executable file → Normal file
20
scripts/install
Executable file → Normal file
|
@ -25,6 +25,7 @@ path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
password=$YNH_APP_ARG_PASSWORD
|
||||||
|
database=$YNH_APP_ARG_DATABASE
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ 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=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
|
ynh_app_setting_set --app=$app --key=database --value=$database
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -56,6 +58,11 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=20
|
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
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -74,8 +81,15 @@ ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
ynh_psql_test_if_first_run
|
if [ $database == "pgsql" ]
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
then
|
||||||
|
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_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
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -114,7 +128,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
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"
|
chmod 400 "$final_path/galette/config/config.inc.php"
|
||||||
chown $app:$app "$final_path/galette/config/config.inc.php"
|
chown $app:$app "$final_path/galette/config/config.inc.php"
|
||||||
|
|
8
scripts/remove
Executable file → Normal file
8
scripts/remove
Executable file → Normal file
|
@ -21,6 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
database=$(ynh_app_setting_get --app=$app --key=database)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -38,7 +39,12 @@ ynh_remove_logrotate
|
||||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
|
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
if [ $database == "pgsql" ]
|
||||||
|
then
|
||||||
|
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
else
|
||||||
|
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
|
|
|
@ -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)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$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)
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
database=$(ynh_app_setting_get --app=$app --key=database)
|
||||||
timezone="$(cat /etc/timezone)"
|
timezone="$(cat /etc/timezone)"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -84,6 +84,11 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=6
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=6
|
||||||
|
|
||||||
# Define and install dependencies
|
# 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
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -91,9 +96,17 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
if [ $database == "pgsql" ]
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
then
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
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
|
||||||
|
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
|
# RESTORE USER RIGHTS
|
||||||
|
|
|
@ -21,8 +21,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$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)
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
database=$(ynh_app_setting_get --app=$app --key=database)
|
||||||
timezone="$(cat /etc/timezone)"
|
timezone="$(cat /etc/timezone)"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -59,10 +60,10 @@ if [ -z "$db_name" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
# If db_pwd doesn't exist, create it
|
||||||
if [ -z "$db_pwd" ]; then
|
if [ -z "$db_pwd" ]; then
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
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
|
fi
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If final_path doesn't exist, create it
|
||||||
|
@ -127,7 +128,12 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
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
|
# PHP-FPM CONFIGURATION
|
||||||
|
|
Loading…
Add table
Reference in a new issue