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