huo-ju / photoprism-freebsd-port

The photoprism port for FreeBSD
BSD 2-Clause "Simplified" License
69 stars 15 forks source link

Respect defaults in photoprism.in #69

Closed tinsukE closed 5 months ago

tinsukE commented 5 months ago

I'm a lazy person that would like to use /usr/local/bin/photoprism from the command line without having to pass in all the args and paths already configured in /etc/rc.conf, so I was glad to find that I could put all the configuration in /etc/photoprism/defaults.yml: https://docs.photoprism.app/getting-started/config-files/defaults/

That works for calling /usr/local/bin/photoprism, but doesn't work for the rc.d script. Even though the port installation says it should, if I set photoprism_defaultsyaml: https://github.com/huo-ju/photoprism-freebsd-port/blob/main/files/pkg-message.in#L9-L11

The problem is that, although a defaults YAML file can be specified, the rc script actually overwrites some configurations to empty. Ex: --assets-path=${photoprism_assetspath} expands to --assets-path= and sets the path to empty, even if it is specified in your YAML configuration file (but not in /etc/rc.conf).

I could duplicate configurations between /etc/rc.conf and /etc/photoprism/defaults.yml, but I'd prefer to have the RC script always respect the defaults.

With the changes from this PR, one could create a /etc/photoprism/defaults.yml file with all the configuration they need and call /usr/local/bin/photoprism from the command line and have the rc script read the file and apply its settings with only photoprism_enable="YES" in their /etc/rc.conf.

I'm no SH/BASH wizard, I have tested my changes, but I suspect they could be simplified to something more idiomatic.

huo-ju commented 5 months ago

lgtm, Thanks!