最近项目中使用了Sphinx搜索,有时候在服务器端管理比较麻烦。索性写个Shell脚本管理Sphinx就方便多了。

#!/bin/bash
. /etc/rc.d/init.d/functions 

appName="Sphinx"

stop(){  
        /usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx.conf --stop > /dev/null 2>&1   
        ret=$?  
        if [ $ret -eq 0 ]; then  
                action $"Stoping $appName: " /bin/true  
        else  
                action $"Stoping $appName: " /bin/false  
        fi  
        return $ret  
}  

start(){  
        /usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx.conf > /dev/null 2>&1   
        ret=$?  
        if [ $ret -eq 0 ]; then  
                action $"Starting $appName: " /bin/true  
        else  
                action $"Starting $appName: " /bin/false  
        fi  
        return $ret  
}  

indexer(){  
        /usr/local/sphinx/bin/indexer --all --rotate > /dev/null 2>&1  
        ret=$?  
        if [ $ret -eq 0 ]; then  
                action $"$appName making index: " /bin/true  
        else  
                action $"$appName making index: " /bin/false  
        fi  
        return $ret  
} 

case $1 in  
    indexer)  
    indexer  
    ;;  

    stop)  
    stop  
    ;;  

    start)  
    start  
    ;; 

    -h)
    echo 'indexer|stop|start|-h'
    ;;    
esac  

exit 0

results matching ""

    No results matching ""