文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>memcached 自安装脚本

memcached 自安装脚本

时间:2010-07-02  来源:skybin090804

偷Justice哥哥的,呵呵;针对LibEventPkg=libevent-1.4.8-stable.tar.gz
McPkg=memcached-1.2.8.tar.gz
#!/bin/bash
## Prog by Justice@090922
## Modifid by Justice @091222
## memcached 1.2.8 install shell script

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
LANG=zh_CN.GB18030
export PATH
export LANG

Root=$(cd $(dirname $0);pwd)
LibEventPkg=libevent-1.4.8-stable.tar.gz
McPkg=memcached-1.2.8.tar.gz

chk_file_type() {
    GetString=$(file $ChkPkg)
    if echo "$GetString"|grep "gzip"; then FileTypeOpt="z"
    elif echo "$GetString"|grep "bzip2"; then FileTypeOpt="j"
    else echo "File type not gz/bz2: $GetString"
    fi
}

get_dir_name(){
    DirName=$(tar tvf${FileTypeOpt} $ChkPkg|head -n 1|awk  '{ print $NF }')
}

extract_pkg(){
    cd $Root
    [[ -f $ChkPkg ]] && tar xf${FileTypeOpt} $ChkPkg && echo "Extract $ChkPkg done."
}

install_pkg(){
    cd $Root
    [[ -d $DirName ]] && echo "found $DirName. Run install" || echo "cd $DirName error. exit."
    cd $DirName
    ./configure $Options  && make && make install && echo "$DirName install success."
}

fix_so_link(){
    [[ -L /$LibDir/libevent-1.4.so.2 ]] || ln -s /usr/local/lib/libevent-1.4.so.2 /$LibDir/libevent-1.4.so.2
    ls -l /$LibDir/libevent-1.4.so.2 && echo "Make soft link done!"
}

cp_init(){
    cd $Root
    ls /etc/init.d/memcached* >/dev/null || cp memcached /etc/init.d/
    ls -l /etc/init.d/memcached*
}

### Start

if `which memcached` ;then
    echo "memcached had been installed:`which memcached`"
    echo -n "reinstall? (y/n)"
    read DOIT
    case $DOIT in
    y|Y|yes)
        echo "Continue..."
    ;;
    *)
        echo "Exiting..."
        exit 1
    ;;
    esac
fi

## install libevent
cd $Root
## chk libevent

uname -a|grep "x86_64"
if [ $? -ne 0 ];then
        LibDir="lib"
else
        LibDir="lib64"
fi

if [[ -L /$LibDir/libevent-1.4.so.2 ]];then
        echo "LibEvent has been installed."
        ls -l /$LibDir/libevent-1.4.so.2
else
        Options=""
        ChkPkg=$LibEventPkg
        chk_file_type
        get_dir_name
        extract_pkg
        install_pkg
fi

## install memcache
cd $Root
ChkPkg=$McPkg
if [[ -f /usr/local/lib/libevent-1.4.so.2 ]]; then
        Options="--with-libevent=/usr/local/lib/"
else
        Options=""
fi

chk_file_type
get_dir_name
extract_pkg
install_pkg
fix_so_link
cp_init

### End

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载