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 | load_default_lang |
---|
41 | check_info |
---|
42 | show_info "$MI_main_echo_1" |
---|
43 | # show_info "歡迎使用NutchEZ, 此安裝程序會為您新建一個nutchuser帳號並協助您設定密碼" |
---|
44 | set_install_information |
---|
45 | show_master_info |
---|
46 | read -p "$MI_main_echo_2" confirm |
---|
47 | # read -p "Please confirm your install infomation: 1.Yes 2.No " confirm |
---|
48 | if [ $confirm -eq 1 ]; then |
---|
49 | creat_nutchuser_account $Nutchuser_Passwd |
---|
50 | make_ssh_key |
---|
51 | # 解壓縮 |
---|
52 | # tar -zxvf nutchezV2-current.tar.gz -C /opt/ |
---|
53 | unzip_nV2_pack |
---|
54 | |
---|
55 | |
---|
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" |
---|
60 | su nutchuser -c "mkdir /home/nutchuser/nutchez/source" |
---|
61 | su nutchuser -c "mkdir /home/nutchuser/nutchez/system" |
---|
62 | |
---|
63 | Install_Nutch |
---|
64 | |
---|
65 | if [ ! -d "/var/nutchez" ]; then |
---|
66 | mkdir /var/nutchez |
---|
67 | fi |
---|
68 | |
---|
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 | |
---|
75 | chown -R nutchuser:nutchuser /opt/nutchez |
---|
76 | chown -R nutchuser:nutchuser /var/nutchez |
---|
77 | |
---|
78 | # 系統路徑鍊結 |
---|
79 | ln -sf /home/nutchuser/nutchez/system/nutchez /usr/local/bin/nutchez |
---|
80 | # 將網頁管理預設密碼寫入隱藏檔, 供網頁預設登入密碼使用 |
---|
81 | su nutchuser -c "echo "nutchuser" > /home/nutchuser/nutchez/system/.passwd" |
---|
82 | chmod 600 /home/nutchuser/nutchez/system/.passwd |
---|
83 | make_client_install |
---|
84 | # 啟動系統 |
---|
85 | format_HDFS |
---|
86 | start_up_NutchEZ |
---|
87 | start_up_tomcat |
---|
88 | # 安裝流程結束,並進入網頁管理頁面設定爬網網址...等 |
---|
89 | show_info "$MI_main_echo_3" |
---|
90 | # show_info "Install Successfully!!" |
---|
91 | show_info "$MI_main_echo_4" |
---|
92 | # show_info "Visit http://$MasterIP_Address:8080" |
---|
93 | client_install_commands |
---|
94 | elif [ $confirm -eq 2 ]; then |
---|
95 | main |
---|
96 | fi |
---|
97 | } |
---|
98 | |
---|
99 | main |
---|