Index: nutchez-0.1/bin/nutchez
===================================================================
--- nutchez-0.1/bin/nutchez	(revision 68)
+++ nutchez-0.1/bin/nutchez	(revision 69)
@@ -4,16 +4,11 @@
 # Description: Eazily use for Nutch
 # .
-export NUTCH_CONF_DIR=~/.nutchez
-NUTCHEZ_SCRIPT_PATH="${NUTCHEZ_SCRIPT_PATH:-/opt/nutch}"
 
-. ./nutchez-func.sh
+# begining ..
+bin=`dirname "$0"`
+bin=`cd "$bin"; pwd`
 
-
-# root ?
-#check_if_root
-
-# show url lists
-
-setup_nutchez
+. "$bin"/nutchez-func.sh
+init_nutchez
 
 CHECK=0
Index: nutchez-0.1/bin/nutchez-func.sh
===================================================================
--- nutchez-0.1/bin/nutchez-func.sh	(revision 68)
+++ nutchez-0.1/bin/nutchez-func.sh	(revision 69)
@@ -5,10 +5,23 @@
 # .
 
-. /etc/nutch/hadoop-env.sh || . $NUTCHEZ_SCRIPT_PATH/conf/hadoop-env.sh
 
 : ${DIALOG=dialog}
 
-# display more for debug
-VERB=0
+# set 1 to display more for debug, 
+VERB=1
+
+init_nutchez () {
+  if ! [ -e ~/.nutchez ] ;then
+    # copy from /etc/nutch
+    mkdir ~/.nutchez
+    cp -rf /etc/nutch/* ~/.nutchez
+    mkdir ~/.nutchez/log
+    chown -R $LOGNAME:$LOGNAME ~/.nutchez
+  fi
+  export NUTCH_CONF_DIR=~/.nutchez
+  export HADOOP_CONF_DIR=~/.nutchez
+  export HADOOP_LOG_DIR=~/.nutchez/log
+  . ~/.nutchez/hadoop-env.sh || . /etc/nutch/hadoop-env.sh
+}
 
 echo_vb () {
@@ -38,8 +51,8 @@
   echo_vb "7. chang tmp as txt"
   rm ~/.nutchez/sav/n.*.txt
-  mv /tmp/n.url.tmp ~/.nutchez/sav/
-  mv /tmp/n.robot.tmp ~/.nutchez/sav/
-  mv /tmp/n.crawler.tmp ~/.nutchez/sav/
-  mv /tmp/n.tomcat.tmp ~/.nutchez/sav/
+  mv /tmp/n.urls.tmp ~/.nutchez/sav/n.urls.txt
+  mv /tmp/n.robot.tmp ~/.nutchez/sav/n.robot.txt
+  mv /tmp/n.crawler.tmp ~/.nutchez/sav/n.crawler.txt
+  mv /tmp/n.tomcat.tmp ~/.nutchez/sav/n.tomcat.txt
 }
 
@@ -47,12 +60,4 @@
   echo_vb "7. delete tmp"
   rm /tmp/n.*.tmp
-}
-
-init_nutchez () {
-  if ! [ -e ~/.nutchez ] ;then
-    # copy from /etc/nutch
-    cp -rf /etc/nutch/* ~/.nutchez
-    chown -R $LOGNAME:$LOGNAME ~/.nutchez
-  fi
 }
 
@@ -71,5 +76,5 @@
   if [ -e ~/.nutchez/nutch-site.xml ] ; then
     # set nutch-site.xml
-    sed -ie "s/>user</>$ROBOT</" ~/.nutchez/nutch-site.xml
+    sed -i -e "4s/<value>[a-zA-Z0-9]*</<value>$ROBOT</" ~/.nutchez/nutch-site.xml
   fi
 
@@ -86,5 +91,6 @@
     fi
     # change explorer port
-    sed -ie "s/8080/>$PORT</" ~/.nutchez/tomcat/conf/server.xml
+    sed -i -e "s/<Connector port=\"[0-9]*\"/<Connector port=\"$PORT\"/" ~/.nutchez/tomcat/conf/server.xml
+  fi
 }
 
@@ -93,10 +99,10 @@
   # show urls : ok =0 ,cancel = 1
   echo_vb "2. show_urls !"
-  test_file  ~/.nutchez/sav/n.url.txt
+  test_file  ~/.nutchez/sav/n.urls.txt
   echo_vb "2.1 test_file ~/.nutchez/sav return : $?"
   # dialog begin
-  dialog  --editbox ~/.nutchez/sav/n.url.txt 16 51 2>/tmp/n.url.tmp
+  dialog  --editbox ~/.nutchez/sav/n.urls.txt 16 51 2>/tmp/n.urls.tmp
   RET=$?
-  echo_vb "2.1 cat url: `cat /tmp/n.url.tmp`"
+  echo_vb "2.1 cat url: `cat /tmp/n.urls.tmp`"
   return $RET
 }
@@ -126,9 +132,8 @@
 final_confirm () {
   echo_vb "6. final_confirm : start =0 , back =1 "
-  tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/n.finalcheck.tmp
-  #trap "rm -f $tempfile" 0 1 2 5 15
+  tempfile=/tmp/n.finalcheck.tmp
 
   echo " \n 1. The url list is : \n " > $tempfile
-  cat /tmp/n.url.tmp >> $tempfile
+  cat /tmp/n.urls.tmp >> $tempfile
   echo " \n 2. The robot name is : \n" >> $tempfile
   cat /tmp/n.robot.tmp >> $tempfile
@@ -142,5 +147,5 @@
   #read READ
   $DIALOG --title "Check It !!" --clear \
-        --yesno "$MSG" 16 51
+        --yesno "$MSG" 26 51
   RET=$?
   echo_vb "final return = $RET"
@@ -152,19 +157,26 @@
 start_crawl () {
 
-  ROBOT=`cat ~/.nutchez/sav`
-  URLS=`cat ~/.nutchez/sav`
-  DEPTH=`cat ~/.nutchez/sav`
-  PORT=`cat ~/.nutchez/sav`
+  ROBOT=`cat ~/.nutchez/sav/n.robot.txt`
+  URLS=`cat ~/.nutchez/sav/n.urls.txt`
+  DEPTH=`cat ~/.nutchez/sav/n.crawler.txt`
+  PORT=`cat ~/.nutchez/sav/n.tomcat.txt`
 
   echo_vb "7. start_crawl"
-  setup_nutch
+  setup_nutchez
   install_tomcat
-  # /opt/nutch/bin/nutch crawl ~/.nutchez/urls -dir ~/.nutchez/search -depth $DEPTH
-  echo "/opt/nutch/bin/nutch crawl ~/.nutchez/urls -dir ~/.nutchez/search -depth $DEPTH"
+  echo_vb "/opt/nutch/bin/nutch crawl ~/.nutchez/urls -dir ~/.nutchez/search -depth $DEPTH"
+  echo_vb "$NUTCH_CONF_DIR"
+  /opt/nutch/bin/nutch crawl ~/.nutchez/urls -dir ~/.nutchez/search -depth $DEPTH
 }
 
 start_tomcat () {
   echo_vb "8. start_tomcat "
-  /opt/nutch/tomcat/bin/startup.sh
+  echo_vb "/opt/nutch/tomcat/bin/startup.sh"
+  if [ -e /tmp/search ]
+    rm -rf /tmp/search
+  fi
+  ln -sf ~/.nutchez/search/ /tmp/
+  ~/.nutchez/tomcat/bin/shutdown.sh
+  ~/.nutchez/tomcat/bin/startup.sh
 }
 
@@ -173,8 +185,10 @@
   FIREFOX=`which firefox`
   RET=$?
-  if [ RET == 0 ];then 
+  if [ $RET == 0 ];then 
     $FIREFOX -D 0.0 http://localhost:$PORT
-  else
-    $DIALOG --msgbox "Congratulations! \n you can explore the url: \n  http://localhost:8080" 0 0 
+    RET=$?
+  fi
+  if ! [ $RET == 0 ];then
+    $DIALOG --msgbox "Congratulations! \n you can explore the url: \n  http://localhost:$PORT" 0 0 
   fi
 }
