[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 |
---|
[100] | 13 | export NUTCH_HOME=/opt/nutchez/nutch |
---|
[89] | 14 | export NUTCH_CONF_DIR=~/.nutchez/conf |
---|
[75] | 15 | export NUTCH_LOG_DIR=~/.nutchez/log |
---|
[77] | 16 | |
---|
[100] | 17 | . /opt/nutchez/nutch/bin/nutchez-func.sh |
---|
[77] | 18 | |
---|
[101] | 19 | cd ~ |
---|
| 20 | |
---|
[94] | 21 | init_nutchez |
---|
[72] | 22 | |
---|
[91] | 23 | |
---|
[94] | 24 | tfile=`tempfile 2>/dev/null` || tfile=/tmp/test$$ |
---|
| 25 | trap "rm -f $tfile" 0 1 2 5 15 |
---|
[72] | 26 | |
---|
[94] | 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 |
---|
[72] | 39 | |
---|
[94] | 40 | rev=$? |
---|
[72] | 41 | |
---|
[94] | 42 | MAIN_CHOISE=`cat $tfile` |
---|
[68] | 43 | |
---|
[94] | 44 | case $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";; |
---|
| 56 | esac |
---|
| 57 | |
---|
| 58 | if [ $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 | |
---|
| 92 | elif [ $MAIN_CHOISE -eq 1 ];then |
---|
| 93 | |
---|
[66] | 94 | CHECK=0 |
---|
| 95 | while [ $CHECK -eq 0 ]; do |
---|
| 96 | |
---|
| 97 | LOCK=1 |
---|
| 98 | while [ $LOCK -eq 1 ]; do |
---|
| 99 | # milestone M1 |
---|
| 100 | show_urls |
---|
| 101 | URL=$? |
---|
[94] | 102 | echo_dialog_v "2.2 show_urls return $URL" |
---|
[66] | 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 | |
---|
[94] | 130 | # continue last search |
---|
| 131 | if [ -e ~/.nutchez/search ];then |
---|
| 132 | continue_previous |
---|
| 133 | fi |
---|
[66] | 134 | # show the final checklist |
---|
| 135 | final_confirm |
---|
| 136 | FC=$? |
---|
[94] | 137 | echo_dialog_v "6.3 final confirm return = $FC " |
---|
[66] | 138 | # START , back, cancel |
---|
| 139 | # start =0 , back =1 |
---|
[75] | 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) |
---|
[100] | 150 | clean_tempfile |
---|
[75] | 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) |
---|
[100] | 162 | clean_tempfile |
---|
[94] | 163 | echo_dialog_v "ESC pressed !!" |
---|
[75] | 164 | ;; |
---|
| 165 | esac |
---|
| 166 | #fi |
---|
[66] | 167 | done |
---|
| 168 | |
---|
[77] | 169 | set_nutchez_p |
---|
| 170 | |
---|
[66] | 171 | start_crawl |
---|
| 172 | |
---|
[77] | 173 | start_tomcat |
---|
[66] | 174 | |
---|
| 175 | # show result message |
---|
| 176 | |
---|
[77] | 177 | show_report |
---|
[66] | 178 | |
---|
| 179 | # Done |
---|
| 180 | |
---|
[94] | 181 | |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | else |
---|
| 185 | |
---|
| 186 | echo_dialog_v "Main Choise is $MAIN_CHOISE ! Error !!" |
---|
| 187 | |
---|
| 188 | fi |
---|