diff --git a/check_process b/check_process index bb25a96..1491d01 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet auto_remove=1 ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" language="en" ; pre-install sudo yunohost tools update --apps diff --git a/scripts/install b/scripts/install index 055c420..ec13560 100644 --- a/scripts/install +++ b/scripts/install @@ -74,6 +74,14 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name +#================================================= +# 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" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -91,14 +99,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3 # Copy and set NGINX configuration ynh_add_nginx_config -#================================================= -# 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 #================================================ @@ -121,27 +121,14 @@ ynh_app_setting_set --app=$app --key=encryptkey --value="$encryptkey" # Copy and set AgenDAV configuration timezone=$(cat /etc/timezone) - caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path) caldav_url="https://${caldav_domain}${caldav_path%/}" - caldav_base_url="${caldav_url}${caldav_baseurl}" - conf_path="${final_path}/web/config/settings.php" -# cp ../conf/settings.php "$conf_path" - logdir=/var/log/$app -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_path" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$conf_path" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$conf_path" -ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path" -ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path" -ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_BASE_URL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path" +ynh_add_config --template="../conf/settings.php" --destination="$conf_path" #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE diff --git a/scripts/upgrade b/scripts/upgrade index 3a85e65..8d1eb85 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -91,6 +91,14 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -99,10 +107,10 @@ ynh_abort_if_errors if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..."0 + ynh_script_progression --message="Upgrading source files..." --weight=2 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="${final_path}/web/config/settings.php" fi #================================================= @@ -113,65 +121,14 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Copy and set NGINX configuration ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config ynh_add_fpm_config --package="$extra_php_dependencies" -#================================================= -# SPECIFIC SETUP -#================================================= -# CREATE SETTINGS.PHP -#================================================= -ynh_script_progression --message="Upgrading AgenDAV configuration..." --weight=2 - -# Generate random encryption key -encryptkey=$(ynh_app_setting_get --app=$app --key=encryptkey) - -# Copy and set AgenDAV configuration -timezone=$(cat /etc/timezone) - -caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain) -caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path) -caldav_url="https://${caldav_domain}${caldav_path%/}" - -caldav_base_url="${caldav_url}${caldav_baseurl}" - -conf_path="${final_path}/web/config/settings.php" - -logdir=/var/log/$app - -ynh_backup_if_checksum_is_different --file="$conf_path" - -cp ../conf/settings.php "$conf_path" - -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_path" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$conf_path" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$conf_path" -ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path" -ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path" -ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_BASE_URL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path" - -#================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE -#================================================= - -# ynh_store_file_checksum --file="$conf_path" - #================================================= # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) #=================================================