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