hao1nan 发表于 2018-12-31 12:02:07

linux下自动安装keepalived、inotify

  下面是我写的在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 "" > /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
  插入系统盘,运行脚本,等待数分钟keepalived和inotify-tools自动安装完成。



页: [1]
查看完整版本: linux下自动安装keepalived、inotify