1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dolibarr_ynh.git synced 2024-09-03 18:35:53 +02:00

More cleaning

This commit is contained in:
ericgaspar 2021-09-25 15:05:51 +02:00
parent ccc3f3f0bc
commit 01e5705c32
No known key found for this signature in database
GPG key ID: 574F281483054D44
2 changed files with 50 additions and 74 deletions

View file

@ -51,6 +51,14 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=member --value=$member ynh_app_setting_set --app=$app --key=member --value=$member
ynh_app_setting_set --app=$app --key=version --value=$(ynh_app_upstream_version "../manifest.json") ynh_app_setting_set --app=$app --key=version --value=$(ynh_app_upstream_version "../manifest.json")
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -80,30 +88,15 @@ ynh_setup_source --dest_dir="$final_path"
datadir=$final_path/documents datadir=$final_path/documents
touch $final_path/htdocs/conf/conf.php touch $final_path/htdocs/conf/conf.php
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM and install dependencies..." --weight=2 ynh_script_progression --message="Configuring PHP-FPM and install dependencies..." --weight=2
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config --usage=medium --footprint=medium --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" ynh_add_fpm_config --usage=medium --footprint=medium --package="$extra_php_dependencies"
# Used by ynh_add_nginx_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
# If phpversion doesn't exist, create it
if [ -z "$phpversion" ]; then
phpversion="$YNH_PHP_VERSION"
fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -117,6 +110,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# PREPARE AND INSTALL APP # PREPARE AND INSTALL APP
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/install.forced.php" --destination="$final_path/htdocs/install/install.forced.php" ynh_add_config --template="../conf/install.forced.php" --destination="$final_path/htdocs/install/install.forced.php"

View file

@ -38,23 +38,25 @@ phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion)
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=11
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
else
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -79,24 +81,24 @@ if [ -z "$fpm_usage" ]; then
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi fi
# If phpversion doesn't exist, create it # Cleaning legacy permissions
if [ -z "$phpversion" ]; then if ynh_legacy_permissions_exists; then
phpversion="$YNH_PHP_VERSION" ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission "public_space"; then
ynh_permission_create --permission "public_space" --url "/public/" --allowed "visitors"
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=11 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Backup the current version of the app # Create a dedicated user (if not existing)
ynh_backup_before_upgrade ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -120,34 +122,26 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
# If php has changed, remove the old fpm config file # If php has changed, remove the old fpm config file
if [ "$phpversion" != $YNH_PHP_VERSION ] # if [ "$phpversion" != $YNH_PHP_VERSION ]
then # then
ynh_backup_if_checksum_is_different --file="/etc/php/$phpversion/fpm/pool.d/$app.conf" # ynh_backup_if_checksum_is_different --file="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_secure_remove --file="/etc/php/$phpversion/fpm/pool.d/$app.conf" # ynh_secure_remove --file="/etc/php/$phpversion/fpm/pool.d/$app.conf"
if [ -f /etc/php/$phpversion/fpm/conf.d/20-$app.ini ]; then # if [ -f /etc/php/$phpversion/fpm/conf.d/20-$app.ini ]; then
ynh_secure_remove --file="/etc/php/$phpversion/fpm/conf.d/20-$app.ini" # ynh_secure_remove --file="/etc/php/$phpversion/fpm/conf.d/20-$app.ini"
fi # fi
ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload # ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload
phpversion="$YNH_PHP_VERSION" # phpversion="$YNH_PHP_VERSION"
fi # fi
# Recreate a dedicated PHP-FPM config # Recreate a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint --package="$extra_php_dependencies" ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --package="$extra_php_dependencies"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -213,7 +207,6 @@ then
then then
ynh_permission_update --permission="main" --remove="visitors" ynh_permission_update --permission="main" --remove="visitors"
fi fi
fi fi
#================================================= #=================================================
@ -223,6 +216,7 @@ fi
ynh_backup_if_checksum_is_different --file="$final_path/htdocs/conf/conf.php" ynh_backup_if_checksum_is_different --file="$final_path/htdocs/conf/conf.php"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/htdocs/conf/conf.php" ynh_store_file_checksum --file="$final_path/htdocs/conf/conf.php"
chmod 644 "$final_path/htdocs/conf/conf.php"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -253,28 +247,16 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
chmod 644 "$final_path/htdocs/conf/conf.php"
mkdir -p "$datadir" mkdir -p "$datadir"
chown -R $app: "$datadir" chown -R $app: "$datadir"
chmod go-w $datadir chmod go-w $datadir
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
# Create the public space permission if needed
if ! ynh_permission_exists --permission "public_space"; then
ynh_permission_create --permission "public_space" --url "/public/" --allowed "visitors"
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT