Last change
on this file since 169 was
165,
checked in by rock, 14 years ago
|
管理介面初版完成
|
-
Property svn:executable set to
*
|
File size:
1012 bytes
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | # Program: |
---|
3 | # Add nutch_nodes to /etc/hosts (for nutchez management interface). |
---|
4 | # $1=/home/nutchuser/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 | # 附加 nutch_nodes 到 /etc/hosts |
---|
41 | cp -f /etc/hosts /etc/hosts.bak |
---|
42 | cat $1 >> $2 |
---|
Note: See
TracBrowser
for help on using the repository browser.