How do I makes glitch-soc ENV changes permanent?

Continuing the discussion from How do I add an additional setting to glith-soc:

I realized that updating .env.production for glitch-soc doesn’t persist after an upgrade. Is there a way to make ENV changes permanent?

My YunoHost server

Hardware: VPS bought online
YunoHost version: 11.0.7
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

You can:

  • Contribute to the package to add the settings in a config panel
  • Write your own post_app_upgrade hook:

Here an example for etherpad

# cat /etc/yunohost/hooks.d/post_app_upgrade/05-etherpad_mypads 
#!/bin/bash

source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME

if [[ "$app" == "etherpad_mypads" ]]; then
  ynh_write_var_in_file --file=/var/www/etherpad_mypads/settings.json --key=max --value=100 --after=importExportRateLimiting
  systemctl restart etherpad_mypads
fi

Do you mean the upgrade script does remove/overwrite it ?

Then you might have a look at Pixelfed upgrade script, I believe it is able to preserve the .env config file now.
ping @yalh76 that might give you some input about that.

Manual update or does the app make changes in this file to store settings?

Thanks for the information regarding options! Good to know! :smiley:

I’ll explore writing a script for this! :+1:

1 Like

I haven’t verified/recreated this issue, but from what I remember, here’s what happened: I updated the file .env.production - adding the setting for SINGLE_USER_MODE and this worked - and then some time later, glitch-soc had an update, so I updated it via the admin, and then the setting I added was no longer there (I think the file gets overwritten). :confused:

Thanks everyone for trying to help, I appreciate it! :smiley:

I faced similar issue with joomla package. Updating gets the settings file reset to default.
So I added two steps to the update script : backup the settings file to a temporary folder before the update, restore the settings file after the update.
You can check the update script of your app and try to make the same I did in the update script of joomla.
Here is the PR :

@jarod5001 This overwritten or not behaviour is a difficult question and it depends of the apps.

In several cases, it could be dangereous to not upgrade the file. So the apps don’t do exactly the same things related to that topic. Some of them replace the file only if it hasn’t been modified. Other display a warning explaining the file has been replaced.

My opinion is no one of these solutions is good, the good way should be to detect what has been changed and to reapply the settings. We could extend a bit the config panel mechanism to allow that, but it won’t cover all the settings only the most important.

An other solutions could be to use a 3 ways merge mechanism, but it could broke completely.

1 Like

Yes. It’s complicated. In my case, the joomla config file didn’t change since the first 4.0 release.
The best way is to have the script check for changes between every version update and add the new lines to the config file. I didn’t have time to search for a good way to achieve it.
May be a helper in this case would transform the process.

Another solution : backup the file in its folder (ex: create a copy configfile.bak) and overwrite it. Then the user is free to restore the backup or some of its components.
But it requires command line access and skills.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.