首页 > 代码库 > 自动安装keepalived、inotify-tools与检测

自动安装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

    touch /etc/yum.repos.d/dvd.repo

    echo "[cd]" > /etc/yum.repos.d/dvd.repo

    echo "baseurl=file:///media/Server" >> /etc/yum.repos.d/dvd.repo

    echo "gpgcheck=0" >> /etc/yum.repos.d/dvd.repo

    mount /dev/cdrom /media/

    yum install gcc gcc-c++ openssl-devel kernel-devel -y

    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


本文出自 “个人随写” 博客,请务必保留此出处http://2856499.blog.51cto.com/2846499/1535552