#!/bin/sh
#
# $Id$
#
# logitechmediaserver initscript for slimserver.pl
# This file should be placed in /etc/init.d.
#
# Original Author: Mattias Holmlund
#
# Updated By: Dan Sully, Michael Herger, Alexander Hartmann
#
### BEGIN INIT INFO
# Provides: logitechmediaserver
# Required-Start: $all
# Required-Stop: $all
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Startup script for the Logitech Media Server
# Description: Logitech Media Server powers the Squeezebox, Transporter and SLIMP3 network music \
# players and is the best software to stream your music to any software MP3 \
# player. It supports MP3, AAC, WMA, FLAC, Ogg Vorbis, WAV and more! \
# As of version 7.7 it also supports UPnP clients, serving pictures and movies too!"
### END INIT INFO
#
# -e Exit immediately if a command exits with a non-zero status.
set -e
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
### About logitechmediaserver
# The logitechmediaserver is kind of special. It uses the
# squeezeboxserver_safe script, to restart any died squeezeboxserver. This
# can easily happen, for example if you use a MySQL server. Depending on unix
# flavour you are running they sometimes do a regular restart. That would
# cause the squeezeboxserver to terminate. Because of that the
# squeezeboxserver_safe starts a logitechmediaserver every few seconds, which
# gets shut down again if any other logitechmediaserver is still running.
#
# Sadly this procedure messes up, the process id file. You would get a new id
# file, every time a new server process gets started. That process will
# terminate but the process id of the first server process is lost. So the
# killing the squeezeboxserver have to be done with analysing the process
# table.
#
# As I upgraded to Ubuntu 20.04 my logitechmediaserver stopped working.
# Installing the lastest 8.0 version was no problem downloading the deb-packet
# and installing with dpkg. But the server did not start. I could start it
# manually but the startup script was not able to start it. After some looking
# around I found this:
#
# /sbin/start-stop-daemon -> /bin/true
#
# This explains why the start up script is not working. There is no package
# in the ubuntu package repository for the start-stop-daemon.
#
# First I tried the C implementation of start-stop-daemon from Dale O'Brien on
# github (https://github.com/daleobrien/start-stop-daemon). It does not
# implement the --remove-pidfile option the original script. But more
# problematic it threw the error not able to terminate the server while
# doing it without a problem.
#
# I had to compile the C implementation from Dale O'Brien myself, which
# worked without a hitch. Considering the limiations of the implementation
# I came to the conclusion to ditch the start-stop-daemon completly and
# doing it the old school way.
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Logitech Media Server"
NAME=squeezeboxserver
NEWNAME=logitechmediaserver
DAEMON=/usr/sbin/$NAME
DAEMON_RESTARTER=/usr/sbin/${NAME}_safe
PIDFILE=/var/run/$NEWNAME/${NEWNAME}.pid
SCRIPTNAME=/etc/init.d/$NEWNAME
SLIMUSER=$NAME
SLIGROUP=$NAME
PREFSDIR=/var/lib/$NAME/prefs
LOGDIR=/var/log/$NAME/
CACHEDIR=/var/lib/$NAME/cache
CHARSET=utf8
SLEEPTIMER=1
## if you want to add additional options
## use /usr/sbin/squeezeboxserver --help
## for the supported options and place them
## into the configfile /etc/default/logitechmediaserver
# Read config file if it is present.
if [ -r /etc/default/$NEWNAME ]; then
. /etc/default/$NEWNAME
elif [ -r /etc/default/$NAME ]; then
. /etc/default/$NAME
fi
#
# Function that starts the daemon/service.
#
d_start() {
# Where is your su installed?
SU_BIN=$(command -v su)
# Use squeezeboxserver_safe to restart the daemon when
# it dies. This must be done to handle mysql restarts.
$SU_BIN - $SLIMUSER \
-s /bin/sh \
-c "$DAEMON_RESTARTER \
$DAEMON \
--user $SLIMUSER \
--group $SLIGROUP \
--prefsdir $PREFSDIR \
--logdir $LOGDIR \
--cachedir $CACHEDIR \
--charset=$CHARSET \
--daemon \
$SLIMOPTIONS \
> /dev/null 2>&1 &"
# Writing the pid for the restarter
PID=$(ps ax | \
grep "$DAEMON_RESTARTER $DAEMON" | \
grep -v grep | \
head -1 | \
awk '{print $1}' )
if [ $PID ]
then
if [ $PID -gt 0 ]
then
echo -n " Started the restarter with the process id: "
echo $PID
if [ -e $PIDFILE ]
then
rm $PIDFILE
fi
echo -n $PID > $PIDFILE
fi
else
echo " ERROR: No process id for the restarter could be found!"
fi
# Check if the server is successfully started
PERL_BIN=$(command -v perl)
PID_SERVER=$(ps ax | \
grep "$PERL_BIN $DAEMON" | \
grep -v grep | \
head -1 | \
awk '{print $1}' )
if [ $PID_SERVER ]
then
if [ $PID_SERVER -gt 0 ]
then
echo " Started the server successfully."
else
echo " ERROR: No process id for the server could be found!"
fi
fi
}
# Function that stops the daemon/service.
#
d_stop() {
echo -n " Checking if the restarter is still running: "
## This will kill the squeezeboxserver_safe script. So we don't have
## to bother about it, starting new processes.
PID1=$(ps ax | \
grep "$DAEMON_RESTARTER $DAEMON" | \
grep -v grep | \
head -1 | \
awk '{print $1}' )
if [ $PID1 ]
then
echo positive
if [ $PID1 -gt 0 ]
then
echo -n " Stopping now restarter: "
kill $PID1
if [ -e $PIDFILE ]
then
rm $PIDFILE
fi
echo done.
fi
else
echo negative
fi
## We have to kill at least one server process. Possible two processes
## and in weird cases under real high load even three processess.
## So a loop it is.
## We have to wait for at least one second for closing the process
## and analyzing the process list again.
echo -n " Checking if any server instances are running: "
PERL_BIN=$(command -v perl)
PID2=$(ps ax | \
grep "$PERL_BIN $DAEMON" | \
grep -v grep | \
head -1 | \
awk '{print $1}' )
if [ $PID2 ]
then
echo positive
echo -n " Stopping now all server instances: "
if [ $PID2 -gt 0 ]
then
while [ $(ps ax | \
grep "$PERL_BIN $DAEMON" | \
grep -v grep | \
head -1 | \
awk '{print $1}') ]
do
kill $(ps ax | \
grep "$PERL_BIN $DAEMON" | \
grep -v grep | \
head -1 | \
awk '{print $1}')
sleep $SLEEPTIMER
done
echo done
fi
else
echo negative
fi
}
#
# Function that sends a SIGHUP to the daemon/service.
#
d_reload() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE --signal 1
}
case "$1" in
start)
echo "Making sure that $DESC is not running: "
d_stop
echo "Starting $DESC:"
d_start
;;
stop)
echo "Stopping $DESC:"
d_stop
;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo "Restarting $NAME."
d_stop
d_start
;;
status)
status_of_proc /usr/bin/$NEWNAME $NEWNAME
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0
在撰写本文时,最新版本是 7.9.2。
在这里可用。您可以在此处找到其他几个版本的概述。
link
根据您的系统将文件复制到剪贴板中。使用 .将文件下载到您的系统
wget link
。安装.file
_ 由于缺少依赖项,sudo dpkg -i file
这将无法安装。修复它
sudo apt -f install
。开始它
sudo service logitechmediaserver start
。检查是否与
top
.通过可在 中获得的 Web-GUI 连接到服务器
http://IPofYOURserver:9000
。设置在
/var/lib/squeezeboxserver/prefs/server.prefs
.这包括媒体库的目录以及本地客户端的设置,例如旧 Squeezebox Boom 显示屏中显示的信息大小。
如果您想避免设置所有新内容,您可以覆盖
server.prefs
. 为了能够做到这一点,你必须sudo systemctl stop logitechmediaserver
。然后复制文件和
sudo chown squeezeboxserver:nogroup /var/lib/squeezeboxserver/prefs/server.prefs
.最后,
sudo systemctl start logitechmediaserver
.更新:也许
squeezeboxserver
需要将用户添加到 groupusers
。此外,播放列表的位置应该是chmod 775
.如果您使用防火墙之类的
ufw
处理端口,请参见此处。其他文件可以在这里找到:http ://wiki.slimdevices.com/index.php/Logitech_Media_Server_file_locations#Ubuntu_.3E12.04
我升级到 Ubuntu 20.04,这破坏了我的安装,但我想出了如何让它再次工作:
经过一番磨练,我考虑重新安装。所以我删除了 /var/lib/squeezeboxserver/ 中的旧东西
然后我从http://downloads.slimdevices.com/nightly/?ver=8.0得到了一个新的 8.0 (beta) 版本的 deb-packet
就我个人而言,我使用了最平台的版本,但取决于平台,只需选择一个合适的 deb:
安装它:dpkg -i logitechmediaserver_8.0.0_1588799628_all.deb
当我也尝试过旧版本甚至尝试过 git checkout 时,我希望我不会缺少另一个脚本已经为我完成的细节而没有注意到它。
如果 dpkg 安装尚未添加用户和组,请执行以下操作:
为 pid 文件创建一个目录:
并将其提供给该用户和组:
/var/lib/squeezeboxserver/ 中的内容也是如此
问题来自 /etc/init.d 中的启动脚本。它根本不起作用,因为 Ubuntu 20.04 不再具有 start-stop-daemon。它只是链接到 /bin/true,这可能适用于某些脚本,但不适用于 logitechmediaserver。我为这个程序尝试了一个 C 实现,但它有铰链,所以我放弃了 start-stop-daemon 并相应地修改了启动程序。
只需将旧的启动脚本存储起来(只是为了保存)并将此内容复制到您选择的编辑器中:
是的,它不漂亮,但它对我有用,希望也能帮助你。您必须将它放在 /etc/init.d 中,名称为 logitechmediaserver
之后,您必须运行以下命令才能使 systemctl 满意:
只需启动它进行测试运行:
您应该能够使用您的网络浏览器登录到http://YourServerIP:9000/并进行配置。
并测试它是否再次关闭:
一切顺利后,启用服务: