建立keepalived目录,里面已经存放了下载并解压的keepalived-1.2.7目录,包括和用于作为系统服务的keepalived脚本
注意,是前面一文修改过后能用于Ubuntu的版本。
install.sh脚本内容:
#!/bin/bash source ../common/tool.sh libssl="libssl-dev" openssl="openssl" popt="libpopt-dev" daemonService="daemon" installDpkg $libssl installDpkg $openssl installDpkg $popt installDpkg $daemonService cd keepalived-1.2.7 ./configure --prefix=/usr make make install cd .. cp ./keepalived /etc/init.d/ cd /etc/init.d/ update-rc.d keepalived start 21 2 3 4 5 . stop 21 0 1 6 . #update-rc.d keepalived default createFolder "/var/lock/subsys" cd - make clean service keepalived start
里面使用了一个新的函数installDpkg,定义在tool.sh脚本中:#$1 dpkg name function installDpkg { hasDpkg $1 r=$? if [ $r -eq 1 ] then echo "$1 was installed" else echo "$1 was not installed, installing..." apt-get install $1 fi }
keepalived的目录结构如下:keepalived# tree -L 2 . ├── install.sh ├── install.sh~ ├── keepalived ├── keepalived~ └── keepalived-1.2.7 ├── AUTHOR ├── bin ├── ChangeLog ├── config.log ├── config.status ├── configure ├── configure.in ├── CONTRIBUTORS ├── COPYING ├── doc ├── genhash ├── INSTALL ├── install-sh ├── keepalived ├── keepalived.spec ├── keepalived.spec.in ├── lib ├── Makefile ├── Makefile.in ├── README ├── TODO └── VERSION 6 directories, 21 files