Ubuntu 14.04 上的 UMS.sh(作為服務運行)不會讀取設定檔

Ubuntu 14.04 上的 UMS.sh(作為服務運行)不會讀取設定檔

我正在嘗試讓我的 ubuntu 14.04 運行通用媒體伺服器,這樣我就可以將電影串流到我的 ps3(不幸的是最低韌體 4.55 - 不可越獄)。

經過在網上進行大量研究後,我能夠將其作為服務運行,/etc/init.d/UMS.sh其他文件位於/usr/ums資料夾中。其中包括UMS.conf設定檔、UMS.sh文件和ums.jar文件以及所有其他文件。

我已經使用creamgedit在創建這些臨時文件時遇到問題,稍後需要將其刪除)來編輯UMS.conf文件。

我試圖讓它在特定連接埠上運行並有一個 IP 白名單,這樣網路上的每個人都無法存取我的東西。

因此,我對文件進行了更改UMS.conf,加載了幾次以仔細檢查更改是否已保存 - 他們確實這樣做了 - 但當我這樣做時:

   service UMS.sh start

UMS 將啟動,但使用所有預設配置。

請幫忙。我是 Ubuntu 新手,所以也請引導我完成。如果有幫助的話,我可以提供腳本/etc/init.d/UMS.sh,但請告訴我如何貼到這裡,我嘗試過,# 使內容變成粗體。

更新:在 Letizia 評論的幫助下,以下是腳本

'/etc/init.d/UMS.sh'

#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          ums
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts UMS program.
# Description:       Java Upnp Media Server dedicated to PS3
### END INIT INFO

#set -x

# Author: Papa Issa DIAKHATE <[email protected]>
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Universal Media Server"
NAME=UMS.sh
UMS_PROFILE=/etc/$NAME
DAEMON=/usr/ums/$NAME
DAEMON_OPTS="console"
SCRIPTNAME=/etc/init.d/$NAME
UMS_START=1 # Wether to start or not UMS ver at boot time.
DODTIME=30  # Time to wait for the server to die, in seconds.
            # If this value is set too low you might not
            # let the program to die gracefully and 'restart' will not work

test -x $DAEMON || exit 1

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Include ums defaults if available
if [[ -f "/etc/default/$NAME" ]] ; then
        . /etc/default/$NAME
fi

# May we run the init.d script ?
[[ $UMS_START = 1 ]] || exit 1

#--------------------------------------------------------------------------
# Some color codes
txtred=$'\e[0;31m' # Red
txtylw=$'\e[0;33m' # Yellow
txtrst=$'\e[0m'    # Text Reset
#--------------------------------------------------------------------------
warnout(){
    echo >&2 -e ""$txtylw"Warning:$txtrst $1"
}
#--------------------------------------------------------------------------
running(){
    pid=`pgrep -f 'java .*ums.jar.*'`
}
#--------------------------------------------------------------------------
do_start(){
    running && { warnout "$NAME is already running !"; exit 0; }
    echo "Starting $DESC : $NAME"
    UMS_PROFILE="$UMS_PROFILE" start-stop-daemon --start --quiet --background --oknodo \
        --exec $DAEMON -- $DAEMON_OPTS

}
#--------------------------------------------------------------------------
do_stop(){
    running || { warnout "$NAME is NOT running !"; exit 0; }   
    local countdown="$DODTIME"
    echo -e "Stopping $DESC : $NAME \c "
    kill -9 $pid
    while running; do
        if (($countdown >= 0)); then
            sleep 1; echo -n .;
            ((--countdown))
        else
            break;
        fi
    done
    echo
    # If still running, then try to send SIGINT signal
    running && { \
        echo >&2 "Using kill -s SIGINT instead"; \
        echo >&2 "If you see this message again, then you should increase the value of DODTIME in '$0'."; \
        kill -2 $pid; \
    }

    if [ -e "/usr/share/ums/debug.log" ]; then
    count=9
    while [ $count -ge 1 ]
    do
    if [ -e "/usr/share/ums/debug.log.$count" ]; then
        plus=$((count+1))
        mv "/usr/share/ums/debug.log.$count" "/usr/share/ums/debug.log.$plus"
    fi
        count=$((count-1))
    done
    if [ -e "/usr/share/ums/debug.log" ]; then
        mv "/usr/share/ums/debug.log" "/usr/share/ums/debug.log.1"
    fi
    fi

    return 0
}
#--------------------------------------------------------------------------
do_force-stop(){
    running || { warnout "$NAME is NOT running !"; exit 0; }   
    echo "Stopping $DESC : $NAME"
    kill -9 $pid
    if [ -e "/usr/share/ums/debug.log" ]; then
    count=9
    while [ $count -ge 1 ]
    do
    if [ -e "/usr/share/ums/debug.log.$count" ]; then
        plus=$((count+1))
   mv "/usr/share/ums/debug.log.$count" "/usr/share/ums/debug.log.$plus"
    fi
       count=$((count-1))
    done
    if [ -e "/usr/share/ums/debug.log" ]; then
   mv "/usr/share/ums/debug.log" "/usr/share/ums/debug.log.1"
    fi
    fi
}
#--------------------------------------------------------------------------
do_status(){
    echo -n " * $NAME is "
    ( running || { echo "NOT running "; exit 0; } )
    ( running && { echo "running (PID -> $(echo $pid))"; exit 0; } )
}
#--------------------------------------------------------------------------
case "$1" in

    start|stop|force-stop|status)
        do_${1}
        ;;
    restart|reload)
        do_stop
        do_start
        ;;
    force-restart|force-reload)
        do_force-stop
        do_start
        ;;
    *)
        echo "Usage: $SCRIPTNAME {start|stop|force-stop|restart|force-restart|reload|force-reload|status}"
        exit 1
        ;;
esac

答案1

看來您使用了與我安裝 UMS 相同的腳本。我遇到了同樣的問題並找到了解決方法。該腳本在 /etc 中建立一個鏈接,指向 /root 中不存在的檔案。如果您在 /etc 上執行 ls -l 您應該看到類似以下內容:

UMS.sh < /root/.config/UMS.conf

但該腳本從未真正創建該文件,可能也沒有權限。所以我所做的就是刪除該鏈接並創建一個指向 /usr/ums/ 中的配置文件的新鏈接

sudo rm /etc/UMS.sh
sudo ln -s /usr/ums/UMS.conf /etc/UMS.sh

這最終對我有用,現在我只需編輯 UMS.conf 檔案即可進行任何更改。希望這可以幫助。

答案2

不,正確的解決方法是這樣的:

  • 以 root 身分執行 UMS.sh;它將建立設定檔 /root/.config/UMS
  • 編輯初始化腳本 /etc/init.d/ums 並將設定檔路徑放在正確的位置:UMS_PROFILE=/root/.config/UMS/

相關內容