1 | #!/bin/sh |
---|
2 | |
---|
3 | echo "$1" |
---|
4 | |
---|
5 | if [ "$1" != configure ] |
---|
6 | then |
---|
7 | exit 0 |
---|
8 | fi |
---|
9 | |
---|
10 | ln -sf /opt/nutch/bin/nutchez /usr/local/sbin/ |
---|
11 | ln -sf /opt/nutch/bin/nutchez-func.sh /usr/local/sbin/ |
---|
12 | |
---|
13 | setup_hdfsadm_user() { |
---|
14 | if ! getent passwd hdfsadm >/dev/null; then |
---|
15 | useradd hdfsadm |
---|
16 | mkdir -p /home/hdfsadm/.ssh |
---|
17 | mkdir -p /var/log/nutch |
---|
18 | ssh-keygen -t rsa -q -f /home/hdfsadm/.ssh/id_rsa -N "" |
---|
19 | cp /home/hdfsadm/.ssh/id_rsa.pub /home/hdfsadm/.ssh/authorized_keys |
---|
20 | chown hdfsadm:hdfsadm /var/log/nutch |
---|
21 | chown -R hdfsadm:hdfsadm /opt/nutch |
---|
22 | chown -R hdfsadm:hdfsadm /home/hdfsadm |
---|
23 | fi |
---|
24 | } |
---|
25 | |
---|
26 | check_root() { |
---|
27 | if ! test -e /root/.ssh/id_rsa ; then |
---|
28 | ssh-keygen -t rsa -q -f /root/.ssh/id_rsa -N "" |
---|
29 | fi |
---|
30 | if test -e /root/.ssh/id_rsa.pub ; then |
---|
31 | if ! test -e /root/.ssh/authorized_keys ; then |
---|
32 | cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys |
---|
33 | fi |
---|
34 | else |
---|
35 | ssh-keygen -t rsa -q -f /root/.ssh/id_rsa -N "" |
---|
36 | cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys |
---|
37 | fi |
---|
38 | |
---|
39 | } |
---|
40 | |
---|
41 | start_hadoop() { |
---|
42 | if getent passwd hdfsadm >/dev/null; then |
---|
43 | su -c "/opt/nutch/bin/hadoop namenode -format" hdfsadm - |
---|
44 | su -c "/opt/nutch/bin/start-all.sh" hdfsadm - |
---|
45 | else |
---|
46 | /opt/nutch/conf/hadoop-env.sh |
---|
47 | /opt/nutch/bin/hadoop namenode -format |
---|
48 | /opt/nutch/bin/start-all.sh |
---|
49 | fi |
---|
50 | } |
---|
51 | show_message() { |
---|
52 | echo "You can use the instruction : \" nutchez\" to easyly use nutch" |
---|
53 | echo "Enjoy" |
---|
54 | } |
---|
55 | show_old_message() { |
---|
56 | echo "You can quickly start by following ways [in /opt/nutch/ with root privilege]:" |
---|
57 | echo "(1) Modify the urls/urls.txt file with indicate urls, one site one line." |
---|
58 | echo "(2) Use this instruction \"bin/nutch crawl urls -dir search -depth 4 -topN 50\" to crawl web" |
---|
59 | echo "(3) Type \" tomcat/bin/startup.sh \" and use browser to check the result in http://localhost:8080/" |
---|
60 | echo "Enjoy !" |
---|
61 | } |
---|
62 | #setup_hdfsadm_user |
---|
63 | #check_root |
---|
64 | #start_hadoop |
---|
65 | show_message |
---|