diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf index 57a545d..e4aa0f8 100644 --- a/conf/extra_php-fpm.conf +++ b/conf/extra_php-fpm.conf @@ -1,10 +1,7 @@ ; Additional php.ini defines, specific to this pool of workers. ; Common values to change to increase file upload limit -php_admin_value[upload_max_filesize] = 50M -php_admin_value[post_max_size] = 50M ; Other common parameters php_admin_value[max_execution_time] = 1600 php_admin_value[max_input_time] = 300 -php_admin_value[memory_limit] = 256M diff --git a/conf/nginx.conf b/conf/nginx.conf index eae8d07..e8853c1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -12,7 +12,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/manifest.toml b/manifest.toml index 395e748..2fe90e4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -21,7 +21,8 @@ code = "https://github.com/Dolibarr/dolibarr" cpe = "cpe:2.3:a:dolibarr:dolibarr" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = true @@ -99,6 +100,7 @@ ram.runtime = "150M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index feab25c..8945fb4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,41 +1,28 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= upgrade_dolibarr() { - ynh_setup_source --source_id="$source_id" --dest_dir="$install_dir" --full_replace=1 \ + ynh_setup_source --source_id="$source_id" --dest_dir="$install_dir" --full_replace \ --keep="htdocs/conf/conf.php htdocs/install/install.forced.php" - chmod -R o-rwx "$install_dir" - chown -R "$app:www-data" "$install_dir" - + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir" # Remove the lock if it exists lock=$install_dir/documents/install.lock if [ -f "$lock" ]; then - ynh_secure_remove --file="$lock" + ynh_safe_rm "$lock" fi pushd "$install_dir/htdocs/install/" - "php$phpversion" upgrade.php "$current_version" "$new_version" - ynh_exec_fully_quiet sleep 5 + "php$php_version" upgrade.php "$current_version" "$new_version" + sleep 5 - "php$phpversion" upgrade2.php "$current_version" "$new_version" - ynh_exec_fully_quiet sleep 5 + "php$php_version" upgrade2.php "$current_version" "$new_version" + sleep 5 - "php$phpversion" step5.php "$current_version" "$new_version" - ynh_exec_fully_quiet sleep 5 + "php$php_version" step5.php "$current_version" "$new_version" + sleep 5 popd } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 97adcfe..1abe61b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -8,36 +8,33 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info --message="Backing up the MySQL database..." +ynh_print_info "Backing up the MySQL database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 01dd48c..9c09826 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -10,20 +10,20 @@ source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # UPDATE conf file #================================================= -ynh_replace_string --target_file="$install_dir/htdocs/conf/conf.php" \ - --match_string="$old_domain$old_path" \ - --replace_string="$new_domain$new_path" +ynh_replace --file="$install_dir/htdocs/conf/conf.php" \ + --match="$old_domain$old_path" \ + --replace="$new_domain$new_path" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 4c2c303..90016d4 100644 --- a/scripts/install +++ b/scripts/install @@ -7,83 +7,84 @@ source _common.sh source /usr/share/yunohost/helpers +ynh_app_setting_set --key=php_memory_limit --value=256M + #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_script_progression --message="Configuring $app's MySQL database..." --weight=1 +ynh_script_progression "Configuring $app's MySQL database..." -ynh_mysql_execute_as_root --sql="ALTER DATABASE $db_name charset=utf8" +ynh_mysql_db_shell <<< "ALTER DATABASE $db_name charset=utf8" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --source_id="main" --dest_dir="$install_dir" mkdir -p "$install_dir/documents" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" chmod go-w "$install_dir/documents" #================================================= # PREPARE AND INSTALL APP #================================================= -ynh_script_progression --message="Adding $app's configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration file..." -ynh_add_config --template="install.forced.php" --destination="$install_dir/htdocs/install/install.forced.php" +ynh_config_add --template="install.forced.php" --destination="$install_dir/htdocs/install/install.forced.php" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_config_add_phpfpm # Create a dedicated nginx config -ynh_add_nginx_config +ynh_config_add_nginx # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="$install_dir/documents/dolibarr.log" +ynh_config_add_logrotate "$install_dir/documents/dolibarr.log" #================================================= # SETUP APPLICATION WITH CURL #================================================= -ynh_script_progression --message="Configuring $app ..." --weight=1 +ynh_script_progression "Configuring $app ..." # Create necessary files touch "$install_dir/htdocs/conf/conf.php" # Set right permissions for curl install -chown -R "$app:" "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "$install_dir" ynh_local_curl "/install/fileconf.php" "testpost=ok" -ynh_exec_fully_quiet sleep 5 +sleep 5 ynh_local_curl "/install/step1.php" "testpost=ok" "action=set" -ynh_exec_fully_quiet sleep 5 +sleep 5 ynh_local_curl "/install/step2.php" "testpost=ok" "action=set" -ynh_exec_fully_quiet sleep 5 +sleep 5 ynh_local_curl "/install/step4.php" "testpost=ok" "action=set" -ynh_exec_fully_quiet sleep 5 +sleep 5 # Generate a random password for the admin user (will be ignored because of LDAP) -password=$(ynh_string_random 8) +password=$(ynh_string_random --length=8) ynh_local_curl "/install/step5.php" "testpost=ok" "action=set" "pass=$password" "pass_verif=$password" -ynh_exec_fully_quiet sleep 5 +sleep 5 # Setup HTTP auth in conf -ynh_replace_string --target_file="$install_dir/htdocs/conf/conf.php" \ - --match_string="dolibarr_main_authentication='dolibarr'" \ - --replace_string="dolibarr_main_authentication='http'" +ynh_replace --file="$install_dir/htdocs/conf/conf.php" \ + --match="dolibarr_main_authentication='dolibarr'" \ + --replace="dolibarr_main_authentication='http'" # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$install_dir/htdocs/conf/conf.php" +ynh_store_file_checksum "$install_dir/htdocs/conf/conf.php" chmod 644 "$install_dir/htdocs/conf/conf.php" # Set permissions on app files @@ -93,28 +94,28 @@ if [ ! -f "$install_dir/documents/install.lock" ]; then chmod 440 "$install_dir/documents/install.lock" fi -chown -R "$app:www-data" "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir" chown -R "$app:" "$install_dir/documents" #================================================= # SETUP LDAP #================================================= -ynh_script_progression --message="Configuring LDAP for $app..." --weight=1 +ynh_script_progression "Configuring LDAP for $app..." # Populate the LDAP parameters -ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < ../conf/sql/ldap.sql +ynh_mysql_db_shell < ../conf/sql/ldap.sql # Populate the database with YNH users. -ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < ../conf/sql/ldap_user.sql +ynh_mysql_db_shell < ../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" +if "php$php_version" "$install_dir/scripts/user/sync_users_ldap2dolibarr.php" commitiferror --server=localhost -y; then + ynh_print_info "LDAP user update ok" else - ynh_print_info --message="LDAP user update ended with error" + ynh_print_info "LDAP user update ended with error" fi #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index eadb498..f7f50dd 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,16 +10,16 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the dedicated nginx config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove the dedicated php-fpm config -ynh_remove_fpm_config +ynh_config_remove_phpfpm # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate #================================================= # REMOVE OLD FILES @@ -27,17 +27,17 @@ ynh_remove_logrotate # Delete old static pool.d conf old_php_version=7.0 if [ -f "/etc/php/$old_php_version/fpm/pool.d/$app.conf" ]; then - ynh_secure_remove --file="/etc/php/$old_php_version/fpm/pool.d/$app.conf" + ynh_safe_rm "/etc/php/$old_php_version/fpm/pool.d/$app.conf" fi # Remove a directory securely -ynh_secure_remove --file="/etc/$app" +ynh_safe_rm "/etc/$app" # Remove the log files -ynh_secure_remove --file="/var/log/$app" +#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index b16dcb1..b1787cd 100755 --- a/scripts/restore +++ b/scripts/restore @@ -11,48 +11,47 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:www-data" "$install_dir" +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir" chmod 644 "$install_dir/htdocs/conf/conf.php" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +ynh_script_progression "Restoring the MySQL database..." -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql +ynh_mysql_db_shell < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." # Restore the file first, so it can have a backup if different -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" # Recreate a dedicated php-fpm config -ynh_add_fpm_config --phpversion="$phpversion" +ynh_config_add_phpfpm -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +ynh_script_progression "Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service="php$php_version-fpm" --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index f182b7a..2a9c21f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,49 +7,51 @@ source _common.sh source /usr/share/yunohost/helpers +ynh_app_setting_set_default --key=php_memory_limit --value=256M + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # If fpm_footprint doesn't exist, create it if [ -z "${fpm_footprint:-}" ]; then fpm_footprint=medium - ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint +#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint fi # If fpm_usage doesn't exist, create it if [ -z "${fpm_usage:-}" ]; then fpm_usage=medium - ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage +#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage fi # Delete existing ini configuration file (backward compatibility) if [ -f /etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini ]; then - ynh_secure_remove --file=/etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini + ynh_safe_rm /etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini fi if [ -n "${version:-}" ]; then - ynh_app_setting_delete --app=$app --key="version" + ynh_app_setting_delete --key="version" fi charset=$(mysql -ss -N -e "SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = '$db_name'") if [ "$charset" != "utf8" ]; then - ynh_print_info --message="Changing Database charset to utf8" - ynh_mysql_execute_as_root --sql="ALTER DATABASE $db_name charset=utf8" + ynh_print_info "Changing Database charset to utf8" + ynh_mysql_db_shell <<< "ALTER DATABASE $db_name charset=utf8" ynh_local_curl "/install/repair.php" "force_utf8_on_tables=confirmed" - ynh_exec_fully_quiet sleep 5 + sleep 5 fi #================================================= # MAKE SEQUENTIAL UPGRADES FROM EACH MAJOR # VERSION TO THE NEXT ONE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=60 +ynh_script_progression "Upgrading source files..." # Sort --version-sort cdécembrean handle underscore in versions numbers mapfile -t main_versions < <( - ynh_read_manifest --manifest_key="resources.sources | keys[]" | grep "main_" | sort --version-sort + ynh_read_manifest | keys[]" | grep "main_" | sort --version-sort ) current_version="$YNH_APP_CURRENT_VERSION" for version in "${main_versions[@]}"; do @@ -57,7 +59,7 @@ for version in "${main_versions[@]}"; do if dpkg --compare-versions "$current_version" ge "$new_version"; then continue fi - ynh_print_info --message="Upgrading app from $current_version to $new_version" + ynh_print_info "Upgrading app from $current_version to $new_version" source_id="$version" upgrade_dolibarr current_version="$new_version" @@ -66,18 +68,18 @@ done # Final upgrade to the final version new_version=$(ynh_app_upstream_version) source_id="main" -ynh_print_info --message="Upgrading app from $current_version to $new_version" +ynh_print_info "Upgrading app from $current_version to $new_version" upgrade_dolibarr -if "php$phpversion" "$install_dir/scripts/user/sync_users_ldap2dolibarr.php" commitiferror --server=localhost -y; then - ynh_print_info --message="LDAP user update ok" +if "php$php_version" "$install_dir/scripts/user/sync_users_ldap2dolibarr.php" commitiferror --server=localhost -y; then + ynh_print_info "LDAP user update ok" else - ynh_print_info --message="LDAP user update ended with error" + ynh_print_info "LDAP user update ended with error" fi -ynh_backup_if_checksum_is_different --file="$install_dir/htdocs/conf/conf.php" +ynh_backup_if_checksum_is_different "$install_dir/htdocs/conf/conf.php" # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$install_dir/htdocs/conf/conf.php" +ynh_store_file_checksum "$install_dir/htdocs/conf/conf.php" chmod 644 "$install_dir/htdocs/conf/conf.php" if [ ! -f "$install_dir/documents/install.lock" ]; then @@ -86,10 +88,9 @@ if [ ! -f "$install_dir/documents/install.lock" ]; then chmod 440 "$install_dir/documents/install.lock" fi -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:www-data" "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir" # mkdir -p "$data_dir" # chown -R $app: "$data_dir" # chmod go-w $data_dir @@ -97,16 +98,16 @@ chown -R "$app:www-data" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." -ynh_add_fpm_config +ynh_config_add_phpfpm -ynh_add_nginx_config +ynh_config_add_nginx -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]