PDA

View Full Version : New Debian install: manual start not very bright, quite overzealous



davejay
2005-08-04, 14:26
After searching and reading forum entries on the subject, I installed the following on my new Debian Sarge box:

1. The 6.1 RPM, into /usr/local/slimserver;

2. The DebianStartupScript3, as instructed by its' INSTALLATION document (other than pulling the latest code using svn).

After a few permissions issues were worked out, it now auto-starts just fine and runs as user slimserver.

However, there are two problems:

#1: if I manually run /etc/init.d/slimserver start as a user other than slimserver, it doesn't recognize that slimserver is already running, and starts another instance of slimserver.pl;

#2: once this additional process starts, it hogs the processor following this cycle:

- Tries to start;
- Sees another instance running;
- Logs "another instance is running, I'm shutting down";
- Shuts down;
- slimserver_safe (the 3rd script's script to automatically restart) logs "slimserver has shut down, restarting";
- slimserver_safe spawns another instance of slimserver.pl, and we do it all over again.

Now, the question isn't "why are you manually running a second instance?!?" -- it's "why don't the init.d script nor slimserver_safe recognize that an instance is already running -before- starting another instance?"

Any assistance would be appreciated. Dunno if it's a user issue, a permissions issue, a flaw in the scripts, or...well, elves, I suppose.

Thanks in advance.

PS -- for those who care, the only way to break out of the cycle is to manually kill the PID that slimserver_safe is running on; however, that PID doesn't appear unless you're logged in as user slimserver, or unless you rename the slimserver.pl to something else. Once you rename it, it can't be restarted and slimserver_safe starts showing up in the PID list. There might be another way to stop it, but I have no idea what that might be.

davejay
2005-08-05, 16:58
Nobody? Anybody? Sigh. I notice some off-topic replies with the same subject header, but threaded separately -- strange.

Found another problem, too: slimserver.conf never gets written (nor does .slimserver.conf). Anyone running debian out there that can give me a hand?

Patrick Dixon
2005-08-06, 01:54
My debian install (ubuntu) uses slimserver.pref rather than slimserver.conf - I think slimserver.conf may only be used in RPM installs.

These are the notes I made when I installed 6.2b1 on ubuntu the other day - the init script was based heavily on debian No2 in the wiki

Instructions for installing on ubuntu (Debian)
----------------------------------------------

/* install as su */
sudo su

/* setup slimserver user */
addgroup slimserver
adduser --ingroup slimserver slimserver

/* unpack slimserver code */
cd /usr/local/slimserver
tar -xzvf ....SlimServer_v2005-08-02.tar.gz
ln -s SlimServer_v2005-08-0 slimserver (link or rename directory as required)

/* create pref file with write permissions for slimserver */
nano /etc/slimserver.pref
(save as empty file)
chmod 666 /etc/slimserver.pref

/* create startup script */
nano /etc/init.d/slimserver
cut & paste:

#!/bin/sh

# slimserver init script for Debian Linux
#
# This script expects slimserver to be installed in
# /usr/local/slimserver
#
# logfile will be written to
# /tmp/slimserver.log
#

DAEMON=/usr/local/slimserver/slimserver.pl
PIDFILE=/var/tmp/slimserver.pid
LOGFILE=/tmp/slimserver.log
USER=slimserver
SLIMSERVER_OPTS=""

test -x ${DAEMON} || exit 0

case "$1" in
start) echo -n "Starting Slimserver: "
HOME=/home/$USER
start-stop-daemon --start --quiet --exec $DAEMON \
--chuid ${USER} -- --daemon \
--prefsfile=/etc/slimserver.pref --pidfile=${PIDFILE} \
--logfile=${LOGFILE} ${SLIMSERVER_OPTS}
echo "slimserver"
;;

stop) echo -n "Stopping Slimserver: "
start-stop-daemon --stop --quiet --user ${USER} --pidfile ${PIDFILE} --retry 5
echo "done"
;;

force-reload|restart) $0 stop
$0 start
;;

*) echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1;
;;

esac

exit 0

(save file)
chmod chmod 755 /etc/init.d/slimserver

/* start slimserver */
/etc/init.d/slimserver start

/* add to init */
update-rc.d slimserver defaults

/* kill su */
exit

davejay
2005-08-06, 08:56
Okay, I'm going to revert my previous installation and start over using your instructions. Thanks for taking the time to post this!

-D

Patrick Dixon
2005-08-06, 11:32
I hope it works for you!

I think I've mistakenly put cd to /usr/local/slimserver rather than /usr/local!

I've also missed that you'll need to
chown -Rf slimserver:slimserver /usr/local/slimserver
after you've unpacked the slimserver code and made the link.

