Linux 启动MySQL后在启动时运行脚本

Linux 启动MySQL后在启动时运行脚本,linux,raspberry-pi,boot,Linux,Raspberry Pi,Boot,我想在Raspberry Pi启动时启动Seafile(需要MySQL的云服务器)。我的问题是,Seafile在mysql之前启动,并导致了许多错误,因为Seafile需要mysql。 我采用了推荐的脚本: #! /bin/sh # /etc/init.d/seafile ### BEGIN INIT INFO # Provides: seafile # Required-Start: $local_fs $remote_fs $network mysql # Requ

我想在Raspberry Pi启动时启动Seafile(需要MySQL的云服务器)。我的问题是,Seafile在mysql之前启动,并导致了许多错误,因为Seafile需要mysql。 我采用了推荐的脚本:

#! /bin/sh
# /etc/init.d/seafile

### BEGIN INIT INFO
# Provides:          seafile
# Required-Start:    $local_fs $remote_fs $network mysql
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Script to start/stop/restart seafile
# Description:       Simple script to start, stop or restart seafile for the cloud
### END INIT INFO

# Change the value of "user" to your linux user name
user=chromo

# Change the value of "script_path" to your path of seafile installation
seafile_dir=/home/chromo/cloud
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

# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=true
# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000

case "$1" in
    start)
            sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
if [  $fastcgi = true ];
            then
                    sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
            else
                    sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
            fi
    ;;
    restart)
            sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
            if [  $fastcgi = true ];
            then
                    sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
            else
                    sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
            fi
    ;;
stop)
            sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
            sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
    ;;
    *)
            echo "Usage: /etc/init.d/seafile {start|stop|restart}"
            exit 1
    ;;
esac

有人能帮我吗?

最好是在
/etc/rc[runlevel].d
文件中设置启动这些服务的优先级

在您的情况下,首先要检查的是您引导到的运行级别。您可以使用命令“
runlevel
”来检查这一点。你也可以查一下

比如说,您已经被引导到运行级别3。您可以重命名目录“
/etc/rc3.d
”中的当前seafile文件

例如:

如果这两个文件是

/etc/rc3.d/20seafile
/etc/rc3.d/50mysql
将文件重命名为
70sefile
或高于50的任何文件

这将解决您现在面临的问题

另一个解决方法是删除指向/etc/init.d目录的seafile链接,并放置一行

/etc/init.d/seafile start 
在文件内部
/etc/rc.local


请检查此项,并告诉我是否已为您解决问题。

最好是在
/etc/rc[runlevel].d
文件中设置启动这些服务的优先级

在您的情况下,首先要检查的是您引导到的运行级别。您可以使用命令“
runlevel
”来检查这一点。你也可以查一下

比如说,您已经被引导到运行级别3。您可以重命名目录“
/etc/rc3.d
”中的当前seafile文件

例如:

如果这两个文件是

/etc/rc3.d/20seafile
/etc/rc3.d/50mysql
将文件重命名为
70sefile
或高于50的任何文件

这将解决您现在面临的问题

另一个解决方法是删除指向/etc/init.d目录的seafile链接,并放置一行

/etc/init.d/seafile start 
在文件内部
/etc/rc.local


请检查此项,并让我知道它是否为您解决了问题。

谢谢您的帮助,但它对我不起作用。'runlevel'向我显示了“n2”,因此我的系统运行在2,然后我将seafile的数量设置为高于MySQL,但它不起作用。第二个解决方案也不起作用,因为rc.local似乎是执行的,只有在我按照ssh登录时才执行。好的,我现在就可以工作了!我与Debian合作,在这个发行版中,数字(如S20和S50)被忽略。我在LSB Infos中添加了必需的Start:mysql,并执行了命令sudo insserv-d.@Chromo。。伟大的不知怎的,我只想到了Centos服务器。谢谢你的帮助,但它对我不起作用。'runlevel'向我显示了“n2”,因此我的系统运行在2,然后我将seafile的数量设置为高于MySQL,但它不起作用。第二个解决方案也不起作用,因为rc.local似乎是执行的,只有在我按照ssh登录时才执行。好的,我现在就可以工作了!我与Debian合作,在这个发行版中,数字(如S20和S50)被忽略。我在LSB Infos中添加了必需的Start:mysql,并执行了命令sudo insserv-d.@Chromo。。伟大的不知怎的,我只想到Centos服务器。