mirror of
https://github.com/YunoHost-Apps/dolibarr_ynh.git
synced 2024-09-03 18:35:53 +02:00
98 lines
3.5 KiB
Bash
98 lines
3.5 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
member=0
|
|
fpm_footprint="medium"
|
|
fpm_usage="medium"
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_script_progression --message="Storing installation settings..." --weight=2
|
|
|
|
ynh_app_setting_set --app="$app" --key="member" --value="$member"
|
|
ynh_app_setting_set --app="$app" --key="fpm_footprint" --value="$fpm_footprint"
|
|
ynh_app_setting_set --app="$app" --key="fpm_usage" --value="$fpm_usage"
|
|
|
|
#=================================================
|
|
# CREATE A MYSQL DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring $app's MySQL database..." --weight=1
|
|
|
|
ynh_mysql_execute_as_root --sql="ALTER DATABASE $db_name charset=utf8"
|
|
ynh_mysql_execute_as_root --database="$db_name" --sql="SET NAMES 'utf8' COLLATE 'utf8_general_ci'"
|
|
|
|
#=================================================
|
|
# 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 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
#=================================================
|
|
# PREPARE AND INSTALL APP
|
|
#=================================================
|
|
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="../conf/conf.php" --destination="$install_dir/htdocs/conf/conf.php"
|
|
|
|
chmod 644 "$install_dir/htdocs/conf/conf.php"
|
|
chown "$app:$app" "$install_dir/htdocs/conf/conf.php"
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated php-fpm config
|
|
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
|
|
|
# Create a dedicated nginx config
|
|
ynh_add_nginx_config
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate --logfile="$install_dir/documents/dolibarr.log"
|
|
|
|
#=================================================
|
|
# FINAL CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Final configuration of $app to create databases..." --weight=1
|
|
|
|
ynh_local_curl "/install/step2.php" \
|
|
"testpost=ok" \
|
|
"action=set"
|
|
|
|
ynh_script_progression --message="Configuring LDAP" --weight=1
|
|
|
|
# Populate the LDAP parameters
|
|
ynh_mysql_execute_file_as_root --database="$db_name" --file="../conf/sql/ldap.sql"
|
|
|
|
# Populate the database with YNH users.
|
|
ynh_mysql_execute_file_as_root --database="$db_name" --file="../conf/sql/ldap_user.sql"
|
|
|
|
if "php$phpversion" "$install_dir/scripts/user/sync_users_ldap2dolibarr.php" commitiferror --server=localhost -y; then
|
|
ynh_print_info --message="LDAP user update ok"
|
|
else
|
|
ynh_print_info --message="LDAP user update ended with error"
|
|
fi
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|