mirror of
https://github.com/YunoHost-Apps/galette_ynh.git
synced 2024-09-03 18:36:28 +02:00
112 lines
4.1 KiB
Bash
112 lines
4.1 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
timezone="$(cat /etc/timezone)"
|
|
|
|
#=================================================
|
|
# 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
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="config.inc.php.$database" --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"
|
|
|
|
#=================================================
|
|
# 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"
|
|
ynh_local_curl "/installer.php" "install_type=i"
|
|
if [ $database == "pgsql" ]
|
|
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_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"
|
|
|
|
#=================================================
|
|
# SECURE FILES AND DIRECTORIES
|
|
#=================================================
|
|
|
|
chown $app $install_dir/galette/config
|
|
chmod g+rwx $install_dir/galette/config
|
|
|
|
for folder in attachments cache exports files imports logs photos templates_c tempimages
|
|
do
|
|
chown $app $install_dir/galette/data/$folder
|
|
chmod g+rwx $install_dir/galette/data/$folder
|
|
done
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|