diff --git a/conf/default.env b/conf/default.env index 611ac40..1c3442e 100644 --- a/conf/default.env +++ b/conf/default.env @@ -11,6 +11,7 @@ GRIST_DATA_DIR=__DATA_DIR__/docs/ TYPEORM_DATABASE=__DATA_DIR__/home.db PORT=__PORT__ GRIST_DEFAULT_EMAIL=__ADMIN_EMAIL__ +GRIST_SESSION_SECRET=__SESSION_SECRET__ # Authentication GRIST_FORWARD_AUTH_HEADER=Email diff --git a/scripts/change_url b/scripts/change_url index 6096804..687c182 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,6 +33,8 @@ ynh_script_progression --message="Updating env configuration file..." --weight=1 domain="$new_domain" path="$new_path" admin_email=$(ynh_user_get_info --username=$admin --key=mail) +redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +session_secret=$(ynh_app_setting_get --app=$app --key=session_secret) ynh_add_config --template="default.env" --destination="$install_dir/default.env" #================================================= diff --git a/scripts/install b/scripts/install index 73eee63..625465c 100755 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,14 @@ source _common.sh source /usr/share/yunohost/helpers + +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + +session_secret=$(ynh_string_random --length=32) +ynh_app_setting_set --app=$app --key=session_secret --value=$session_secret + #================================================= # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 0fcbbda..6113c1c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source _common.sh source /usr/share/yunohost/helpers redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) - +session_secret=$(ynh_app_setting_get --app=$app --key=session_secret) upgrade_type=$(ynh_check_app_version_changed) @@ -23,6 +23,15 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= + +if [ -z "$session_secret" ]; then + session_secret=$(ynh_string_random --length=32) + ynh_app_setting_set --app=$app --key=session_secret --value=$session_secret +fi + #================================================= # UPGRADE DEPENDENCIES #=================================================