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 | set_nutchuser_passwd |
---|
27 | read -p "Please enter Administrator's e-mail address: " Admin_email |
---|
28 | read -p "Please enter the Master DNS: " MasterDNS |
---|
29 | } |
---|
30 | |
---|
31 | function set_nutchuser_passwd () { |
---|
32 | read -p "Please enter nutchuser's password : " nutchuser_passwd |
---|
33 | read -p "Please enter nutchuser's password again: " nutchuser_passwd_confirm |
---|
34 | if [ $nutchuser_passwd != $nutchuser_passwd_confirm ]; then |
---|
35 | set_nutchuser_passwd |
---|
36 | fi |
---|
37 | } |
---|
38 | |
---|
39 | function show_info () { |
---|
40 | echo "Administrator's e-mail address is $Admin_email." |
---|
41 | echo "The master DNS is: $MasterDNS" |
---|
42 | } |
---|
43 | |
---|
44 | function confirm_install_information () { |
---|
45 | read -p "Please confirm your install infomation: 1.Yes 2.No " confirm |
---|
46 | } |
---|
47 | |
---|
48 | function make_ssh_key () { |
---|
49 | su nutchuser -c 'ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ""' |
---|
50 | su nutchuser -c "cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys" |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | function set_haoop-site () { |
---|
55 | echo "set $Nutch_HOME/conf/hadoop-site.xml" |
---|
56 | cd $Nutch_HOME/conf/ |
---|
57 | cat > hadoop-site.xml << EOF |
---|
58 | <configuration> |
---|
59 | <property> |
---|
60 | <name>fs.default.name</name> |
---|
61 | <value>hdfs://$MasterIP_Address:9000</value> |
---|
62 | </property> |
---|
63 | <property> |
---|
64 | <name>mapred.job.tracker</name> |
---|
65 | <value>$MasterIP_Address:9001</value> |
---|
66 | </property> |
---|
67 | <property> |
---|
68 | <name>hadoop.tmp.dir</name> |
---|
69 | <value>/var/nutchez/nutch-nutchuser</value> |
---|
70 | </property> |
---|
71 | </configuration> |
---|
72 | EOF |
---|
73 | } |
---|
74 | |
---|
75 | # 修改nutch-site.xml中-http.agent.url, http.agent.email |
---|
76 | function set_nutch-site () { |
---|
77 | echo "set $Nutch_HOME/conf/nutch-site.xml" |
---|
78 | Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.url' | sed 's/:.*//g'` |
---|
79 | echo "debug...http.agent.url line number = $Line_NO..." |
---|
80 | sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml |
---|
81 | echo "debug...edit http.agent.url delete line $((Line_NO+1))..." |
---|
82 | sed -i ''$Line_NO'a <value>'$MasterIP_Address'</value>' $Nutch_HOME/conf/nutch-site.xml |
---|
83 | echo "debug...edit http.agent.url done..." |
---|
84 | |
---|
85 | Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.email' | sed 's/:.*//g'` |
---|
86 | echo "debug...http.agent.email line number = $Line_NO..." |
---|
87 | |
---|
88 | sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml |
---|
89 | echo "debug...edit http.agent.email delete line $((Line_NO+1))..." |
---|
90 | sed -i ''$Line_NO'a <value>'$Admin_email'</value>' $Nutch_HOME/conf/nutch-site.xml |
---|
91 | echo "debug...edit http.agent.email done..." |
---|
92 | } |
---|
93 | |
---|
94 | function format_HDFS () { |
---|
95 | echo "format HDFS..." |
---|
96 | su nutchuser -c "$Nutch_HOME/bin/hadoop namenode -format" |
---|
97 | } |
---|
98 | |
---|
99 | function start_up_NutchEZ (){ |
---|
100 | echo "start up NutchEZ..." |
---|
101 | su nutchuser -c "$Nutch_HOME/bin/start-all.sh" |
---|
102 | } |
---|
103 | |
---|
104 | function Install_Nutch () { |
---|
105 | set_haoop-site |
---|
106 | set_nutch-site |
---|
107 | } |
---|
108 | |
---|
109 | |
---|
110 | function make_client_install () { |
---|
111 | # 將Master_IP_Address給client |
---|
112 | # 打包安裝目錄(不含tomcat) |
---|
113 | # tar -czv /opt/nutchez/nutch NutchezFor_$Master_IP_Client.tar.gz |
---|
114 | echo "undo... function make_client_install" |
---|
115 | } |
---|
116 | |
---|
117 | function start_up_tomcat () { |
---|
118 | echo "start up tomcat..." |
---|
119 | sleep 10s |
---|
120 | echo "su nutchuser -c "$Tomcat_HOME/bin/startup.sh"" |
---|
121 | su nutchuser -c "$Tomcat_HOME/bin/startup.sh" |
---|
122 | } |
---|