我该如何调整这个debian init.d脚本才能使用CentOS 5?

我试图让一个lsyncd守护进程运行。 我从epel安装了lsyncd RPM,但似乎没有带有init.d脚本。 在lsyncd存储库中,有这个脚本可以与Debian一起使用。 但是,当我尝试在CentOS下运行这个时,我得到这个消息:

/etc/init.d/lsyncd: line 46: log_daemon_msg: command not found 

我怎样才能适应这与CentOS的工作?

从头开始编写可能会更容易,取决于脚本的复杂程度。 您遇到的问题是脚本中的这一行:

 . /lib/lsb/init-functions 

它加载了debian的启动脚本的所有function。 在这是一个函数“log_daemon_msg”这是你的问题在哪里。

你可以看一下init函数文件来确定log_daemon_msg的作用,并在CentOS上复制,或者你可以通过Debian脚本查看实际运行的内容(可能less于5行命令)

/usr/share/doc/initscripts-*/sysvinitfiles包含一个模板,您可以将其用作修改现有脚本或创build新脚本的模型。

我遇到过同样的问题。 下面是我想到的其他build议,init.d教程,以及在lsyncd googlecode站点链接文本中find的现有debian脚本。 希望这有助于他人,只需复制和粘贴!

 #!/bin/bash # # lsyncd This shell script takes care of starting and stopping # lsyncd (the Live Syncing (Mirror) Daemon) # # Author: Randy Reddekopp [email protected] # # chkconfig: 2345 13 87 # description: Lsyncd uses rsync to synchronize local directories with a remote \ # machine running rsyncd. It watches multiple directories trees \ # through inotify. The first step after adding the watches is to \ # rsync all directories with the remote host, and then sync single \ # file by collecting the inotify events. So lsyncd is a light-weight \ # live mirror solution. # pidfile: /var/run/lsyncd.pid # processname: lsyncd # Source function library. . /etc/init.d/functions PIDFILE="/var/run/lsyncd.pid" LSYNCD_DIR="/usr/local/bin/" start() { echo -n "Starting Live Syncing Daemon: " if [ -f $PIDFILE ]; then PID=`cat $PIDFILE` echo lsyncd already running: $PID exit 1; else cd $LSYNCD_DIR daemon ./lsyncd $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lsyncd return $RETVAL fi } stop() { echo -n "Shutting down Live Syncing Daemon: " echo killproc lsyncd echo rm -f /var/lock/subsys/lsyncd return 0 } case "$1" in start) start ;; stop) stop ;; status) status lsyncd ;; restart) stop start ;; *) echo "Usage: {start|stop|status|restart}" exit 1 ;; esac exit $? 

将该代码粘贴到/etc/init.d/lsyncd中。

更改文件权限:

chmod 755 /etc/init.d/lsyncd

在/etc/lsyncd.conf.xml文件中,您需要取消注释“<pidfile … />”节点,并将其文件名属性设置为“/var/run/lsyncd.pid”。

那么你应该设置启动服务!

/ sbin / service lsyncd启动

干杯,兰迪