%EA%B0%80%20%EA%B5%AC%EC%84%B1%20%ED%8C%8C%EC%9D%BC%EC%9D%84%20%EC%9D%BD%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
내 우분투 14.04에서 범용 미디어 서버를 실행하여 PS3로 영화를 스트리밍할 수 있도록 하려고 합니다(불행히도 최저 펌웨어 4.55 - 탈옥 불가능).
인터넷에서 많은 조사를 한 후에 서비스로 실행할 수 있었고 /etc/init.d/UMS.sh
다른 파일은 /usr/ums
폴더에 있습니다. 여기에는 UMS.conf
구성 파일, UMS.sh
파일, ums.jar
파일 및 기타 모든 항목이 포함됩니다.
cream
나는 파일을 편집하기 위해 ( gedit
나중에 삭제해야 하는 임시 파일을 생성하는 데 문제가 있음)을 사용했습니다 UMS.conf
.
특정 포트에서 실행되도록 하고 IP 화이트리스트를 설정하여 네트워크의 모든 사람이 내 콘텐츠에 액세스할 수 없도록 하려고 합니다.
그래서 파일을 변경하고 UMS.conf
변경 사항이 저장되었는지 다시 확인하기 위해 몇 번 로드했습니다. 하지만 그렇게 하면 다음과 같습니다.
service UMS.sh start
UMS가 시작되지만 모든 기본 구성이 사용됩니다.
도와주세요. 저는 우분투를 처음 접했으므로 안내해 주시기 바랍니다. 도움이 된다면 스크립트를 제공할 수 있지만 /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를 설치할 때 사용한 것과 동일한 스크립트를 사용한 것 같습니다. 나는이 같은 문제에 직면하여 그것을 해결할 방법을 찾았습니다. 스크립트는 존재하지 않는 /root의 파일을 가리키는 링크를 /etc에 생성합니다. /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
아니요, 올바른 수정 사항은 다음과 같습니다.
- UMS.sh를 루트로 실행하십시오. /root/.config/UMS 프로필이 생성됩니다.
- init 스크립트 /etc/init.d/ums를 편집하고 프로필 경로를 오른쪽에 입력합니다: UMS_PROFILE=/root/.config/UMS/