[116] | 1 | #!/bin/bash |
---|
[199] | 2 | # |
---|
[195] | 3 | |
---|
[199] | 4 | # 變數宣告 |
---|
[198] | 5 | Work_Path="./" |
---|
| 6 | Work_Path_J=0 |
---|
[195] | 7 | |
---|
[198] | 8 | # Work Path setup |
---|
| 9 | echo $0 | grep '/' || Work_Path_J=1 |
---|
| 10 | if [ "$Work_Path_J" == "0" ]; then |
---|
| 11 | Work_Path=$(echo $0 | sed 's/install//') |
---|
| 12 | fi |
---|
| 13 | |
---|
[195] | 14 | # Source functions |
---|
[199] | 15 | source $Work_Path/install_func.sh |
---|
[213] | 16 | source $Work_Path/lang_link |
---|
[117] | 17 | ### real code ##### |
---|
[137] | 18 | |
---|
[150] | 19 | # 前置作業 |
---|
| 20 | # *.sh及nutchez-0.2-0531.tar.gz均在同一目錄下 |
---|
| 21 | |
---|
[164] | 22 | function show_info () { |
---|
| 23 | if [ $? -eq 0 ]; then |
---|
| 24 | echo -e "\033[1;32;40m $1 \033[0m" |
---|
| 25 | fi |
---|
| 26 | } |
---|
[125] | 27 | |
---|
[137] | 28 | main () { |
---|
[160] | 29 | check_info |
---|
[213] | 30 | show_info "$MI_main_echo_1" |
---|
[195] | 31 | # show_info "歡迎使用NutchEZ, 此安裝程序會為您新建一個nutchuser帳號並協助您設定密碼" |
---|
[117] | 32 | set_install_information |
---|
[206] | 33 | show_master_info |
---|
[213] | 34 | read -p "$MI_main_echo_2" confirm |
---|
[195] | 35 | # read -p "Please confirm your install infomation: 1.Yes 2.No " confirm |
---|
[117] | 36 | if [ $confirm -eq 1 ]; then |
---|
[161] | 37 | creat_nutchuser_account $Nutchuser_Passwd |
---|
[139] | 38 | make_ssh_key |
---|
[136] | 39 | # 解壓縮 |
---|
[218] | 40 | # tar -zxvf nutchezV2-current.tar.gz -C /opt/ |
---|
| 41 | unzip_nV2_pack |
---|
[206] | 42 | |
---|
[140] | 43 | su nutchuser -c "mkdir /home/nutchuser/nutchez" |
---|
| 44 | su nutchuser -c "mkdir /home/nutchuser/nutchez/urls" |
---|
| 45 | su nutchuser -c "touch /home/nutchuser/nutchez/urls/urls.txt" |
---|
| 46 | su nutchuser -c "mkdir /home/nutchuser/nutchez/search" |
---|
[158] | 47 | su nutchuser -c "mkdir /home/nutchuser/nutchez/source" |
---|
[213] | 48 | su nutchuser -c "mkdir /home/nutchuser/nutchez/system" |
---|
[206] | 49 | |
---|
[213] | 50 | Install_Nutch |
---|
| 51 | |
---|
| 52 | mkdir /var/nutchez |
---|
[219] | 53 | # 建立 nutch 與 tomcat 的 logs 資料夾 |
---|
| 54 | mkdir /var/nutchez/tomcat-logs |
---|
| 55 | ln -sf /var/nutchez/tomcat-logs /opt/nutchez/tomcat/logs |
---|
| 56 | mkdir /var/nutchez/logs |
---|
| 57 | ln -sf /var/nutchez/logs /opt/nutchez/nutch/logs |
---|
| 58 | |
---|
[213] | 59 | chown -R nutchuser:nutchuser /opt/nutchez |
---|
| 60 | chown -R nutchuser:nutchuser /var/nutchez |
---|
[219] | 61 | |
---|
| 62 | # 系統路徑鍊結 |
---|
| 63 | ln -sf /home/nutchuser/nutchez/system/nutchez /usr/local/sbin/nutchez |
---|
[213] | 64 | |
---|
[144] | 65 | make_client_install |
---|
[137] | 66 | # 啟動系統 |
---|
[117] | 67 | format_HDFS |
---|
| 68 | start_up_NutchEZ |
---|
[139] | 69 | start_up_tomcat |
---|
[125] | 70 | # 安裝流程結束,並進入網頁管理頁面設定爬網網址...等 |
---|
[213] | 71 | show_info "$MI_main_echo_3" |
---|
[195] | 72 | # show_info "Install Successfully!!" |
---|
[213] | 73 | show_info "$MI_main_echo_4" |
---|
[195] | 74 | # show_info "Visit http://$MasterIP_Address:8080" |
---|
| 75 | client_install_commands |
---|
[117] | 76 | elif [ $confirm -eq 2 ]; then |
---|
| 77 | main |
---|
| 78 | fi |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | main |
---|