Open EWouters opened 7 years ago
Hey EWouters,
you also have to include the section for the config key, separated by a dot.
Please try to use --conf media.basedir=/music
I've updated the wiki to document this switch (see command line override): https://github.com/devsnd/cherrymusic/wiki/Setup-guide#user-content-manual-setup
I'll close the issue now, feel free to reopen it, if this does not work as expected. Have a nice day! 🍰
Hey, thanks for clarifying!
However, it does not seem to work as expected. I tried this:
root@raspberrypi:/# CHERRY_USER=pi
root@raspberrypi:/# CHERRY_PORT=7600
root@raspberrypi:/# sudo -u $CHERRY_USER python /opt/cherrymusic/cherrymusic --conf \
> media.basedir=/home/$CHERRY_USER/Music \
> server.port=$CHERRY_PORT \
> server.rootpath=/cherrymusic
[170316-15:09] Default configuration file written to '/home/pi/.config/cherrymusic/cherrymusic.conf'
==========================================================================
Welcome to CherryMusic 0.39.1!
To get this party started, you need to edit the configuration file, which
resides under the following path:
/home/pi/.config/cherrymusic/cherrymusic.conf
Then you can start the server and listen to whatever you like.
Have fun!
==========================================================================
root@raspberrypi:/# head -12 /home/$CHERRY_USER/.config/cherrymusic/cherrymusic.conf
[media]
; BASEDIR specifies where the media that should be served is located. It must be
; an absolute path, e.g. BASEDIR=/absolute/path/to/media.
;
; Links: If your operating system supports them, you can use symlinks directly in
; BASEDIR. Links to directories which contain BASEDIR will be ignored, just like
; all links not directly in, but in sublevels of BASEDIR. This is to guard against
; the adverse effects of link cycles.
;
basedir = None
So it says everything is ok, but the settings do not stick for some reason. Is this a bug?
Perhaps there is a problem here because there is no config file when I call the function?
edit: never mind, also when I call the command twice it doesn't work.
Yeah, you are right, it seems you cannot run CM without a config file (even an empty file) right now.
You could create a pull request that does not only check if the config file exists, but also allows to pass this test if the media.basedir
is set on the command line.
I could of course just edit the configuration file, but the build in method to set the config values seems more appealing. [EWouters]
The thing is, --conf
is not intended to permanently change the configuation value(s), it's a this-runtime-only override.
You could create a pull request that does not only check if the config file exists, but also allows to pass this test if the media.basedir is set on the command line. [devsnd]
A good solution would be to respect the command line setting for media.basedir (or any other settings) when the config file gets auto-created on first run, like I think it does with the --port
. Come to think of it, this is probably exactly what @EWouters expected to happen.
@tilboerner Correct, that is what I was expecting.
So I'm reinstalling my server and I'm tackling the same problem again. Do you recommend me to write a script that I can pass the configuration value(s) to which will edit them in the configuration file or would it be feasible to make a pull request to add a --update-conf KEY=VALUE [KEY=VALUE ...]]
argument to the cherrymusic command which will update any configuration value(s) in the (existing) configuration file?
Possible changes here, using this function? It seems this only needs to be a few lines of code. Am I very wrong here?
@EWouters I wouldn't write code to edit the config file. Editing is non-trivial, because users can add their own comments to it, and back when all this code got written, there was no simple way to update the configuration file with configparser
without losing those comments. For all I know, this might still be the case. Anyway, that's the reason why cherrymusic only ever writes to this file when it initially creates it.
Luckily, if I understand you correctly, this is exactly the moment you want to influence. You want to write the right configuration when the config file gets created. That should be doable. The files gets created using the configuration defaults. You can change that to also take into account the --conf
overrides from the command line. Here's some hints. (Hope you don't mind all the weird, old code. We were still figuring things out back then. :ghost:)
The whole things happens in the main script:
The command line config options are in ConfigOptions.configdict
at this point. You could pass them to create_default_config_file
as a parameter, and in that function merge that with the defaults before writing out the file. The browsersetup
handler does something very similar:
Don't mind the collect_errors
stuff, if you leave that out, merge errors will just get raised as exceptions.
You're right, it looks pretty straightforward. I'd be happy to receive a pull request, if you feel up to it. :)
Hi, i installed CherryMusic on my raspberry pi (raspbian) and it works great!
However, I am looking for the documentation on how to automate the setup. I want to find out what arguments I can set with
python /opt/cherrymusic/cherrymusic [--conf KEY=VALUE [KEY=VALUE ...]]
I tried the documentation here, but I can't get it to work.
I could of course just edit the configuration file, but the build in method to set the config values seems more appealing.
I tried:
without succes. Can anyone point me in the right direction? Thanks for the great work!