自动安装keepalived、inotify-tools与检测

下面是我写的在linux5.6下自动安装keepalived、inotify-tools的脚本文件,里面添加了检测功能,脚本名称取名为task_install.sh,keepalived的版本为keepalived-1.1.20.tar.gz,inotify-tools的版本为inotify-tools-3.14.tar.gz。下面是脚本源文件:

#!/bin/bash   

mount /dev/cdrom /media

        cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/local.repo

        sed -e '1c [local]' -e '3c baseurl=file:///media/Server' -e '4c enabled=1' -i /etc/yum.repos.d/local.repo

    yum -y install gcc* kernel kernel-devel openssl openssl-devel ncurses-devel libxml2-devel samba

        echo "This is Rely on package installation is complete"

    keepalived_install () {

            cd

            tar zxf keepalived-1.1.20.tar.gz

            cd keepalived-1.1.20

            ./configure --sysconfdir=/etc/ --with-kernel-dir=/usr/src/kernels/2.6.18-238.el5

            make

            make install

            cp /usr/local/sbin/keepalived /usr/sbin

            /etc/init.d/keepalived start

            chkconfig --add keepalived

            chkconfig keepalived on

    }

    inotify-tools_install () {

            cd

            tar zxf inotify-tools-3.14.tar.gz

            cd /root/inotify-tools-3.14

            ./configure --prefix=/usr/local/inotify-tools/

            make

            make install

    }

    remove_files () {

            rm -rf /root/keepalived-1.1.20.tar.gz /root/keepalived-1.1.20 /root/inotify-tools-3.14.tar.gz /root/inotify-tools-3.14

    }

    check () {

            echo "#######check installed soft error or ok ##########"

            /etc/init.d/keepalived status >/dev/null

            ret=$?

            if [ $ret -eq 0 ]; then

                    echo "keepalived installed ok!!"

            else

                    echo "keepalived installed error!!"

            fi

            ls /usr/local/inotify-tools/bin/inotifywait >/dev/null

            ret=$?

            if [ $ret -eq 0 ]; then

                    echo "inotify-tools installed ok!!"

            else

                    echo "inotify-tools installed error!!"

            fi

    }

    keepalived_install

    inotify-tools_install

    remove_files

    check


你可能感兴趣的:(自动安装keepalived)