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