Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix environment variables #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

DtxdF
Copy link

@DtxdF DtxdF commented Nov 25, 2024

Some environment variables have no effect due to setting the variables to an empty string or a string at the beginning of the code.

Some environment variables have no effect due to setting the variables
to an empty string or a string at the beginning of the code.
@tschettervictor
Copy link
Owner

tschettervictor commented Nov 25, 2024

I prefer to keep those in place. It’s more for reference than anything else.

Some only are used under certain conditions. For example, with caddy CERT_EMAIL is only used with DNS_CERT and STANDALONE_CERT.

@tschettervictor
Copy link
Owner

To put it simply, every script shows every variable that it can possibly use (in alphabetical order) and these variables are meant to be edited and then executed.

@DtxdF
Copy link
Author

DtxdF commented Nov 26, 2024

If you set environment variables at the beginning of the code as you do currently, user-defined environment variables will have no effect, meaning that if a variable like HOST_NAME is required in the caddy app, the script cannot be executed correctly even if the variable is set, since shell variables take precedence over environment variables. If you need to have those variables as a reference, just use comments. See this Makejail:

https://github.com/AppJail-makejails/inventree/blob/main/scripts/admin.sh#L3

@tschettervictor
Copy link
Owner

That is correct. The scripts were designed to necessitate setting the variable within the actual install script.

These scripts are developed more toward simplicity and not automation.

I do see your point though.

@DtxdF
Copy link
Author

DtxdF commented Nov 26, 2024

Ah, I see, but remember that AppJail is an automation project, so if variables need to be changed from code, the Makejail is useless because people can't use settings other than the default ones.

I like your idea, but if this doesn't work, I'll unfortunately have to remove the Makejail from the organization.

Of course, this doesn't mean that your project can't be used with AppJail, it just means that the Makejail can't be used.

@tschettervictor
Copy link
Owner

A simple fix could be to source the environment after the given list, so users could still set them through a .env file.

@DtxdF
Copy link
Author

DtxdF commented Nov 26, 2024

This still excludes automation systems or, more specifically, jail managers, not just AppJail but any others that simply pass user-defined options through environment variables.

@DtxdF
Copy link
Author

DtxdF commented Nov 26, 2024

I think the best solution is to create a .env file in each application directory with the default values, but it is a mere reference (with comments explaining the options if you want). This file is not loaded by *-install.sh scripts. The user can load from his shell the .env file and run the *-install.sh script. This also does not exclude automation systems.

@tschettervictor
Copy link
Owner

tschettervictor commented Dec 3, 2024

So, would simply adding a .env file into each directory, and adding every value in there be enough?

That would require fetching both files then.

Then source that right off the bat.

How would that work with Appjail?

@DtxdF
Copy link
Author

DtxdF commented Dec 3, 2024

AppJail will not use that file. What I need is that the scripts do not overwrite the environment variables as it currently happens.

The .env file is for the users, but I only said that as a recommendation and it is not really necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants