开机启动 Seafile功能实现不了

CentOS 6.8+python2.7,seafile的版本是社区版的
我在CentOS 6.8新建了一个/etc/rc.d/rc.local 脚本,

• 定位 python(python 2.6 or 2.7)
which python2.7
/usr/local/python2.7/bin/python2.7
• 在 /etc/rc.d/rc.local 脚本中, 将 python2.7路径加入到PATH字段中, 并增加 Seafile/Seahub 启动命令/usr/local/file/conf
`

假设 python 2.6(2.7) 可执行文件在 /usr/local/python2.7/bin目录下

PATH=$PATH: /usr/local/python2.7/bin

rc.local 脚本内容如下:

请将 user 改为你的Linux用户名

user=root

请将 script_path 改为你的 Seafile 文件安装路径

seafile_dir=/usr/local/file
script_path=${seafile_dir}/seafile-server-latest

sudo -u ${user} ${script_path}/seafile.sh start > /tmp/seafile.init.log 2>&1
sudo -u ${user} ${script_path}/seahub.sh start > /tmp/seahub.init.log 2>&1

CentOS 系统方法 2
RHEL/CentOS 下 , 我们通过 /etc/init.d/ 脚本将 Seafile/Seahub作为服务程序随开机启动.
创建/etc/sysconfig/seafile文件

请将 user 改为你的Linux用户名

user=root

请将 script_path 改为你的 Seafile 文件安装路径

seafile_dir=/home/haiwen /usr/local/file
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

seafile_init_log=${seafile_dir}/logs/seafile.log
seahub_init_log=${seafile_dir}/logs/seahub.log

若使用 fastcgi, 请将其设置true

fastcgi=false

fastcgi 端口, 默认为 8000.

fastcgi_port=8000
创建/etc/rc.d/init.d/seafile文件
#!/bin/bash

seafile

chkconfig: - 68 32

description: seafile

Source function library.

. /etc/init.d/functions

Source networking configuration.

. /etc/sysconfig/network

if [ -f /etc/sysconfig/seafile ];then
. /etc/sysconfig/seafile
else
echo “Config file /etc/sysconfig/seafile not found! Bye.”
exit 200
fi

RETVAL=0

start() {
# Start daemons.
echo -n $“Starting seafile: "
ulimit -n 30000
su - ${user} -c”${script_path}/seafile.sh start >> ${seafile_init_log} 2>&1"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/seafile
return $RETVAL
}

stop() {
echo -n $“Shutting down seafile: "
su - ${user} -c”${script_path}/seafile.sh stop >> ${seafile_init_log} 2>&1"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/seafile
return $RETVAL
}

See how we were called.

case “$1” in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
*)
echo $“Usage: $0 {start|stop|restart}”
RETVAL=3
esac

exit $RETVAL
创建/etc/rc.d/init.d/seahub脚本
#!/bin/bash

seahub

chkconfig: - 69 31

description: seahub

Source function library.

. /etc/init.d/functions

Source networking configuration.

. /etc/sysconfig/network

if [ -f /etc/sysconfig/seafile ];then
. /etc/sysconfig/seafile
else
echo “Config file /etc/sysconfig/seafile not found! Bye.”
exit 200
fi

RETVAL=0

start() {
# Start daemons.
echo -n $“Starting seahub: "
ulimit -n 30000
if [ $fastcgi = true ];
then
su - ${user} -c”${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log} 2>&1"
else
su - ${user} -c"${script_path}/seahub.sh start >> ${seahub_init_log} 2>&1"
fi
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/seahub
return $RETVAL
}

stop() {
echo -n $“Shutting down seafile: "
su - ${user} -c”${script_path}/seahub.sh stop >> ${seahub_init_log} 2>&1"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/seahub
return $RETVAL
}

See how we were called.

case “$1” in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
*)
echo $“Usage: $0 {start|stop|restart}”
RETVAL=3
esac

exit $RETVAL
接下来启动服务程序:
[root@localhost seafile]# cd /etc/rc.d
[root@localhost rc.d]#
chmod 550 /etc/init.d/seafile
chmod 550 /etc/init.d/seahub
chkconfig --add seafile
chkconfig --add seahub
chkconfig seahub on
chkconfig seafile on
执行:
cd /etc/rc.d/init.d
service seafile start
service seahub start

还是实现不了,请高手指导,是修改错了

建议使用 CentOS 7. 我们提供了一键安装脚本,测试过开机启动可以工作。

我的centos6.8已经正在使用了,再改成centos7,现在已经来不及了

如果是Centos7的话~

/etc/rc.d/rc.local 脚本

实际上只添加最后两句即可,${user}和${script_path}两部分替换为“用户”和“程序路径”

最重要的是需要看/etc/rc.local的权限

[root@localhost ~]# ll /etc/rc.d/rc.local
-rw-r–r--. 1 root root 477 6月 10 13:35 /etc/rc.d/rc.local(说明没有执行权限)

/etc/rc.d/rc.local没有执行权限,于是按说明的内容执行
chmod +x /etc/rc.d/rc.local

应该可以解决你的问题~~~