bash 指令碼編程十八 Keepalived自動部署

來源:互聯網
上載者:User

緊接前面手工部署Keepalived的文章,這次來自動部署。

建立keepalived目錄,裡面已經存放了下載並解壓的keepalived-1.2.7目錄,包括和用於作為系統服務的keepalived指令碼

注意,是前面一文修改過後能用於ubuntu的版本。

install.sh指令碼內容:

#!/bin/bash source ../common/tool.shlibssl="libssl-dev"openssl="openssl"popt="libpopt-dev"daemonService="daemon"installDpkg $libsslinstallDpkg $opensslinstallDpkg $poptinstallDpkg $daemonServicecd keepalived-1.2.7./configure --prefix=/usrmakemake installcd ..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 defaultcreateFolder "/var/lock/subsys"cd -make cleanservice keepalived start

裡面使用了一個新的函數installDpkg,定義在tool.sh指令碼中:

#$1 dpkg namefunction installDpkg {    hasDpkg $1    r=$?        if [ $r -eq 1 ]    thenecho "$1 was installed"    elseecho "$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    └── VERSION6 directories, 21 files

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.