Last change
on this file since 174 was
174,
checked in by rock, 14 years ago
|
新增功能 1.叢集狀態檢視 2.增加註解文字
|
-
Property svn:executable set to
*
|
File size:
1.1 KB
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | # Program: |
---|
3 | # Add nutch_nodes to /etc/hosts (for nutchez management interface). |
---|
4 | # $1=/home/nutchuser/nutchez/system/nutch_nodes |
---|
5 | # $2=/etc/hosts |
---|
6 | # Author: |
---|
7 | # Waue, Shunfa, Rock {waue, shunfa, rock}@nchc.org.tw |
---|
8 | # Version: |
---|
9 | # 1.0 |
---|
10 | # History: |
---|
11 | # 2010/06/07 Rock First release (1.0) |
---|
12 | |
---|
13 | IPs=$(cat $1 | awk '{print $1}') |
---|
14 | HOSTNAMEs=$(cat $1 | awk '{print $2}') |
---|
15 | |
---|
16 | # 刪除相同的 ip 在 /etc/hosts 和 nutch_nodes |
---|
17 | for ip_addr in $(echo $IPs) |
---|
18 | do |
---|
19 | jude=0 |
---|
20 | cat $2 | grep ${ip_addr} || jude=1 |
---|
21 | |
---|
22 | if [ $jude == 0 ]; then |
---|
23 | del_line=$(cat -n $2 | grep ${ip_addr} | awk '{print $1}') |
---|
24 | sed -i "${del_line}d" $2 |
---|
25 | fi |
---|
26 | done |
---|
27 | |
---|
28 | # 刪除相同的 hostname 在 /etc/hosts 和 nutch_nodes |
---|
29 | for host_name in $(echo $HOSTNAMEs) |
---|
30 | do |
---|
31 | jude=0 |
---|
32 | cat $2 | grep ${host_name} || jude=1 |
---|
33 | |
---|
34 | if [ $jude == 0 ]; then |
---|
35 | del_line=$(cat -n $2 | grep ${host_name} | awk '{print $1}') |
---|
36 | sed -i "${del_line}d" $2 |
---|
37 | fi |
---|
38 | done |
---|
39 | |
---|
40 | # Backup /etc/hosts |
---|
41 | cp -f "$2" "$2.bak" |
---|
42 | |
---|
43 | # attache nutch_nodes to hosts |
---|
44 | sed -i '/# NutchEz add/d' $2 |
---|
45 | echo "# NutchEz add" >>$2 |
---|
46 | cat $1 | grep -v '#' >>$2 |
---|
47 | |
---|
Note: See
TracBrowser
for help on using the repository browser.