#!/bin/bash source install_lang ####### garbage here ############# function mainFunction ( ) { echo "$Good" } function braBraBra ( ) { echo "$Bra_Bra_Bra" } ####### garbage end ############### ####### fafa code here ########### set_install_information () { read -p "Please select install mode, 1:Single mode 2:Cluster mode: " install_mode read -p "Please enter administrator's e-mail address: " admin_email if [ $install_mode -eq 1 ]; then select_mode="Single" read -p "Please enter the ip address: " MasterIP_Address elif [ $install_mode -eq 2 ]; then select_mode="Cluster" read -p "Please enter the master ip address: " MasterIP_Address read -p "Please enter the slaves number: " Slaves_NO for (( i=1; i<=$Slaves_NO; i=i+1 )) do read -p "Please enter the slaves of $i's ip address: " SlavesAddress$i done fi } show_info () { echo "Your choose is $select_mode install mode." echo "Administrator's e-mail address is $admin_email." echo "The master IP address is: $MasterIP_Address" if [ $install_mode -eq 2 ]; then echo "You have $Slaves_NO slaves, the list of slave as following: " for (( i=1; i<=$Slaves_NO; i=i+1)) do echo "The slaves $i: $((SlavesAddress$i))" done fi } confirm_install_information () { read -p "Please confirm your install infomation: 1.Yes 2.No " confirm } # Hadoop install Hadoop_install () { set_hadoop-env set_hadoop-site set_masters_slaves if [ $install_mode -eq 2 ]; then echo "Hadoop Cluster install version($Slaves_NO slaves...)" fi } # set $Hadoop_HOME/conf/hadoop-env.sh set_hadoop-env () { echo "set $Hadoop_HOME/conf/hadoop-env.sh" } # set $Hadoop_HOME/conf/hadoop-site.xml set_hadoop-site () { echo "set $Hadoop_HOME/conf/hadoop-site.xml" } # set $Hadoop_HOME/conf/masters and slaves set_masters_slaves () { echo "set $Hadoop_HOME/conf/masters and slaves" } # Nutch install Nutch_install () { echo "install Nutch..." echo "cp -rf $Hadoop_HOME/* $Nutch_HOME/*" echo "cp -rf $Nutch_HOME/*.jar lib/" set_nutch-site set_crawl-urlfilter if [ $install_mode -eq 2 ]; then echo "Nutch Cluster install version($Slaves_NO slaves...)" nutch_cluster_install fi } # cp -rf $Hadoop_HOME/* $Nutch_HOME/* # cp -rf $Nutch_HOME/*.jar lib/ #********these steps will merge with hadoop******** # set $Nutch_HOME/conf/hadoop-env.sh * # source ./$Nutch_HOME/conf/hadoop-env.sh * #************************************************** # set $Nutch_HOME/conf/nutch-site.xml set_nutch-site () { echo "set $Nutch_HOME/conf/nutch-site.xml" } # set $Nutch_HOME/conf/crawl-urlfilter.txt set_crawl-urlfilter () { echo "set $Nutch_HOME/conf/crawl-urlfilter.txt" } #******Cluster version to do********* # scp nutch_dir to the other slaves * #************************************ nutch_cluster_install () { for (( i=1; i<=$Slaves_NO; i=i+1)) do echo "ssh $((SlavesAddress$i)) chown" echo "scp nutch_dir to slave $((SlavesAddress$i))." done } # format HDFS format_HDFS () { echo "format HDFS" } # start up NutchEZ # bin/start-all.sh start_up_NutchEZ (){ echo "start up NutchEZ" } # Crawl(Maybe in administrator page to do this) # edit url list(mkdir urls and urls.txt) # upload to HDFS # bin/hadoop dfs -put urls urls # bin/nutch crawl urls -dir search -threads 2 -depth 3 -topN 100000 # or save as a log file # bin/nutch crawl urls -dir search -threads 2 -depth 3 -topN 100000 >& nutch.log #****only master do this**** # Tomcat install function * #*************************** # install tomcat set_tomcat () { echo "install tomcat.." echo "wget Tomcat" edit_server download_crawl_result } # edit $Tomcat_HOME/conf/server.xml edit_server () { echo "edit $Tomcat_HOME/conf/server.xml" } # download crawl result download_crawl_result () { echo "download crawl result" echo "bin/hadoop dfs -get search /opt/search" echo "set search engine page to tomcat" echo "set search engine page source page" } start_up_tomcat () { echo "start up tomcat" }