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