如何安裝羅技媒體伺服器(Squeezebox Server)?

如何安裝羅技媒體伺服器(Squeezebox Server)?

在哪裡可以取得 Logitech Media Server 的最新安裝檔案以及如何正確安裝?

(我在 Raspberry Pi 2 上運行它,由於 SD 卡故障,我不得不重新安裝幾次。所以我回答這個問題主要是為了提醒自己。)

答案1

在撰寫本文時最新版本是 7.9.2。

可用這裡。您可以找到其他幾個版本的概述這裡link根據您的系統將其複製到剪貼簿中的檔案。

使用 .zip 檔案將檔案下載到您的系統wget link。安裝filesudo 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新增到群組中users。此外,播放清單的位置應該是chmod 775


如果你使用防火牆之類的ufw處理連接埠已解釋這裡


其他文件可以在這裡找到:http://wiki.slimdevices.com/index.php/Logitech_Media_Server_file_locations#Ubuntu_.3E12.04

答案2

我升級到 Ubuntu 20.04,這破壞了我的安裝,但我想出瞭如何讓它再次工作:

經過一番磨練後,我考慮重新安裝。所以我刪除了 /var/lib/squeezeboxserver/ 中的舊內容

然後我從以下位置獲得了 8.0(測試版)版本的新 deb 資料包:http://downloads.slimdevices.com/nightly/?ver=8.0

就我個人而言,我使用了最平台的版本,但根據平台,只需選擇一個合適的 deb:

wget http://downloads.slimdevices.com/nightly/8.0/lms/cf7bcdb87b4f8bf6f71f5b5444c923afae4c300d/logitechmediaserver_8.0.0~1589180193_all.deb

安裝它: dpkg -i logitechmediaserver_8.0.0_1588799628_all.deb

當我也嘗試過舊版本,甚至嘗試過 git checkout 時,我希望我不缺少任何細節,另一個腳本已經為我完成了,而沒有註意到它。

如果 dpkg 安裝尚未新增使用者和群組,請執行以下操作:

adduser squeezeboxserver
usermod -a -G squeezeboxserver squeezeboxserver

為pid檔案建立一個目錄:

mkdir /var/run/logitechmediaserver

並將其提供給該使用者和群組:

chown squeezeboxserver:squeezeboxserver /var/run/logitechmediaserver

/var/lib/squeezeboxserver/ 中的內容也是如此

chown squeezeboxserver:squeezeboxserver /var/lib/squeezeboxserver
chown -R squeezeboxserver:squeezeboxserver /var/lib/squeezeboxserver/*

問題出在 /etc/init.d 中的啟動腳本。它根本不起作用,因為 Ubuntu 20.04 不再有啟動-停止-守護程式。它只是連結到 /bin/true ,這可能適用於某些腳本,但不適用於 logitechmediaserver。我嘗試了這個程序的 C 實現,但它有它的鉸鏈,所以我放棄了啟動-停止-守護程序並相應地修改了啟動程序。

只需將舊的啟動腳本儲存起來(只是為了保存)並將此內容複製到您選擇的編輯器中:

#!/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

是的,它並不漂亮,但它對我來說很有效,希望對你也有幫助。您必須將其放在 /etc/init.d 中,名稱為 logitechmediaserver

之後,您必須執行以下命令以使 systemctl 滿意:

systemctl daemon-reload

只需啟動它即可進行測試運行:

/etc/init.d/logitechmediaserver start

您應該能夠使用網頁瀏覽器登入http://你的伺服器IP:9000/並配置它。

並測試它是否再次關閉:

/etc/init.d/logitechmediaserver stop

一切順利後,啟用該服務:

systemctl enable logitechmediaserver.service

相關內容