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

113 lines
4.1 KiB
Text
Raw Normal View History

2015-10-17 10:47:21 +02:00
#!/bin/bash
2018-02-27 22:35:57 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2018-02-27 22:35:57 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2018-02-27 22:35:57 +01:00
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2022-04-13 20:36:45 +02:00
timezone="$(cat /etc/timezone)"
2022-04-14 00:33:50 +02:00
#=================================================
2022-04-18 20:10:22 +02:00
# CREATE A SQL DATABASE
2022-04-14 00:33:50 +02:00
#=================================================
2023-11-11 14:14:26 +01:00
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
2023-11-11 14:32:11 +01:00
if [ $database == "postgresql" ]
2022-04-14 00:33:50 +02:00
then
2023-11-11 14:14:26 +01:00
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
2022-04-14 00:33:50 +02:00
else
2023-11-11 14:14:26 +01:00
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
2022-04-14 00:33:50 +02:00
fi
2018-02-27 22:35:57 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2021-06-15 22:16:38 +02:00
ynh_script_progression --message="Setting up source files..." --weight=1
2018-02-27 22:35:57 +01:00
# Download, check integrity, uncompress and patch the source from app.src
2023-11-11 14:01:42 +01:00
ynh_setup_source --dest_dir="$install_dir"
2021-01-05 23:31:12 +01:00
2023-11-11 14:01:42 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2018-02-27 22:35:57 +01:00
#=================================================
2023-11-11 14:37:54 +01:00
# SYSTEM CONFIGURATION
2018-02-27 22:35:57 +01:00
#=================================================
2023-11-11 14:37:54 +01:00
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
2015-10-17 10:47:21 +02:00
2022-04-13 20:36:45 +02:00
# Create a dedicated PHP-FPM config
2021-11-14 15:32:27 +01:00
ynh_add_fpm_config
2022-06-26 14:53:49 +02:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2023-11-11 14:14:26 +01:00
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
2021-01-05 23:55:50 +01:00
#=================================================
2022-04-13 20:36:45 +02:00
# SPECIFIC SETUP
2021-01-05 23:55:50 +01:00
#=================================================
2022-04-13 20:36:45 +02:00
# ADD A CONFIGURATION
2021-01-05 23:55:50 +01:00
#=================================================
2022-04-13 20:36:45 +02:00
ynh_script_progression --message="Adding a configuration file..." --weight=1
2021-01-05 23:55:50 +01:00
2023-11-11 14:14:26 +01:00
ynh_add_config --template="config.inc.php.$database" --destination="$install_dir/galette/config/config.inc.php"
2021-01-05 23:55:50 +01:00
2023-11-11 14:01:42 +01:00
chmod 400 "$install_dir/galette/config/config.inc.php"
chown $app:$app "$install_dir/galette/config/config.inc.php"
2022-04-13 20:36:45 +02:00
2018-02-27 22:35:57 +01:00
#=================================================
2022-04-13 22:15:12 +02:00
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Setuping application with CURL..."
# Installation with curl
ynh_script_progression --message="Finalizing installation..."
ynh_local_curl "/installer.php" "install_permsok=1"
2022-04-21 21:31:44 +02:00
ynh_local_curl "/installer.php" "install_type=i"
2023-11-11 14:32:11 +01:00
if [ $database == "postgresql" ]
2022-04-21 00:14:47 +02:00
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
2022-04-13 22:15:12 +02:00
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"
2018-02-27 22:35:57 +01:00
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
2023-11-11 14:01:42 +01:00
chown $app $install_dir/galette/config
chmod g+rwx $install_dir/galette/config
2021-07-22 15:58:43 +02:00
2021-07-22 14:48:40 +02:00
for folder in attachments cache exports files imports logs photos templates_c tempimages
do
2023-11-11 14:01:42 +01:00
chown $app $install_dir/galette/data/$folder
chmod g+rwx $install_dir/galette/data/$folder
2021-07-22 15:58:43 +02:00
done
2021-01-05 23:31:12 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last