LinHES Forums http://forum.linhes.org/ |
|
squeezeboxserver (slimserver) - integration with runit http://forum.linhes.org/viewtopic.php?f=25&t=21992 |
Page 1 of 1 |
Author: | Golffies [ Mon Jan 24, 2011 3:12 pm ] |
Post subject: | squeezeboxserver (slimserver) - integration with runit |
Hi, Squeezeboxserver from Logitech (formerly slimserver from Slimdevices) is a perl script working with MySQL, and streaming audio files over IP to devices built by the vendor, such as the Squeezebox and the Transporter. Really a nice surprise that Squeezeboxserver is available as a package under LinHES. My backend is my NAS for video and audio files, then it makes sense to install Squeezeboxserver on it. Code: $ sudo pacman -Qi squeezeboxserver Name : squeezeboxserver Version : 7.4.1-1 URL : http://www.slimdevices.com/pi_features.html Licenses : GPL Groups : None Provides : None Depends On : None Optional Deps : None Required By : None Conflicts With : None Replaces : None Installed Size : 142072.00 K Packager : LinHESDev@knoppmyth.net Architecture : i686 Build Date : Sun 21 Mar 2010 10:27:52 PM CET Install Date : Mon 24 Jan 2011 02:05:08 PM CET Install Reason : Explicitly installed Install Script : Yes Description : Powerful streaming audio server from Slim Devices Installation completed like a charm. But further, how to tell runit about Squeezeboxserver as a new service to start up at boot ? Here is the file I created according to what I read from runit FAQ and I observed from LinHES architecture ; /etc/sv/squeezeboxserver/run: Code: #!/bin/sh
export TERM=linux . /etc/rc.conf . /etc/rc.d/functions stat_runit "Starting Squeezeboxserver" exec /home/squeezeboxserver/slimserver.pl Does the syntax look correct ? Furthermore, I created a symbolic link as /var/service/squeezeboxserver targeting at /etc/sv/squeezeboxserver/ As you can see, Squeezeboxserver package created a user 'squeezeboxserver' on the system, and dropped into its home folder the executable perl script. A message was displayed after installation completed, warning to run slimserver.pl with squeezeboxserver as a user (not from root or mythtv for instance). Does such a recommendation makes sense as the service is started as a child of runit ? If yes, how to instruct runit about that ? (I mean, to launch slimserver.pl from squeezeboxserver user ?) Thank you. |
Author: | bigtoedsloth [ Wed Jan 26, 2011 2:06 pm ] |
Post subject: | |
You could try making the last line of your run file look like Code: exec su squeezeboxserver -c /home/squeezeboxserver/slimserver.pl > /dev/null 2>&1
This will make the server script run as the squeezeboxserver and the last bit redirects output to null. You could make a log instead, but not 100% sure how to do that properly. |
Author: | Golffies [ Thu Feb 03, 2011 5:07 pm ] |
Post subject: | squeezeboxserver (slimserver) - integration with runit |
Thanks BigToe, I dropped your syntax into /etc/sv/squeezeboxserver/run, and observed the following: Being logged as a regular user : Code: $ sudo sv start squeezeboxserver timeout: down: squeezeboxserver: 1s, normally up, want up Being logged as squeezeboxserver : Code: $ sudo sv start squeezeboxserver We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. Password: squeezeboxserver is not in the sudoers file. This incident will be reported. Increasing squeezeboxserver's rights to sudo would be the wrong move. Moreover, I chose to remove the package squeezeboxserver 7.4.1-1 from the system, as the squeezeboxserver user created by that package was actually odd: its account was expired and had no shell defined. That's why I created from scratch a squeezeboxserver user with classical attributes (no-expiry date, /bin/bash shell, member of users' group, etc.), then I decompressed the tar archive of squeezeboxserver's up-to-date version into /home/squeezeboxserver/ folder. Code: $ tar -xzf squeezeboxserver-7.5.3.tgz $ ls -lah /home/squeezeboxserver/ total 54M drwxr-xr-x 16 squeezeboxserver users 4.0K 2011-02-03 00:12 . drwxr-xr-x 6 root root 4.0K 2011-02-02 23:39 .. -rw------- 1 squeezeboxserver users 533 2011-02-03 23:40 .bash_history -rw-r--r-- 1 squeezeboxserver users 16 2009-03-20 02:00 .bash_profile -rw-r--r-- 1 squeezeboxserver users 108 2009-03-20 02:00 .bashrc -rwxr-xr-x 1 squeezeboxserver users 273 2009-08-10 03:05 .xinitrc -rwxr-xr-x 1 squeezeboxserver users 100 2009-08-10 03:05 .xsession drwx------ 7 squeezeboxserver users 4.0K 2011-01-24 16:21 Bin drwx------ 51 squeezeboxserver users 4.0K 2011-01-24 16:16 CPAN drwxr-xr-x 10 squeezeboxserver users 4.0K 2011-02-03 23:22 Cache -rw------- 1 squeezeboxserver users 651 2011-01-24 16:16 Changelog.html -rw------- 1 squeezeboxserver users 1.1K 2011-01-24 16:16 Changelog1.html -rw------- 1 squeezeboxserver users 2.9K 2011-01-24 16:16 Changelog2.html -rw------- 1 squeezeboxserver users 48K 2011-01-24 16:16 Changelog3.html -rw------- 1 squeezeboxserver users 34K 2011-01-24 16:16 Changelog4.html -rw------- 1 squeezeboxserver users 79K 2011-01-24 16:16 Changelog5.html -rw------- 1 squeezeboxserver users 245K 2011-01-24 16:16 Changelog6.html -rw------- 1 squeezeboxserver users 114K 2011-01-24 16:16 Changelog7.html drwx------ 2 squeezeboxserver users 4.0K 2011-01-24 16:15 Firmware drwx------ 2 squeezeboxserver users 4.0K 2011-01-24 16:15 Graphics drwx------ 11 squeezeboxserver users 4.0K 2011-01-24 16:15 HTML drwx------ 2 squeezeboxserver users 4.0K 2011-01-24 16:16 IR -rw------- 1 squeezeboxserver users 3.9K 2011-01-24 16:16 Installation.txt -rw------- 1 squeezeboxserver users 20K 2011-01-24 16:16 License.de.txt -rw------- 1 squeezeboxserver users 20K 2011-01-24 16:16 License.es.txt -rw------- 1 squeezeboxserver users 20K 2011-01-24 16:16 License.fr.txt -rw------- 1 squeezeboxserver users 20K 2011-01-24 16:16 License.he.txt -rw------- 1 squeezeboxserver users 20K 2011-01-24 16:16 License.it.txt -rw------- 1 squeezeboxserver users 20K 2011-01-24 16:16 License.nl.txt -rw------- 1 squeezeboxserver users 20K 2011-01-24 16:16 License.txt drwxr-xr-x 2 squeezeboxserver users 4.0K 2011-02-03 00:27 Logs drwx------ 2 squeezeboxserver users 4.0K 2011-01-24 16:16 MySQL drwx------ 2 squeezeboxserver users 4.0K 2011-01-24 16:15 Plugins drwx------ 4 squeezeboxserver users 4.0K 2011-01-24 16:15 SQL drwx------ 16 squeezeboxserver users 4.0K 2011-01-24 16:15 Slim -rwx------ 1 squeezeboxserver users 6.9K 2011-01-24 16:16 cleanup.pl -rw------- 1 squeezeboxserver users 8.9K 2011-01-24 16:16 convert.conf drwx------ 13 squeezeboxserver users 4.0K 2011-01-24 16:15 lib -rw------- 1 squeezeboxserver users 836 2011-01-24 16:16 modules.conf drwxr-xr-x 3 squeezeboxserver users 4.0K 2011-02-03 23:22 prefs -rw------- 1 squeezeboxserver users 35 2011-01-24 16:21 revision.txt -rwxr-xr-x 1 squeezeboxserver users 11K 2011-01-24 16:16 scanner.pl -rwxr-xr-x 1 squeezeboxserver users 29K 2011-01-24 16:16 slimserver.pl -rw------- 1 squeezeboxserver users 163 2011-01-24 16:16 slimservice-convert.conf -rw------- 1 squeezeboxserver users 29K 2011-01-24 16:16 slimservice-strings.txt -rwx------ 1 squeezeboxserver users 19K 2011-01-24 16:16 slimservice.pl -rw-r--r-- 1 squeezeboxserver users 52M 2011-02-02 23:49 squeezeboxserver-7.5.3.tgz -rw------- 1 squeezeboxserver users 1.2M 2011-01-24 16:16 strings.txt -rw------- 1 squeezeboxserver users 4.5K 2011-01-24 16:16 types.conf At least, it gives me now the ability to log into squeezeboxserver user's account, and launch from there the slimserver.pl script; it is the best workaround I found until now: Code: $ su squeezeboxserver Password: $ /home/squeezeboxserver/slimserver.pl --daemon [11-02-03 23:14:22.3223] main::init (323) Starting Squeezebox Server (v7.5.3, r31792, Mon Jan 24 08:21:38 MST 2011) perl 5.010000 But I would love to learn more about syntax of sv's run files, in order to make the script managed from boot by runit. Final note: I dropped squeezeboxserver into /etc/ssh/sshd_config file: Code: DenyUsers mythtv squeezeboxserver Unfortunately, the barring is not enforced (I am able still to ssh into the system as squeezeboxserver, which I shouldn't). /etc/ssh/ folder contains another sshd_config file: Code: $ ls /etc/ssh/sshd_config*
-rw-r--r-- 1 root root 3.2K 2011-02-03 00:04 /etc/ssh/sshd_config -rw-r--r-- 1 root root 3.2K 2010-07-16 02:39 /etc/ssh/sshd_config.pacnew Is /etc/ssh/sshd_config deprecated under LinHES, and should /etc/ssh/sshd_config.pacnew be used instead ? |
Author: | Martian [ Fri Feb 04, 2011 10:55 am ] |
Post subject: | |
It looks like you need to add your squeezebox user to the sudoers list. look up the command visudo. I believe ssh_config is for the ssh command (ie. connecting to other ssh servers) where sshd_config is the actual server configuration. Try editing sshd_config. Also, be sure to restart the server in order to load the updated config (sometimes this doesn't end well if you restart sshd over ssh). Martian |
Author: | Golffies [ Fri Feb 04, 2011 4:02 pm ] |
Post subject: | squeezeboxserver (slimserver) - integration with runit |
Hi Martian, thanks for the reply. Martian wrote: I believe ssh_config is for the ssh command where sshd_config is the actual server configuration. Try editing sshd_config. You are right; nevertheless, my point here is about /etc/ssh/sshd_config and /etc/ssh/sshd_config.pacnew. My best guess is that when completing an update, Pacman does not override config files which have been customized and then differ from default, but writes their latest version with an additional .pacnew extension in their name. Am I right ? That being said, I don't know for sure what the updated software chooses to read now : the regular_conf (likely) or the regular_conf.pacnew ? Martian wrote: Also, be sure to restart the server in order to load the updated config (sometimes this doesn't end well if you restart sshd over ssh). True, I may have missed that. Martian wrote: It looks like you need to add your squeezebox user to the sudoers list. look up the command visudo.
On that, I fail to see your point. Why would you say that squeezeboxserver user shall sudo ? I found nowhere such a claim in squeezeboxserver doc or wiki. |
Author: | Martian [ Fri Feb 04, 2011 5:59 pm ] |
Post subject: | Re: squeezeboxserver (slimserver) - integration with runit |
Golffies wrote: Hi Martian, thanks for the reply. No problem - Glad to help! Golffies wrote: Martian wrote: I believe ssh_config is for the ssh command where sshd_config is the actual server configuration. Try editing sshd_config. You are right; nevertheless, my point here is about /etc/ssh/sshd_config and /etc/ssh/sshd_config.pacnew. My best guess is that when completing an update, Pacman does not override config files which have been customized and then differ from default, but writes their latest version with an additional .pacnew extension in their name. Am I right ? Exactly. Golffies wrote: That being said, I don't know for sure what the updated software chooses to read now : the regular_conf (likely) or the regular_conf.pacnew ? regular_conf Golffies wrote: Martian wrote: It looks like you need to add your squeezebox user to the sudoers list. look up the command visudo. On that, I fail to see your point. Why would you say that squeezeboxserver user shall sudo ? I found nowhere such a claim in squeezeboxserver doc or wiki. I'm a moron and missed where you said "Increasing squeezeboxserver's rights to sudo would be the wrong move. " opps.... |
Author: | bigtoedsloth [ Sat Feb 05, 2011 7:56 am ] |
Post subject: | Re: squeezeboxserver (slimserver) - integration with runit |
Golffies wrote: But I would love to learn more about syntax of sv's run files, in order to make the script managed from boot by runit. The run files are bash scripts run as root. So the syntax relies on the various commands run in the script, which you can find in the relevant man pages. If you run (as root)Code: su squeezeboxserver -c /home/squeezeboxserver/slimserver.pl and it does something sensible, then you can use that in the last line of the run file.Its important that the command is not interactive (it doesn't expect any input from stdin) and does not return control (i.e. don't include --daemon). Golffies wrote: Unfortunately, the barring is not enforced (I am able still to ssh into the system as squeezeboxserver, which I shouldn't). Did you restart the server (sudo sv restart sshd), or reboot? The config file will only be read when the service is started.
|
Author: | Golffies [ Sun Feb 06, 2011 9:05 am ] |
Post subject: | Re: squeezeboxserver (slimserver) - integration with runit |
Thanks BigToes, thanks Martian, bigtoedsloth wrote: Did you restart the server (sudo sv restart sshd), or reboot? The config file will only be read when the service is started. Both of you are right, of course. My mistake. A reboot later, squeezeboxserver user got ssh access denied. I would have better never opened the topic. bigtoedsloth wrote: the syntax relies on the various commands run in the script, which you can find in the relevant man pages
Understood. First, I have to blame myself. Runit could not have reported something better than an error message, as /etc/sv/squeezeboxserver/run was not executable ! I failed to check the permission earlier than today. Code: $ sudo sv start squeezeboxserver Fixed.timeout: down: squeezeboxserver: 1s, normally up, want up $ ls total 16K drwxr-xr-x 3 root root 4.0K 2011-01-24 18:31 . drwxr-xr-x 48 root root 4.0K 2011-02-05 21:53 .. -rw-r--r-- 1 root root 256 2011-02-06 14:53 run drwx------ 2 root root 4.0K 2011-02-06 14:54 supervise Code: $ sudo chmod u+x /etc/sv/squeezeboxserver/run $ ls /etc/sv/squeezeboxserver/run -rwxr--r-- 1 root root 256 2011-02-06 14:53 run That being written, well, the syntaxe you proposed made me move in the right direction: Code: $ cat /etc/sv/squeezeboxserver/run #!/bin/sh export TERM=linux . /etc/rc.conf . /etc/rc.d/functions stat_runit "Starting Squeezeboxserver" su squeezeboxserver -c /home/squeezeboxserver/slimserver.pl #exec 2>&1 #exec su squeezeboxserver /home/squeezeboxserver/slimserver.pl >/dev/null $ sudo sv start squeezeboxserver ok: run: squeezeboxserver: (pid 4857) 0s $ sudo sv status squeezeboxserver run: squeezeboxserver: (pid 4857) 327s $ pgrep -lu squeezeboxserver 21401 slimserver.pl 21405 mysqld 21406 mysqld 21407 mysqld 21408 mysqld 21409 mysqld 21410 mysqld 21412 mysqld 21413 mysqld 21414 mysqld 21415 mysqld 21417 mysqld But it is not yet perfect. Unfortunately, I am still unable to stop the daemon through runit: Code: $ sudo sv stop squeezeboxserver
ok: down: squeezeboxserver: 0s, normally up $ pgrep -lu squeezeboxserver 21401 slimserver.pl 21405 mysqld 21406 mysqld 21407 mysqld 21408 mysqld 21409 mysqld 21410 mysqld 21412 mysqld 21413 mysqld 21414 mysqld 21415 mysqld 21417 mysqld I had a look at /var/log/sv/current, but it is empty. To be continued, thanks to you... |
Author: | bigtoedsloth [ Sun Feb 06, 2011 1:15 pm ] |
Post subject: | |
It seems a bit odd to me that sv tells you that the process id is 4857, but psgrep says 21401. Are you sure that it wasn't already running before you did the sv up? |
Author: | tjc [ Sun Feb 06, 2011 1:45 pm ] |
Post subject: | |
Yeah, to clarify the situation I'd start with the following. - Set up some logging so you can see what is happening when the slimserver.pl script is run. Redirecting the output to /dev/null when you're trying to troubleshoot is driving blindfolded. Make sure the stderr is also captured. Put this in the sv script. - Before starting your experiments make sure that you kill any existing versions of the process: Code: pkill -9 slimserver.pl # hard kill, there can be only one! Server daemons often need particular resources, if they're not available, they fail. Another running instance may be consuming those resources. Without logging, errors like this are hidden so you can't tell what is going on. Do this manually, don't put it in the sv script. OBTW - you should also be using exec so that the PID in the /etc/sv/squeezeboxserver/supervise/pid matches your process. The runit sv command uses that PID to manage your daemon, and if it isn't right it's left talking to the wrong process. Here's what I'd put in that script: Code: #!/bin/sh
exec 2>&1 export TERM=linux . /etc/rc.conf . /etc/rc.d/functions stat_runit "Starting Squeezeboxserver" exec su squeezeboxserver -c /home/squeezeboxserver/slimserver.pl >/var/log/squeezeboxserver.log 2>&1 |
Author: | Golffies [ Mon Feb 07, 2011 3:48 am ] |
Post subject: | squeezeboxserver - locale |
Well, you saved my week, tjc Next time I fly to the States, I bring a champagne bottle for you. Code: $ sudo sv start squeezeboxserver ok: run: squeezeboxserver: (pid 4025) 1s $ pgrep -lu squeezeboxserver 4025 slimserver.pl 4052 mysqld 4053 mysqld 4054 mysqld 4055 mysqld 4056 mysqld 4057 mysqld 4059 mysqld 4060 mysqld 4061 mysqld 4062 mysqld 4064 mysqld $ sudo sv stop squeezeboxserver ok: down: squeezeboxserver: 0s, normally up $ pgrep -lu squeezeboxserver $ sudo sv start squeezeboxserver ok: run: squeezeboxserver: (pid 6717) 1s $ pgrep -lu squeezeboxserver 6717 slimserver.pl 6744 mysqld 6745 mysqld 6746 mysqld 6747 mysqld 6748 mysqld 6749 mysqld 6751 mysqld 6752 mysqld 6753 mysqld 6754 mysqld 6756 mysqld It works fine now ! bigtoedsloth wrote: It seems a bit odd to me that sv tells you that the process id is 4857, but psgrep says 21401. You made the point. I went through a few trials and errors, then wrote the whole message to the board; the first 4857 instance got copied & pasted from an earlier attempt, the second 21401 from a later one. I did not expected you would scrutinise so sharply what I wrote. Final point, the locale: Code: $ cat /var/log/squeezeboxserver.log Your locale was detected as C, you may have problems with non-Latin filenames. Consider changing your LANG variable to the correct locale, i.e. en_US.utf8 [11-02-07 09:24:31.9293] main::init (323) Starting Squeezebox Server (v7.5.3, r31792, Mon Jan 24 08:21:38 MST 2011) perl 5.010000 This is right: all diacritics letters are wrongly displayed on the Transporter. This was not the case, and I did not get such an error message, as I ran /home/squeezeboxserver/slimserver.pl directly from squeezeboxserver user Code: $ su squeezeboxserver Password: $ /home/squeezeboxserver/slimserver.pl --daemon [11-02-03 23:14:22.3223] main::init (323) Starting Squeezebox Server (v7.5.3, r31792, Mon Jan 24 08:21:38 MST 2011) perl 5.010000 I did a quick check: Code: $ locale LANG=en_US.utf8 LC_CTYPE="en_US.utf8" LC_NUMERIC="en_US.utf8" LC_TIME="en_US.utf8" LC_COLLATE=C LC_MONETARY="en_US.utf8" LC_MESSAGES="en_US.utf8" LC_PAPER="en_US.utf8" LC_NAME="en_US.utf8" LC_ADDRESS="en_US.utf8" LC_TELEPHONE="en_US.utf8" LC_MEASUREMENT="en_US.utf8" LC_IDENTIFICATION="en_US.utf8" LC_ALL= It looks OK. However, I commented in the relevant line as Code: #LC_COLLATE=C into /etc/profile.
Problem remains still. Have you an idea about what should be fixed here ? |
Author: | tjc [ Mon Feb 07, 2011 7:44 pm ] |
Post subject: | |
Assuming that you have the support files for the Polish locale installed, you can try overriding the locale by setting the following variables in the script: Code: export LANG=pl.utf8 export LC_ALL=pl.utf8 However, If running: Code: locale -a
doesn't show it as an option that probably won't work. BTW - all you did above was comment out the default collating order (the order than things are sorted in "alphabetically"). |
Author: | Golffies [ Tue Feb 08, 2011 12:27 am ] |
Post subject: | locale |
Hi tjc, tjc wrote: BTW - all you did above was comment out the default collating order (the order than things are sorted in "alphabetically"). Yes,
I gave it a try after reading this bug report on Archlinux: FS#10435 - LC_COLLATE="C" should be removed from /etc/profile. So I suspected that "something might be wrong there". But you are right, it was non-sense. The point here is not that I need to move from US to PL locale. As far as Unicode is supported, I am fine with US locale. Problem is rather that squeezeboxserver considers that 'C' is my locale, not 'us.utf8' as it is normally. I never took care before, but mythtv might face the same problem, as its EPG gets blurred on letters with diacritics. Final point, why such a problem does not happen when starting manually squeezeboxserver from squeezeboxserver user ? Code: $ su squeezeboxserver
Password: $ /home/squeezeboxserver/slimserver.pl --daemon [11-02-03 23:14:22.3223] main::init (323) Starting Squeezebox Server (v7.5.3, r31792, Mon Jan 24 08:21:38 MST 2011) perl 5.010000 In such a case, no error message, no erroneous letters with diacritics. |
Author: | tjc [ Thu Feb 10, 2011 8:09 pm ] |
Post subject: | |
The most common differences for scripts run "from the command line" versus scripts run "automatically" is the environment. Scripts that are intended to be run automatically need to pay special attention to setting up any environment variables that they (or the other scripts/programs that they call) need. So... Run env | sort from the command line where it works. Put the same thing in the sv script and make sure you're logging the output. Compare the two, paying special attention to LANG or LC_ settings. |
Author: | rsay [ Sun May 01, 2011 8:05 am ] |
Post subject: | |
I was also having some difficulties with locale. locale -a wasn't showing any valid locales on my system. I checked /etc/locale.gen and it looked okay, showing en_US.UTF-8 UTF-8. I finally solved it by running pacman -S glibc to reinstall glibc and then my locale was available and I stopped getting locale related errors from perl. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |