[116] | 1 | #!/bin/bash |
---|
| 2 | source install_lang |
---|
[117] | 3 | ####### garbage here ############# |
---|
[116] | 4 | function mainFunction ( ) |
---|
| 5 | { |
---|
| 6 | echo "$Good" |
---|
| 7 | } |
---|
| 8 | function braBraBra ( ) |
---|
| 9 | { |
---|
| 10 | echo "$Bra_Bra_Bra" |
---|
| 11 | } |
---|
[117] | 12 | ####### garbage end ############### |
---|
| 13 | |
---|
| 14 | ####### fafa code here ########### |
---|
[137] | 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 |
---|
[130] | 20 | MasterIP_Address=`/sbin/ifconfig eth0 | grep 'inet addr' | sed 's/^.*addr://g' | sed 's/Bcast.*$//g' | sed 's/ .*// '` |
---|
[125] | 21 | |
---|
[137] | 22 | # DNS暫時以IP取代 |
---|
| 23 | MasterDNS=$MasterIP_Address |
---|
[125] | 24 | |
---|
[137] | 25 | function set_install_information () { |
---|
[139] | 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 () { |
---|
[137] | 32 | read -p "Please enter nutchuser's password : " nutchuser_passwd |
---|
| 33 | read -p "Please enter nutchuser's password again: " nutchuser_passwd_confirm |
---|
[139] | 34 | if [ $nutchuser_passwd != $nutchuser_passwd_confirm ]; then |
---|
| 35 | set_nutchuser_passwd |
---|
[137] | 36 | fi |
---|
[117] | 37 | } |
---|
| 38 | |
---|
[137] | 39 | function show_info () { |
---|
[125] | 40 | echo "Administrator's e-mail address is $Admin_email." |
---|
| 41 | echo "The master DNS is: $MasterDNS" |
---|
[117] | 42 | } |
---|
| 43 | |
---|
[137] | 44 | function confirm_install_information () { |
---|
[117] | 45 | read -p "Please confirm your install infomation: 1.Yes 2.No " confirm |
---|
| 46 | } |
---|
| 47 | |
---|
[139] | 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 | |
---|
[137] | 54 | function set_haoop-site () { |
---|
| 55 | echo "set $Nutch_HOME/conf/hadoop-site.xml" |
---|
| 56 | cd $Nutch_HOME/conf/ |
---|
[130] | 57 | cat > hadoop-site.xml << EOF |
---|
[125] | 58 | <configuration> |
---|
[137] | 59 | <property> |
---|
[125] | 60 | <name>fs.default.name</name> |
---|
[137] | 61 | <value>hdfs://$MasterIP_Address:9000</value> |
---|
| 62 | </property> |
---|
| 63 | <property> |
---|
[125] | 64 | <name>mapred.job.tracker</name> |
---|
[137] | 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> |
---|
[125] | 71 | </configuration> |
---|
| 72 | EOF |
---|
[117] | 73 | } |
---|
| 74 | |
---|
[137] | 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..." |
---|
[117] | 84 | |
---|
[137] | 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..." |
---|
[126] | 87 | |
---|
[137] | 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..." |
---|
[117] | 92 | } |
---|
| 93 | |
---|
[137] | 94 | function format_HDFS () { |
---|
[125] | 95 | echo "format HDFS..." |
---|
[139] | 96 | su nutchuser -c "$Nutch_HOME/bin/hadoop namenode -format" |
---|
[117] | 97 | } |
---|
| 98 | |
---|
[137] | 99 | function start_up_NutchEZ (){ |
---|
[125] | 100 | echo "start up NutchEZ..." |
---|
[139] | 101 | su nutchuser -c "$Nutch_HOME/bin/start-all.sh" |
---|
[117] | 102 | } |
---|
| 103 | |
---|
[137] | 104 | function Install_Nutch () { |
---|
[136] | 105 | set_haoop-site |
---|
| 106 | set_nutch-site |
---|
| 107 | } |
---|
| 108 | |
---|
[139] | 109 | |
---|
[140] | 110 | function client_PassMasterIPAddr () { |
---|
| 111 | Line_NO=`cat client_install | grep -n '# Master IP here' | sed 's/:.*//g'` |
---|
| 112 | echo "debug...Master IP here line number = $Line_NO..." |
---|
| 113 | sed -i ''$((Line_NO+1))'d' client_install |
---|
| 114 | echo "debug...edit Master IP at line $((Line_NO+1))..." |
---|
| 115 | sed -i ''$Line_NO'a Master_IP_Address='$MasterIP_Address'' client_install |
---|
| 116 | echo "edit client_install done..." |
---|
| 117 | } |
---|
| 118 | |
---|
[139] | 119 | function make_client_install () { |
---|
| 120 | # 將Master_IP_Address給client |
---|
| 121 | # 打包安裝目錄(不含tomcat) |
---|
[140] | 122 | echo "function make_client_install..." |
---|
| 123 | client_PassMasterIPAddr |
---|
[144] | 124 | su nutchuser -c "tar -cvzf /opt/nutchez/NutchezForClientOf_$Master_IP_Address.tar.gz /home/nutchuser/nutchez/" |
---|
[131] | 125 | } |
---|
| 126 | |
---|
[137] | 127 | function start_up_tomcat () { |
---|
[125] | 128 | echo "start up tomcat..." |
---|
[139] | 129 | sleep 10s |
---|
| 130 | echo "su nutchuser -c "$Tomcat_HOME/bin/startup.sh"" |
---|
| 131 | su nutchuser -c "$Tomcat_HOME/bin/startup.sh" |
---|
[117] | 132 | } |
---|
[144] | 133 | |
---|
| 134 | function client_install_command () { |
---|
| 135 | WhereAmI=pwd |
---|
| 136 | echo "Client Install Command as Follows:" |
---|
| 137 | echo "cd ~" |
---|
| 138 | echo "mkdir NutchezClientInstall" |
---|
| 139 | echo "scp $WhereAmI/* ~/NutchezClientInstall" |
---|
| 140 | echo "./client_install" |
---|
| 141 | } |
---|