Note that I put slimserver.log in /tmp because the ubuntu default permissions allowed 'slimserver' to write it there - and that's also where the rpm install puts it.

Patrick Dixon
2005-08-06, 11:36
So, revised

Instructions for installing on ubuntu (Debian)
----------------------------------------------

/* install as su */
sudo su

/* setup slimserver user */
addgroup slimserver
adduser --ingroup slimserver slimserver

/* unpack slimserver code */
cd /usr/local
tar -xzvf ....SlimServer_v2005-08-02.tar.gz
ln -s SlimServer_v2005-08-0 slimserver (link or rename directory as required)
chown -Rf slimserver:slimserver /usr/local/slimserver

/* create pref file with write permissions for slimserver */
nano /etc/slimserver.pref
(save as empty file)
chmod 666 /etc/slimserver.pref

/* create startup script */
nano /etc/init.d/slimserver
cut & paste:

#!/bin/sh

# slimserver init script for Debian Linux
#
# This script expects slimserver to be installed in
# /usr/local/slimserver
#
# logfile will be written to
# /tmp/slimserver.log
#

DAEMON=/usr/local/slimserver/slimserver.pl
PIDFILE=/var/tmp/slimserver.pid
LOGFILE=/tmp/slimserver.log
USER=slimserver
SLIMSERVER_OPTS=""

test -x ${DAEMON} || exit 0

case "$1" in
start) echo -n "Starting Slimserver: "
HOME=/home/$USER
start-stop-daemon --start --quiet --exec $DAEMON \
--chuid ${USER} -- --daemon \
--prefsfile=/etc/slimserver.pref --pidfile=${PIDFILE} \
--logfile=${LOGFILE} ${SLIMSERVER_OPTS}
echo "slimserver"
;;

stop) echo -n "Stopping Slimserver: "
start-stop-daemon --stop --quiet --user ${USER} --pidfile ${PIDFILE} --retry 5
echo "done"
;;

force-reload|restart) $0 stop
$0 start
;;

*) echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1;
;;

esac

exit 0

(save file)
chmod chmod 755 /etc/init.d/slimserver

/* start slimserver */
/etc/init.d/slimserver start

/* add to init */
update-rc.d slimserver defaults

/* kill su */
exit

davejay
2005-08-06, 12:35
Thanks again -- it's all working beautifully now.

FYI, I did a couple of steps differently (putting here for future debian-seekers):

1. When I created the slimserver user, I added --system so that it didn't ask for a password;

2. Once I placed the untar'd files in /usr/local/slimserver, I did chown -R root * and chgrp -R staff * on /usr/local/slimserver; on my machine (Debian Sarge) these are the default permissions in /usr/local;

Oh, and when I first started it up, it took a long time (a minute?) before it would respond to the web interface, even on localhost. No idea why.

-D

Marc Sherman
2005-08-06, 15:14
Patrick Dixon wrote:
>
> I've also missed that you'll need to
> chown -Rf slimserver:slimserver /usr/local/slimserver
> after you've unpacked the slimserver code and made the link.

I'd recommend root:slimserver, not slimserver:slimserver, and only make
the files that need to be (the .conf files) group writable. Never give
your process more permissions than it needs.

- Marc

Lars Chr. Hausmann
2005-08-07, 06:47
>>>>> "Marc" == Marc Sherman <msherman (AT) projectile (DOT) ca> writes:

Marc> Patrick Dixon wrote:
>> I've also missed that you'll need to chown -Rf slimserver:slimserver
>> /usr/local/slimserver
>> after you've unpacked the slimserver code and made the link.

Marc> I'd recommend root:slimserver, not slimserver:slimserver, and only
Marc> make the files that need to be (the .conf files) group writable.
Marc> Never give your process more permissions than it needs.

For that excact reason you should _never_ run anything as root, that
does not require root permission.

I am runing my slimserver under slim:slim under DJB's
daemontools. Works like a charm. This also means that I am pretty
confident, that if that user is compromised he wont be able to do too
much serious damage.

Marc Sherman
2005-08-07, 07:15
Lars Chr. Hausmann wrote:
>
> For that excact reason you should _never_ run anything as root, that
> does not require root permission.
>
> I am runing my slimserver under slim:slim under DJB's
> daemontools. Works like a charm. This also means that I am pretty
> confident, that if that user is compromised he wont be able to do too
> much serious damage.

I didn't say _run_ as root, I said the files should be _owned_ by root.
That way, the user running the slimserver app doesn't own the files,
and can't modify them if compromised.

- Marc

Robin Bowes
2005-08-07, 13:29
Lars Chr. Hausmann wrote:

> I am runing my slimserver under slim:slim under DJB's
> daemontools. Works like a charm. This also means that I am pretty
> confident, that if that user is compromised he wont be able to do too
> much serious damage.

