#!/bin/bash
source install_lang
####### garbage here #############
function mainFunction ( )
{
echo "$Good"
}
function braBraBra ( )
{
echo "$Bra_Bra_Bra"
}
####### garbage end ###############
####### fafa code here ###########
# 參數假設
# /home/nutchuser/NutchEZ_source下有3個檔案
# install.sh, nutch-1.0.tar.gz, apache-tomcat-6.0.18.tar.gz
# 安裝路徑為/opt/nutchEZ
Nutch_install_folder=/opt/nutchEZ
Install_source=/home/nutchuser/NutchEZ_source
NutchEZ_HOME=/opt/nutchEZ
MasterIP=`/sbin/ifconfig eth0 | grep 'inet addr' | sed 's/^.*addr://g' | sed 's/Bcast.*$//g'`
set_install_information () {
read -p "Please enter administrator's e-mail address: " admin_email
read -p "Please enter the Master DNS: " MasterDNS
}
show_info () {
echo "Administrator's e-mail address is $Admin_email."
echo "The master DNS is: $MasterDNS"
}
confirm_install_information () {
read -p "Please confirm your install infomation: 1.Yes 2.No " confirm
}
Install_Nutch () {
tar zxvf $Install_source/nutch-1.0.tar.gz /opt/
mv nutch-1.0 nutchEZ
chown -R nutchuser:nutchuser /opt/nutchEZ
set_Nutch_conf
}
set_Nutch_conf () {
set_hadoop-env
set_haoop-site
set_nutch-site
set_crawl-urlfilter
}
# set $NutchEZ_HOME/conf/hadoop-env.sh
set_hadoop-env () {
echo "set $NutchEZ_HOME/conf/hadoop-env.sh"
cat >> hadoop-env.sh << EOF
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export HADOOP_HOME=/opt/nutch
export HADOOP_LOG_DIR=/tmp/nutch/logs
export HADOOP_SLAVES=/opt/nutch/conf/slaves
EOF
}
# set $NutchEZ_HOME/conf/hadoop-site.xml
set_hadoop-site () {
echo "set $NutchEZ_HOME/conf/hadoop-site.xml"
cat > $NutchEZ_HOME/conf/hadoop-site.xml << EOF
fs.default.name
$MasterDNS:9000
The name of the default file system. Either the literal string "local" or a host:port for NDFS.
mapred.job.tracker
$MasterDNS:9001
The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in-process as a single map and reduce task.
EOF
}
set_nutch-site () {
echo "set $NutchEZ_HOME/conf/nutch-site.xml"
cat > $NutchEZ_HOME/conf/nutch-site.xml << EOF
http.agent.name
nutchuser
HTTP 'User-Agent' request header.
http.agent.description
MyTest
Further description
http.agent.url
$MasterDNS
A URL to advertise in the User-Agent header.
$MasterDNS
$Admin_email
An email address
EOF
}
###################
# undo... sed or cp
set_crawl-urlfilter () {
echo "set NutchEZ_HOME/conf/set_crawl-urlfilter.txt"
}
format_HDFS () {
echo "format HDFS..."
$NutchEZ_HOME/bin/hadoop namenode -format
}
start_up_NutchEZ (){
echo "start up NutchEZ..."
$NutchEZ_HOME/bin/start-all.sh
}
# install tomcat
Install_Tomcat () {
tar zxvf $Install_source/apache-tomcat-6.0.18.tar.gz $NutchEZ_HOME
mv $NutchEZ_HOME/apache-tomcat-6.0.18 $NutchEZ_HOME/tomcat
chown -R nutchuser:nutchuser $NutchEZ_HOME
mkdir $NutchEZ_HOME/web
jar -xvf $NutchEZ_HOME/nutch-1.0.war $NutchEZ_HOME/web
mv $NutchEZ_HOME/tomcat/webapps/ROOT $NutchEZ_HOME/tomcat/webapps/ROOT-ori
mv $NutchEZ_HOME/web $NutchEZ_HOME/tomcat/webapps/ROOT
mkdir $NutchEZ_HOME/search
set_server
set_nutch-site
}
####################
# undo...sed or cp
set_server () {
echo "$NutchEZ_HOME/tomcat/conf/server.xml"
}
####################
# undo...sed or cp
set_nutch-site () {
echo "$NutchEZ_HOME/tomcat/webapps/ROOT/WEB-INF/classes/nutch-site.xml"
}
start_up_tomcat () {
echo "start up tomcat..."
$NutchEZ_HOME/tomcat/bin/startup.sh
}