source: nutchez-0.1/bin/nutchez @ 94

Last change on this file since 94 was 94, checked in by waue, 15 years ago

0.1-2 fix some bug

  • Property svn:executable set to *
File size: 4.1 KB
RevLine 
[66]1#!/bin/bash
2# Author: WeiYu Chen <waue _at_ nchc org tw>
3# License: GPL
4# Description: Eazily use for Nutch
5# .
6
[69]7# begining ..
[67]8
[72]9
10#. "$bin"/nutchez-func.sh
11
[91]12  export JAVA_HOME=/usr/lib/jvm/java-6-sun
13  export NUTCH_HOME=/opt/nutch
[89]14  export NUTCH_CONF_DIR=~/.nutchez/conf
[75]15  export NUTCH_LOG_DIR=~/.nutchez/log
[77]16
[94]17. /opt/nutch/bin/nutchez-func.sh
[77]18
[94]19init_nutchez
[72]20
[91]21
[94]22tfile=`tempfile 2>/dev/null` || tfile=/tmp/test$$
23trap "rm -f $tfile" 0 1 2 5 15
[72]24
[94]25$DIALOG --backtitle "Developed By NCHC" --clear --item-help --title "NutchEz 雛型版" \
26        --menu " 你好,歡迎使用NutchEz! \n\
27這套軟體是用來打造專屬於你的搜尋引擎 \n\
28你有網頁不希望被公開的搜尋引擎找到, \n\
29卻又希望能有個搜尋介面的困擾嗎? \n\
30用NutchEz就對了!因為他操作簡單, \n\
31除了基本的網頁以外,還支援多種格式(ppt,doc,txt...) \n\
32並且是開源碼軟體,完全免費,安全無虞\n\
33趕快來使用看看吧!\n\n\
34          選擇你要的模式:" 20 60 4 \
35        "1"  "開始建構搜尋內容"    "透過NutchEz來建構專屬於你自己所需的內容的搜尋引擎" \
36        "2"  "開啟或關閉NutchEz的網頁伺服器"  "若您之前已經執行完1之後才需做網頁伺服器的管理" 2> $tfile
[72]37
[94]38rev=$?
[72]39
[94]40MAIN_CHOISE=`cat $tfile`
[68]41
[94]42case $rev in
43  0)
44    echo_dialog_v "OK '$MAIN_CHOISE' chosen.";;
45  1)
46    echo_dialog_v "Cancel pressed."
47    exit 0 ;;
48  2)
49    echo_dialog_v "HELP '$MAIN_CHOISE' chosen.";;
50  255)
51    echo_dialog_v "ESC pressed.";;
52  *)
53    echo_dialog_v "Unexpected code $MAIN_CHOISE";;
54esac
55
56if [ $MAIN_CHOISE -eq 2 ];then
57
58  pid_tc=$(ps axw -eo pid,command |\
59  grep "catalina" | grep "java" |\
60  grep "start" | awk '{print $1}')
61  if [ -z "$pid_tc" ]; then
62      echo_dialog_v "0. pid = $pid_tc ! no another toddmcat is running"
63
64      $DIALOG --title "你的NutchEz網頁伺服器沒打開.." --clear \
65        --yesno "\n 要開啟NutchEz的網頁伺服器嗎? \n" 15 61
66      if [ $? -eq 0 ];then
67          ~/.nutchez/tomcat/bin/startup.sh
68    PORT=`cat ~/.nutchez/sav/n.tomcat.txt`
69          $DIALOG --msgbox "已經試著開啟瀏覽伺服器,你可以瀏覽這個網址看看: \n  http://localhost:$PORT" 0 0
70      else 
71    $DIALOG --msgbox "你選擇不要打開瀏覽伺服器!" 0 0
72      fi
73     
74  else
75      echo_dialog_v "0. tomcat had been started and the pid is $pid_tc"
76
77      $DIALOG --title "偵測到NutchEz的網頁伺服器正在運作.." --clear \
78        --yesno "\n 你要關閉他嗎? \n" 15 61
79      if [ $? -eq 0 ];then
80          ~/.nutchez/tomcat/bin/shutdown.sh
81    kill -9 $pid_tc
82          $DIALOG --msgbox "已經試著關閉NutchEz網頁伺服器" 0 0
83      else 
84          $DIALOG --msgbox "你選擇不要關閉瀏覽伺服器!" 0 0
85      fi
86
87  fi
88  exit 0
89
90elif [ $MAIN_CHOISE -eq 1 ];then
91
[66]92CHECK=0
93while [ $CHECK -eq 0 ]; do
94
95  LOCK=1
96  while [ $LOCK -eq 1 ]; do
97    # milestone M1
98    show_urls
99    URL=$?
[94]100    echo_dialog_v "2.2 show_urls return $URL"
[66]101   
102# add or delete url:  ok , exit
103# ok =0 , exit =1
104
105    if [ $URL -eq 0 ];then
106      # go_to_M2
107      LOCK=0
108    else
109      #return_console
110      exit
111    fi
112
113  done
114  # milestone M2
115
116  # setup search engine personality
117  #   next, back
118  setup_robot
119
120  # setup the crawl paramater
121  #   next, back
122  setup_crawler
123
124  # setup the tomcat paramater
125  #   next, back
126  setup_tomcat
127
[94]128  # continue last search
129  if [ -e ~/.nutchez/search ];then
130    continue_previous
131  fi
[66]132  # show the final checklist
133  final_confirm
134  FC=$?
[94]135  echo_dialog_v "6.3 final confirm return = $FC "
[66]136  #   START , back, cancel
137  # start =0 , back =1
[75]138  #if [ $FC -eq 0 ];then
139  case $FC in
140    0)
141      #go_to_M3
142      CHECK=1
143      # change temp file as conf file
144      promote_tempfile
145      ;;
146    #else
147    1)
148      exit
149      ;;
150    3)
151      #go_to_M1
152      LOCK=1
153      CHECK=0
154      # temp file delete!
155      clean_tempfile
156      #return_console
157      ;;
158    255)
[94]159      echo_dialog_v "ESC pressed !!"
[75]160      ;;
161  esac
162    #fi
[66]163done
164
[77]165set_nutchez_p
166
[66]167start_crawl
168
[77]169start_tomcat
[66]170
171# show result message
172
[77]173show_report
[66]174
175# Done
176
[94]177
178
179
180else
181
182  echo_dialog_v "Main Choise is $MAIN_CHOISE ! Error !!"
183
184fi
Note: See TracBrowser for help on using the repository browser.