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