source: nutchez-0.1/bin/nutchez @ 180

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

fix several bugs

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