1 | #!/bin/bash |
---|
2 | source install_lang |
---|
3 | ####### garbage here ############# |
---|
4 | function mainFunction ( ) |
---|
5 | { |
---|
6 | echo "$Good" |
---|
7 | } |
---|
8 | function braBraBra ( ) |
---|
9 | { |
---|
10 | echo "$Bra_Bra_Bra" |
---|
11 | } |
---|
12 | ####### garbage end ############### |
---|
13 | |
---|
14 | ####### fafa code here ########### |
---|
15 | User_HOME=/home/nutchuser/nutchez |
---|
16 | NutchEZ_HOME=/opt/nutchez |
---|
17 | Nutch_HOME=$NutchEZ_HOME/nutch |
---|
18 | Tomcat_HOME=$NutchEZ_HOME/tomcat |
---|
19 | Index_DB=$User_HOME/search |
---|
20 | MasterIP_Address=`/sbin/ifconfig eth0 | grep 'inet addr' | sed 's/^.*addr://g' | sed 's/Bcast.*$//g' | sed 's/ .*// '` |
---|
21 | |
---|
22 | # DNS暫時以IP取代 |
---|
23 | MasterDNS=$MasterIP_Address |
---|
24 | |
---|
25 | function set_install_information () { |
---|
26 | read -p "Please enter nutchuser's password : " nutchuser_passwd |
---|
27 | read -p "Please enter nutchuser's password again: " nutchuser_passwd_confirm |
---|
28 | if [$nutchuser_passwd != $nutchuser_passwd_confirm] |
---|
29 | set_install_information |
---|
30 | fi |
---|
31 | read -p "Please enter Administrator's e-mail address: " Admin_email |
---|
32 | read -p "Please enter the Master DNS: " MasterDNS |
---|
33 | } |
---|
34 | |
---|
35 | function show_info () { |
---|
36 | echo "Administrator's e-mail address is $Admin_email." |
---|
37 | echo "The master DNS is: $MasterDNS" |
---|
38 | } |
---|
39 | |
---|
40 | function confirm_install_information () { |
---|
41 | read -p "Please confirm your install infomation: 1.Yes 2.No " confirm |
---|
42 | } |
---|
43 | |
---|
44 | function set_haoop-site () { |
---|
45 | echo "set $Nutch_HOME/conf/hadoop-site.xml" |
---|
46 | cd $Nutch_HOME/conf/ |
---|
47 | cat > hadoop-site.xml << EOF |
---|
48 | <configuration> |
---|
49 | <property> |
---|
50 | <name>fs.default.name</name> |
---|
51 | <value>hdfs://$MasterIP_Address:9000</value> |
---|
52 | </property> |
---|
53 | <property> |
---|
54 | <name>mapred.job.tracker</name> |
---|
55 | <value>$MasterIP_Address:9001</value> |
---|
56 | </property> |
---|
57 | <property> |
---|
58 | <name>hadoop.tmp.dir</name> |
---|
59 | <value>/var/nutchez/nutch-nutchuser</value> |
---|
60 | </property> |
---|
61 | </configuration> |
---|
62 | EOF |
---|
63 | } |
---|
64 | |
---|
65 | # 修改nutch-site.xml中-http.agent.url, http.agent.email |
---|
66 | function set_nutch-site () { |
---|
67 | echo "set $Nutch_HOME/conf/nutch-site.xml" |
---|
68 | Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.url' | sed 's/:.*//g'` |
---|
69 | echo "debug...http.agent.url line number = $Line_NO..." |
---|
70 | sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml |
---|
71 | echo "debug...edit http.agent.url delete line $((Line_NO+1))..." |
---|
72 | sed -i ''$Line_NO'a <value>'$MasterIP_Address'</value>' $Nutch_HOME/conf/nutch-site.xml |
---|
73 | echo "debug...edit http.agent.url done..." |
---|
74 | |
---|
75 | Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.email' | sed 's/:.*//g'` |
---|
76 | echo "debug...http.agent.email line number = $Line_NO..." |
---|
77 | |
---|
78 | sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml |
---|
79 | echo "debug...edit http.agent.email delete line $((Line_NO+1))..." |
---|
80 | sed -i ''$Line_NO'a <value>'$Admin_email'</value>' $Nutch_HOME/conf/nutch-site.xml |
---|
81 | echo "debug...edit http.agent.email done..." |
---|
82 | } |
---|
83 | |
---|
84 | function format_HDFS () { |
---|
85 | echo "format HDFS..." |
---|
86 | $Nutch_HOME/bin/hadoop namenode -format |
---|
87 | } |
---|
88 | |
---|
89 | function start_up_NutchEZ (){ |
---|
90 | echo "start up NutchEZ..." |
---|
91 | $NutchE_HOME/bin/start-all.sh |
---|
92 | } |
---|
93 | |
---|
94 | function Install_Nutch () { |
---|
95 | set_hadoop-env |
---|
96 | set_haoop-site |
---|
97 | set_nutch-site |
---|
98 | } |
---|
99 | |
---|
100 | function Install_Tomcat () { |
---|
101 | # 設定nutch的搜尋引擎頁面到tomcat |
---|
102 | cd $Nutch_HOME |
---|
103 | mkdir web |
---|
104 | cd web |
---|
105 | jar -xvf ../nutch-1.0.war |
---|
106 | mv $Tomcat_HOME/webapps/ROOT $Tomcat_HOME/webapps/ROOT-ori |
---|
107 | cd $Nutch_HOME |
---|
108 | mv $Nutch_HOME/web $Tomcat_HOME/webapps/ROOT |
---|
109 | mkdir $Index_DB |
---|
110 | } |
---|
111 | |
---|
112 | function start_up_tomcat () { |
---|
113 | echo "start up tomcat..." |
---|
114 | $Tomcat_HOME/bin/startup.sh |
---|
115 | } |
---|