自己寫的一個linux下的bash安裝

來源:互聯網
上載者:User
    每次安裝linux下的包的時候都要一個個config make make install安裝,煩,抽了個空,查了些資料,寫了個bash安裝指令碼,分別安裝了openldapujs、freeradiusujs及checkuserujs包,安裝時只需./install.sh即可,這三個包放在與install同一個目錄下的work目錄夾裡。安裝的配置在jsradius.ebuild中。install.sh #!/usr/bin/env bash CONF="jsradius.ebuild"
if [ ! -e $CONF ]
then
    echo "Can't find ujsradius.ebuild."
    exit 1
fi if [ $# -ne 1 ]
then
    echo "Only one Parameter is permitted."
    exit 1
fi source $CONF export ORIGDIR=`pwd`
export WORKDIR=${ORIGDIR}/work
export SRCDIR1=${WORKDIR}/${P1}
export SRCDIR2=${WORKDIR}/${P2}
export SRCDIR2=${WORKDIR}/${P3} ebuild_unpack() {
    #make sure we're in the right directory
    cd ${ORIGDIR}     if [ -d ${WORKDIR} ]
    then
        rm -rf ${WORKDIR}
    fi     mkdir ${WORKDIR}
    cd ${WORKDIR}
    if [ ! -e ${ORIGDIR}/${A1} ]
    then
        echo "${ORIGDIR}/${A1} does not exist.  Please download first."
        exit 1
    fi
    tar xzf ${ORIGDIR}/${A1}
    echo "Unpacked ${ORIGDIR}/${A1}."
    if [ ! -e ${ORIGDIR}/${A2} ]
    then
        echo "${ORIGDIR}/${A2} does not exist.  Please download first."
        exit 1
    fi
    tar xzf ${ORIGDIR}/${A2}
    echo "Unpacked ${ORIGDIR}/${A2}."
    if [ ! -e ${ORIGDIR}/${A3} ]
    then
        echo "${ORIGDIR}/${A3} does not exist.  Please download first."
        exit 1
    fi
    tar xzf ${ORIGDIR}/${A3}
    echo "Unpacked ${ORIGDIR}/${A2}."     #source is now correctly unpacked
} ebuild_compile() {
    if [ ! -d "${SRCDIR1}" ]
    then
        echo "${SRCDIR1} does not exist -- please unpack first."
        exit 1
    fi
    #make sure we're in the right directory
    cd ${SRCDIR1}
    user_compile_ldap
    if [ ! -d "${SRCDIR2}" ]
    then
        echo "${SRCDIR2} does not exist -- please unpack first."
        exit 1
    fi
    #make sure we're in the right directory
    cd ${SRCDIR2}
    user_compile_radius
    if [ ! -d "${SRCDIR3}" ]
    then
        echo "${SRCDIR3} does not exist -- please unpack first."
        exit 1
    fi
    #make sure we're in the right directory
    cd ${SRCDIR3}
    user_compile_checkuser
} case "${1}" in
    unpack)
        ebuild_unpack
        ;;
    compile)
        ebuild_compile
        ;;
    install)
        ebuild_install
        ;;
    all)
        ebuild_unpack
        ebuild_compile
        ebuild_install
        ;;
    *)
        echo "Please specify unpack, compile, install or all as the parameter"
        exit 1
        ;;
esacjsradius.ebuild#jsradius ebuild conf write by cz_hyfMAKEOPTS="-j2"
P1=openldapujs-2.0.25
P2=freeradiusujs-0.8.1
P3=checkuserujs-1.0
A1=${P1}.tar.gz
A2=${P2}.tar.gz
A3=${P3}.tar.gz user_compile_ldap() {         if [ -e configure ]
        then
                ./configure
                ./make depend
        fi
        make $MAKEOPTS MAKE="make $MAKEOPTS"
} user_compile_radius() {         if [ -e configure ]
        then
                ./configure
        fi
        make $MAKEOPTS MAKE="make $MAKEOPTS"
} user_compile_checkuser() {         if [ -e configure ]
        then
                ./configure
        fi
        make $MAKEOPTS MAKE="make $MAKEOPTS" }install #!/usr/bin/env bash CONF="ujsradius.ebuild"
if [ ! -e $CONF ]
then
    echo "Can't find ujsradius.ebuild."
    exit 1
fi if [ $# -ne 1 ]
then
    echo "Only one Parameter is permitted."
    exit 1
fi source $CONF export ORIGDIR=`pwd`
export WORKDIR=${ORIGDIR}/work
export SRCDIR1=${WORKDIR}/${P1}
export SRCDIR2=${WORKDIR}/${P2}
export SRCDIR2=${WORKDIR}/${P3} ebuild_unpack() {
    #make sure we're in the right directory
    cd ${ORIGDIR}     if [ -d ${WORKDIR} ]
    then
        rm -rf ${WORKDIR}
    fi     mkdir ${WORKDIR}
    cd ${WORKDIR}
    if [ ! -e ${ORIGDIR}/${A1} ]
    then
        echo "${ORIGDIR}/${A1} does not exist.  Please download first."
        exit 1
    fi
    tar xzf ${ORIGDIR}/${A1}
    echo "Unpacked ${ORIGDIR}/${A1}."
    if [ ! -e ${ORIGDIR}/${A2} ]
    then
        echo "${ORIGDIR}/${A2} does not exist.  Please download first."
        exit 1
    fi
    tar xzf ${ORIGDIR}/${A2}
    echo "Unpacked ${ORIGDIR}/${A2}."
    if [ ! -e ${ORIGDIR}/${A3} ]
    then
        echo "${ORIGDIR}/${A3} does not exist.  Please download first."
        exit 1
    fi
    tar xzf ${ORIGDIR}/${A3}
    echo "Unpacked ${ORIGDIR}/${A2}."     #source is now correctly unpacked
} ebuild_compile() {
    if [ ! -d "${SRCDIR1}" ]
    then
        echo "${SRCDIR1} does not exist -- please unpack first."
        exit 1
    fi
    #make sure we're in the right directory
    cd ${SRCDIR1}
    user_compile_ldap
    if [ ! -d "${SRCDIR2}" ]
    then
        echo "${SRCDIR2} does not exist -- please unpack first."
        exit 1
    fi
    #make sure we're in the right directory
    cd ${SRCDIR2}
    user_compile_radius
    if [ ! -d "${SRCDIR3}" ]
    then
        echo "${SRCDIR3} does not exist -- please unpack first."
        exit 1
    fi
    #make sure we're in the right directory
    cd ${SRCDIR3}
    user_compile_checkuser
} case "${1}" in
    unpack)
        ebuild_unpack
        ;;
    compile)
        ebuild_compile
        ;;
    install)
        ebuild_install
        ;;
    all)
        ebuild_unpack
        ebuild_compile
        ebuild_install
        ;;
    *)
        echo "Please specify unpack, compile, install or all as the parameter"
        exit 1
        ;;
esac參考資料:http://www-128.ibm.com/developerworks/cn/linux/shell/bash/bash-1/index.html

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.