Lars,

I'd be interested to see your run file for your slimserver service.

Also, how are you doing logging?

I'm currently running slimserver from /etc/init.d/slimserver on my
Fedora Core 4 box. I am logging using multilog as follows:

In /etc/sysconfig/slimserver:

SLIMSERVER_LOG="'|/usr/local/bin/multilog t s1000000 n40
/var/log/slimserver'"
SLIMSERVER_ARGS="--daemon --prefsfile=$SLIMSERVER_CFG
--logfile=$SLIMSERVER_LOG
--d_source --d_remotestream"

I had to patch slimserver.pl to work with this but that was committed to
CVS/svn some time ago.

Cheers,

R.

Christian Pernegger
2005-08-07, 15:34
> If there's not, I may try my hand at it. I've always wanted to learn how
> they are made, but haven't found a package that I use that needed it, that
> I thought would be simple enough for a first attempt.

IIRC someone else has tried getting slimserver into Debian before, and
failed because some parts (fonts?) are not DFSG free.

For a "third-party" deb it would be nice to just include the debian/
subdirectory in the official source, so a dpkg-buildpackage in a
directory with the extracted source is all that's needed to get a
package. (cf. mplayer)

C.

Dan Sully
2005-08-08, 10:24
* Michael Carland shaped the electrons to say...

>The one perl module I can't find already made is HiRes. At that point it
>was getting late, and I haven't looked at it again.

Time::HiRes ships as part of perl 5.8.x

-D
--
<weezyl> Oh, I cook bacon naked all the time. You just have to keep the heat on med-low.

PowerRanger
2005-08-20, 14:58
Great and timely thread. I'm trying to get slimserver installed on Ubuntu hoary hedgehog. I've been running it on a windows box, but when that crashed I decided it was a good time to make the Linux switch on that box. As near as I can tell, as this is based on debian, this thread has just the info I was looking for. Noticed the the source I d/l'd from slimdevices.com was SlimServer_v6.1.1.tar.gz, so I had to change some of the stuff from the earlier posts. On to my problem....

When I try to start slimserver, I get an error 'Use of initialized string eq at /usr/local/SlimServer_v6.1.1/slim/utils.prefs.pm line 424

The section of code is :

