Index: nutchez-0.2/src/test/install_func.sh
===================================================================
--- nutchez-0.2/src/test/install_func.sh	(revision 117)
+++ nutchez-0.2/src/test/install_func.sh	(revision 125)
@@ -16,33 +16,23 @@
 ####### fafa code here ###########
 
+# 參數假設
+# /home/nutchuser/NutchEZ_source下有3個檔案
+# install.sh, nutch-1.0.tar.gz, apache-tomcat-6.0.18.tar.gz
+# 安裝路徑為/opt/nutchEZ
+
+Nutch_install_folder=/opt/nutchEZ
+Install_source=/home/nutchuser/NutchEZ_source
+NutchEZ_HOME=/opt/nutchEZ
+MasterIP=`/sbin/ifconfig eth0 | grep 'inet addr' |  sed 's/^.*addr://g' | sed 's/Bcast.*$//g'`
+
+
 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
+  read -p "Please enter the Master DNS:  " MasterDNS
 }
 
 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
+  echo "Administrator's e-mail address is $Admin_email."
+  echo "The master DNS is: $MasterDNS"
 }
 
@@ -51,119 +41,123 @@
 }
 
-# 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
-
+Install_Nutch () {
+  tar zxvf $Install_source/nutch-1.0.tar.gz /opt/
+  mv nutch-1.0 nutchEZ
+  chown -R nutchuser:nutchuser /opt/nutchEZ
+  set_Nutch_conf
 }
 
-# set $Hadoop_HOME/conf/hadoop-env.sh
-set_hadoop-env () {
-  echo "set $Hadoop_HOME/conf/hadoop-env.sh"
+set_Nutch_conf () {
+  set_hadoop-env
+  set_haoop-site
+  set_nutch-site
+  set_crawl-urlfilter
 }
 
-# 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"
+# set $NutchEZ_HOME/conf/hadoop-env.sh
+set_hadoop-env () {
+  echo "set $NutchEZ_HOME/conf/hadoop-env.sh"
+  cat >> hadoop-env.sh << EOF
+export JAVA_HOME=/usr/lib/jvm/java-6-sun
+export HADOOP_HOME=/opt/nutch
+export HADOOP_LOG_DIR=/tmp/nutch/logs
+export HADOOP_SLAVES=/opt/nutch/conf/slaves
+EOF
 }
 
-# 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
+# set $NutchEZ_HOME/conf/hadoop-site.xml
+set_hadoop-site () {
+  echo "set $NutchEZ_HOME/conf/hadoop-site.xml"
+  cat > $NutchEZ_HOME/conf/hadoop-site.xml << EOF
+<configuration>
+<property>
+    <name>fs.default.name</name>
+    <value>$MasterDNS:9000</value>
+    <description> The name of the default file system. Either the literal string "local" or a host:port for NDFS. </description>
+</property>
+<property>
+    <name>mapred.job.tracker</name>
+    <value>$MasterDNS:9001</value>
+    <description> The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in-process as a single map and reduce task. </description>
+</property>
+</configuration>
+EOF
+}
 
+set_nutch-site () {
+  echo "set $NutchEZ_HOME/conf/nutch-site.xml"
+  cat > $NutchEZ_HOME/conf/nutch-site.xml << EOF
+<configuration>
+<property>
+  <name>http.agent.name</name>
+  <value>nutchuser</value>
+  <description>HTTP 'User-Agent' request header. </description>
+</property>
+<property>
+  <name>http.agent.description</name>
+  <value>MyTest</value>
+  <description>Further description</description>
+</property>
+<property>
+  <name>http.agent.url</name>
+  <value>$MasterDNS</value>
+  <description>A URL to advertise in the User-Agent header. </description>
+</property>
+<property>
+  <name>$MasterDNS</name>
+  <value>$Admin_email</value>
+  <description>An email address
+  </description>
+</property>
+</configuration>
+EOF
 }
-# 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         *
-#**************************************************
+###################
+# undo... sed or cp
+set_crawl-urlfilter () {
+  echo "set NutchEZ_HOME/conf/set_crawl-urlfilter.txt"
+}
 
-# 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"
+format_HDFS () {
+  echo "format HDFS..."
+  $NutchEZ_HOME/bin/hadoop namenode -format
 }
 
 
-#******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
+start_up_NutchEZ (){
+  echo "start up NutchEZ..."
+  $NutchEZ_HOME/bin/start-all.sh
+}
+
+# install tomcat
+Install_Tomcat () {
+  tar zxvf $Install_source/apache-tomcat-6.0.18.tar.gz $NutchEZ_HOME
+  mv $NutchEZ_HOME/apache-tomcat-6.0.18 $NutchEZ_HOME/tomcat
+  chown -R nutchuser:nutchuser $NutchEZ_HOME
+  mkdir $NutchEZ_HOME/web
+  jar -xvf $NutchEZ_HOME/nutch-1.0.war $NutchEZ_HOME/web
+  mv $NutchEZ_HOME/tomcat/webapps/ROOT $NutchEZ_HOME/tomcat/webapps/ROOT-ori
+  mv $NutchEZ_HOME/web $NutchEZ_HOME/tomcat/webapps/ROOT
+  mkdir $NutchEZ_HOME/search
+  set_server
+  set_nutch-site
+}
+
+####################
+# undo...sed or cp
+set_server () {
+  echo "$NutchEZ_HOME/tomcat/conf/server.xml"
+}
+
+####################
+# undo...sed or cp
+set_nutch-site () {
+  echo "$NutchEZ_HOME/tomcat/webapps/ROOT/WEB-INF/classes/nutch-site.xml"
 }
 
 
-# format HDFS
-format_HDFS () {
-  echo "format HDFS"
+start_up_tomcat () {
+  echo "start up tomcat..."
+  $NutchEZ_HOME/tomcat/bin/startup.sh
 }
-
-# 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"
-}
