如何在CentOS中设置mailcatcher并作为服务运行

Pau*_*aul 3 centos mailcatcher

我已经按照本教程中的步骤进行操作,但是无法正常工作。

https://serversforhackers.com/setting-up-mailcatcher

但是,我确实成功安装了mailcatcher并进行了测试。它正在工作,但是我不能将其作为服务运行。

有人知道如何在CentOS中做到这一点吗?谢谢。

mar*_*kux 5

由root用户或sudoer用户执行的所有操作。

  1. 创建文件/etc/init.d/mailcatcher
  2. 向其中添加以下内容(来自https://gist.github.com/oppara/c4233b289c86e2b3cb66):

    
    #!/bin/sh
    # chkconfig: 345 99 1
    # description: mailcatcher
    # processname: mailcatcher
    
    start() {
        echo -n "starting mailcatcher:"
        /usr/local/rbenv/shims/mailcatcher --http-ip=0.0.0.0
        return 0
    }
    
    stop() {
        killall mailcatcher
        return 0
    }
    
    case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        *)
            echo $"Usage: $0 {start|stop}"
            exit 2
    esac
    
    exit 0
    
    
    Run Code Online (Sandbox Code Playgroud)
  3. 使文件可执行:

    chmod +x /etc/init.d/mailcatcher
    Run Code Online (Sandbox Code Playgroud)
  4. 添加可用服务:

    chkconfig --add mailcatcher
    Run Code Online (Sandbox Code Playgroud)
  5. 启用服务:

    chkconfig mailcatcher on
    Run Code Online (Sandbox Code Playgroud)
  6. 使用以下命令启动或停止服务:

    service mailcatcher stop|start
    Run Code Online (Sandbox Code Playgroud)