sub checkServerPrefs {
for my $key (keys %DEFAULT) {
if (!defined($prefs{$key})) {
if (ref($DEFAULT{$key} eq 'ARRAY')) {
my @temp = @{$DEFAULT{$key}};
$prefs{$key} = \@temp;
} else {
$prefs{$key} = $DEFAULT{$key};
}
}
}

with "if (ref($DEFAULT{$key} eq 'ARRAY')) {" being line 424

Does anyone who knows perl have any ideas?

Thanks

Mike

Patrick Dixon
2005-08-21, 00:37
I don't know perl so this is a stab in the dark, but have you put your logfile somewhere with permissions set so that the slimserver user can create and write to it?

PowerRanger
2005-08-21, 11:54
yup, I created an empty file as :

# slimserver init script for Debian Linux
#
# This script expects slimserver to be installed in
# /usr/local/slimserver
#
# logfile will be written to
# /tmp/slimserver.log
#

DAEMON=/usr/local/slimserver/slimserver.pl
PIDFILE=/var/tmp/slimserver.pid
LOGFILE=/tmp/slimserver.log
USER=slimserver
SLIMSERVER_OPTS=""



The log is being written to, it contains this which I think is related to the other prefs error echoed to the terminal session;

Use of uninitialized value in -d at /usr/local/SlimServer_v6.1.1/Slim/Networking/mDNS.pm line 26.
Use of uninitialized value in -d at /usr/local/SlimServer_v6.1.1/Slim/Networking/mDNS.pm line 26.
Use of uninitialized value in -d at /usr/local/SlimServer_v6.1.1/Slim/Networking/mDNS.pm line 26.
Use of uninitialized value in -d at /usr/local/SlimServer_v6.1.1/Slim/Networking/mDNS.pm line 26.
Use of uninitialized value in -d at /usr/local/SlimServer_v6.1.1/Slim/Networking/mDNS.pm line 26.
Use of uninitialized value in join or string at /usr/share/perl/5.8/File/Spec/Unix.pm line 36.
DBI connect('dbname=/.slimserversql.db','',...) failed: unable to open database file(1) at dbdimp.c line 94 at /usr/local/SlimServer_v6.1.1/Slim/DataStores/DBI/DataModel.pm line 113

Patrick Dixon
2005-08-21, 14:24
Sorry - I'm out of my depth then.

Hopefully someone else will be able to help.

PowerRanger
2005-08-22, 17:44
Well, I'm still messing with this, but I'm not getting anywhere. Is anyone willing to pull the package from slimdevices.com and diff the /slim/utils/prefs.pm file between V6.1.1.tar.gz (which I have and is on the website) and SlimServer_v2005-08-02.tar.gz (which the scripts were written for and I have no idea where to get)

TIA

Mike

Patrick Dixon
2005-08-23, 00:49
SlimServer_v2005-08-02.tar.gz was just the latest nightly I'd downloaded when I wrote up those instructions.

You can find the nightlies here: http://www.slimdevices.com/downloads/nightly/latest/6.2/

The code is built every night so it won't be exactly the same as the 2 August code; but give it a go anyway.

PowerRanger
2005-08-23, 18:26
WooHoo---Its working!

I diffed doday's code with what I have, in addition to a few other differences, I found new line 424 vs old line;


if (ref($DEFAULT{$key}) eq 'ARRAY') {
if (ref($DEFAULT{$key} eq 'ARRAY')) {

I haven't played any tunes yet because I have to hook up my audio drive still, but I wanted to say thanks for helping me out.


BTW

It also looks like somebody added a line to write out the actual prefs file (I suppose instead of building it fresh every time).

Mike

johnduley
2005-10-23, 05:55
What a great tutorial! I'm studying for an LPI at the moment so being able to apply some of what I have learnt in a "real" situation is great i.e. creating a start-up script for SlimServer and setting up all the folders, users and permissions.

Previously, I used to run slimserver.pl from a subdir of my home dir - NOW I have it run as a daemon, by the dedicated use "slimserver" it has made the server much more responsive (particularly when using the web interface! Thanks Patrick!

MrC
2005-11-09, 22:28
/* install as su */
sudo su



This is an odd one. You're using a setuid change UID program to run another setuid change UID program? How about the simpler:

sudo -s

MrC
2005-11-09, 22:32
What a great tutorial! I'm studying for an LPI at the moment so being able to apply some of what I have learnt in a "real" situation is great i.e. creating a start-up script for SlimServer and setting up all the folders, users and permissions.

How are things going with your studying/learning? I used to teach Unix/Linux course at a local community college for fun in the evenings. If you want some additional materials, lots of coursework, labs, lecture notes, and other stuff here (check the Calender sections):

http://cis68a.mikecappella.com/
http://cis68b1.mikecappella.com/
http://cis68c1.mikecappella.com/
http://cis68c2.mikecappella.com/

mordav
2005-12-04, 15:36
I've spent a couple of hours reading forum threads and trying to install v6.2.1 on my vanilla kubuntu 5.10 installation. I've been using Debian for years so was quite happy to follow the tutorial in this thread, but made a couple of changes:

To create the group and user together and give them the same uids:
adduser --system --group slimserver

To change the owner and groups on all files:
chown -RH root:slimserver /usr/local/slimserver

Then I had to run the step as prompted:
/usr/local/SlimServer_v6.2.1/Bin/build-perl-modules.pl

Finally the thing that stumped me for longest was "which port do I use to connect to the server" but I found the answer in the log:
2005-12-04 22:17:30.8311 The URL to access SlimServer is now:
http://hurley:9000/

FWIW, I also have errors in the log but I don't know what if anything these will break:
can't create /fontcache: Permission denied at /usr/local/SlimServer_v6.2.1/Slim/Display/Graphics.pm line 392
can't create /fontcache: Permission denied at /usr/local/SlimServer_v6.2.1/Slim/Display/Graphics.pm line 392
can't create /fontcache: Permission denied at /usr/local/SlimServer_v6.2.1/Slim/Display/Graphics.pm line 392
can't create /fontcache: Permission denied at /usr/local/SlimServer_v6.2.1/Slim/Display/Graphics.pm line 392

WildCoder
2005-12-07, 07:51
You either need to give write permission to your slimserver user in its home directory or manually create the fontcache directory and give it write permission to slimserver user.

The strange thing is that it seems to want to create it at the root (/fontcahe). You may not have defined a home directory for your slimserver user (not positive about that one).

My setup creates that directory in the same place it create the database (.slimserverdb.sql).

-WildCOder

Pale Blue Ego
2006-06-22, 12:01
Previously, I used to run slimserver.pl from a subdir of my home dir - NOW I have it run as a daemon, by the dedicated use "slimserver" it has made the server much more responsive (particularly when using the web interface! Thanks Patrick!

Does the .deb package now handle all this? - (create user slimserver, grant needed permissions, create startup script)

I've been manually starting slimserver.pl from /home/myusername/slimserver/
and it does seem very sluggish

Currently using 6.2.2 on a Mepis (debian) system
AMD Athlon 2K, 512 MB RAM, 20k track library