2017-02-12 53 views
0

我使用direct download在我的服务器上安装了Icecast 2.4.3以获取最新版本。如何将icecast制作为服务并重新启动?

这样,我不使用我的发行版(debian 8)发布的版本,因此没有默认激活的守护进程。

我发现一个脚本,我修改了我的相应路径,但执行出错。

脚本icecast.sh

#!/bin/bash 
# 
# Init file for Icecast server daemon 
# 
# chkconfig: 345 55 25 
# description: Icecast streaming mp3 server daemon 
# 
# processname: icecast 
# config: /etc/icecast.xml 
# pidfile: /var/run/icecast.pid 

# source function library 
# . /etc/rc.d/init.d/functions : returns an error on debian 8 
. /lib/lsb/init-functions 

# pull in sysconfig settings 
[ -f /etc/sysconfig/icecast ] && . /etc/sysconfig/icecast 

RETVAL=0 
prog="icecast" 

# Some functions to make the below more readable 
PREFIX=/usr/local 
PATH=$PATH:$PREFIX/bin 
PIDFILE=/icecast/icecast.pid 
CONF_FILE=/icecast/conf/icecast.xml 

[ -f $PREFIX/bin/icecast ] || (echo Failed to locate icecast binary: $PREFIX/bin/icecast && exit) 
[ -f $CONF_FILE   ] || (echo Failed to locate icecast configuration file: $CONF_FILE && exit) 

OPTIONS="-b -c $CONF_FILE" 

start() 
{ 
    echo -n $"Starting $prog:" 
    ulimit -c unlimited # dump core for debugging purposes 
    ulimit -n 32768 
    daemon icecast icecast $OPTIONS 
    RETVAL=$? 
    [ "$RETVAL" = 0 ] && touch /var/lock/subsys/icecast 
    echo 
    pidof icecast > $PIDFILE 
    return $RETVAL 
} 

stop() 
{ 
    echo -n $"Stopping $prog:" 
    killproc icecast -TERM 
    RETVAL=$? 
    [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/icecast 
    echo 
    rm -f $PIDFILE 
    return $RETVAL 
} 

reload() 
{ 
    echo -n $"Reloading $prog:" 
    killproc icecast -HUP 
    RETVAL=$? 
    echo 
    return $RETVAL 
} 

condrestart() 
{ 
    [ -e /var/lock/subsys/icecast ] && restart 
    return 0 
} 

case "$1" in 
    start) 
     start 
     ;; 
    stop) 
     stop 
     ;; 
    restart) 
     stop 
     # wait for listening sockets to clear 
     echo "Waiting 5 seconds before restarting..." 
     sleep 5 
     start 
     ;; 
    reload) 
     reload 
     ;; 
    condrestart) 
     condrestart 
     ;; 
    status) 
     status icecast 
     RETVAL=$? 
     ;; 
    *) 
     echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" 
     RETVAL=1 
esac 
exit $RETVAL 

而当我在做sh icecast.sh status我得到的错误:

# sh icecast.sh status 
icecast.sh: line 93: status : unknow command 

Q1:如何解决这个问题?

Q2:如何获得像icecast restart service这样的功能指令?

Q3:如果服务器自行重新启动,我应该怎么做才能自动重启Icecast?

回答

1
  1. 从你的发行版安装一个软件包(apt-get install icecast2yum install icecast,无论)。通常pakage manager还会安装初始化脚本,这将允许您启动/停止Icecast。
  2. 让您的Icecast patht与which icecastwhereis icecast
  3. 下载的Icecast,从源代码构建它(比如,如果你需要的Icecast-KH分支取代官方的Icecast或使用您自己的编译标志)。
  4. 将(2)中的原始icecast二进制替换为您构建的那个。但是,备份原始版本总是更好。
  5. /etc/inid/icecast restartsystemctr restart iecast现在应该与您的Icecast版本一起工作。
  6. 为了确保重启运行后您的Icecast将开始 systemctl enable icecast
+0

感谢您的解释以及重新启动后如何启动 – Zl3n

2

答案是使用来自debian backports正确的包,或者如果你是需要TLS支持来自official Xiph.org repositories的包。

这保证,您将收到包更新,而无需自己监控发布并找出必要的更改。

同时请注意,此时的Linux/Unix的最新版本是2.4.2,因为2.4.3是一个的Windows仅释放。如果为Linux/Unix编译,代码是相同的。

+0

谢谢您的回答!这就是我对自己说的。但因为我有服务器正在生产......我尝试了另一种方式。您是否认为我可以并行进行全新安装,因为我知道我不会将它安装在相同的路径中?另一件事是,[Xiph.org回购](http://download.opensuse.org/repositories/multimedia:/xiph/Debian_8。0 /)版本自动安装守护进程? – Zl3n

+0

默认情况下,除非被覆盖,否则它将安装到/ usr/local,并且二进制名称将是'icecast'。虽然debian包装使用二进制名称'icecast2'和非本地前缀。并行安装应该没有问题。 debian和xiph.org软件包都安装了一项服务。无论如何,包几乎是相同的。一旦你快乐起来,你可以在icecast源目录中运行''uninstall'''来摆脱/ usr/local中的位。 – TBR

+0

感谢您的解释 – Zl3n

相关问题