diff --git a/conf/settings.php b/conf/settings.php index 9173926..141bdb0 100644 --- a/conf/settings.php +++ b/conf/settings.php @@ -20,9 +20,9 @@ $app['proxies'] = []; // Database settings $app['db.options'] = [ - 'dbname' => '__DBNAME__', - 'user' => '__DBUSER__', - 'password' => '__DBPASS__', + 'dbname' => '__DB_NAME__', + 'user' => '__DB_USER__', + 'password' => '__DB_PWD__', 'host' => 'localhost', 'driver' => 'pdo_mysql' ]; @@ -31,7 +31,7 @@ $app['db.options'] = [ $app['csrf.secret'] = '__ENCRYPTKEY__'; // Log path -$app['log.path'] = '__LOGDIR__/'; +$app['log.path'] = '/var/log/__APP__/'; // Base URL $app['caldav.baseurl'] = '__CALDAV_BASEURL__'; diff --git a/scripts/install b/scripts/install index 657d863..4682de3 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,8 @@ language=$YNH_APP_ARG_LANGUAGE app=$YNH_APP_INSTANCE_NAME +encryptkey=$(ynh_string_random --length=24) + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -68,6 +70,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=encryptkey --value="$encryptkey" #================================================= # STANDARD MODIFICATIONS @@ -144,23 +147,12 @@ 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_baseurl="${caldav_url}${caldav_baseurl}" -conf_path="${final_path}/web/config/settings.php" -cp ../conf/settings.php "$conf_path" +dir=dir +ynh_add_config --template="../conf/settings.php" --destination="${final_path}/web/config/settings.php" -logdir=/var/log/$app - -ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path" -ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path" -ynh_replace_string --match_string="__DBNAME__" --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_BASEURL__" --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_store_file_checksum --file="$conf_path" +ynh_store_file_checksum --file="${final_path}/web/config/settings.php" #================================================= # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) @@ -193,8 +185,8 @@ chmod -R 750 ${final_path}/web/config/ #================================================= ynh_script_progression --message="Configuring log rotation..." -mkdir -p $logdir -chown -R $app: $logdir +mkdir -p /var/log/$app +chown -R $app: /var/log/$app # Use logrotate to manage application logfile(s) ynh_use_logrotate diff --git a/scripts/upgrade b/scripts/upgrade index 78c102a..649d409 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,12 +21,12 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) language=$(ynh_app_setting_get --app=$app --key=language) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -110,7 +110,7 @@ then ynh_script_progression --message="Upgrading source files..." # 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="web/config/settings.php" fi chmod 750 "$final_path" @@ -146,38 +146,25 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=2 +# ynh_script_progression --message="Updating a configuration file..." --weight=2 -# Generate random encryption key -encryptkey=$(ynh_app_setting_get --app=$app --key=encryptkey) +# # Generate random encryption key +# encryptkey=$(ynh_app_setting_get --app=$app --key=encryptkey) -# Copy and set AgenDAV configuration -timezone=$(cat /etc/timezone) +# # 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_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_baseurl="${caldav_url}${caldav_baseurl}" -conf_path="${final_path}/web/config/settings.php" +# ynh_backup_if_checksum_is_different --file="${final_path}/web/config/settings.php" -ynh_backup_if_checksum_is_different --file="$conf_path" +# dir=dir +# ynh_add_config --template="../conf/settings.php" --destination="${final_path}/web/config/settings.php" -cp ../conf/settings.php "$conf_path" - -logdir=/var/log/$app - -ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path" -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path" -ynh_replace_string --match_string="__DBNAME__" --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_BASEURL__" --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_store_file_checksum --file="$conf_path" +# ynh_store_file_checksum --file="${final_path}/web/config/settings.php" #================================================= # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) @@ -210,8 +197,8 @@ chmod -R 750 ${final_path}/web/config/ #================================================= ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2 -mkdir -p $logdir -chown -R $app: $logdir +mkdir -p /var/log/$app +chown -R $app: /var/log/$app # Use logrotate to manage application logfile(s) ynh_use_logrotate --non-append