Closed TooMuchBlue closed 3 years ago
Thanks for the really well justified suggestion. I agree this sounds useful and it should be quite easy to implement this.
@rnwood @TooMuchBlue I did a PR #877 for this, see comments about usage. Can you take a look and see if it matches your requirements. I ran a local test and it appears to do as you describe.
@jafin Thanks for taking this on. I like the looks of the code changes. As it turns out, I have a client to install this for in the next few days. I'll reply back soon.
While I was reviewing the changes, I had another look at the Configuration page (https://github.com/rnwood/smtp4dev/wiki/Configuration), which includes the sample appsettings.json. Here's a suggested rewrite for line 21 in the appsettings.json file that I think would be helpful. (Might as well update that too, right?)
// - {baseAppDataPath}/appsettings.json - If not specified using --baseappdatapath, then {baseAppDataPath} will be %APPDATA%/smtp4dev/ on Windows, or %XDG_CONFIG_HOME%/smtp4dev/ on non-Windows.
I may just take a shot at a few wording improvements throughout, if that's OK. (Developer, former copy editor.)
This started as a comment on #541 but I think it has merit on its own. (Plus, I thought the comment might not be seen.)
I would like to suggest a command-line option that provides a base path for all other path-based settings.
As a consultant, I find it very useful to deploy smtp4dev on a dev web server for each of my clients, running as a Windows service. I have my preferred/default configurations that are useful at every client, but the path where I install necessarily changes for each client.
I would like to be able to install like this:
The appsettings.json would already be configured with relative paths for the database (settings\database.db) and certs (settings\default.crt) as well as my preferred URL, port, message counts, etc.
If I want to load an updated version, I can stop the service, delete/unzip into the \code\ folder, then start up again. All the important settings live in the service command line or the \settings\ folder and are untouched.
This also prevents the need to grant myself access to the %APPDATA% folder for local system accounts which typically live under C:\Windows\System32\ServiceProfiles and require special permissions to access. ("You don't currently have permission to access this folder. Click Continue to permanently get access to this folder.")
The only piece that would need to vary for each client is the path to the exe and the value of --basePath, both of which are in the sc command.
I believe from reading other tickets that there are a couple of other settings that can only be specified on the command line. This change would be most useful if those settings could also be defined in appsettings.json.
I'm happy to brainstorm further if some of this doesn't fit your ideas for how it should work.