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 | |
---|
19 | init_nutchez |
---|
20 | |
---|
21 | |
---|
22 | tfile=`tempfile 2>/dev/null` || tfile=/tmp/test$$ |
---|
23 | trap "rm -f $tfile" 0 1 2 5 15 |
---|
24 | |
---|
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 |
---|
37 | |
---|
38 | rev=$? |
---|
39 | |
---|
40 | MAIN_CHOISE=`cat $tfile` |
---|
41 | |
---|
42 | case $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";; |
---|
54 | esac |
---|
55 | |
---|
56 | if [ $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 | |
---|
90 | elif [ $MAIN_CHOISE -eq 1 ];then |
---|
91 | |
---|
92 | CHECK=0 |
---|
93 | while [ $CHECK -eq 0 ]; do |
---|
94 | |
---|
95 | LOCK=1 |
---|
96 | while [ $LOCK -eq 1 ]; do |
---|
97 | # milestone M1 |
---|
98 | show_urls |
---|
99 | URL=$? |
---|
100 | echo_dialog_v "2.2 show_urls return $URL" |
---|
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 | |
---|
128 | # continue last search |
---|
129 | if [ -e ~/.nutchez/search ];then |
---|
130 | continue_previous |
---|
131 | fi |
---|
132 | # show the final checklist |
---|
133 | final_confirm |
---|
134 | FC=$? |
---|
135 | echo_dialog_v "6.3 final confirm return = $FC " |
---|
136 | # START , back, cancel |
---|
137 | # start =0 , back =1 |
---|
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 | clean_tempfile |
---|
149 | exit |
---|
150 | ;; |
---|
151 | 3) |
---|
152 | #go_to_M1 |
---|
153 | LOCK=1 |
---|
154 | CHECK=0 |
---|
155 | # temp file delete! |
---|
156 | clean_tempfile |
---|
157 | #return_console |
---|
158 | ;; |
---|
159 | 255) |
---|
160 | clean_tempfile |
---|
161 | echo_dialog_v "ESC pressed !!" |
---|
162 | ;; |
---|
163 | esac |
---|
164 | #fi |
---|
165 | done |
---|
166 | |
---|
167 | set_nutchez_p |
---|
168 | |
---|
169 | start_crawl |
---|
170 | |
---|
171 | start_tomcat |
---|
172 | |
---|
173 | # show result message |
---|
174 | |
---|
175 | show_report |
---|
176 | |
---|
177 | # Done |
---|
178 | |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | else |
---|
183 | |
---|
184 | echo_dialog_v "Main Choise is $MAIN_CHOISE ! Error !!" |
---|
185 | |
---|
186 | fi |
---|