source: nutchez-0.2/src/test/client_remove.sh @ 203

Last change on this file since 203 was 203, checked in by shunfa, 14 years ago

修改語言檔

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/bash
2# Program:
3#   remove shell script for client uninstall
4# Author:
5#   Waue, Shunfa, Rock {waue, shunfa, rock}@nchc.org.tw
6# Version:
7#    1.0
8# History:
9#   
10
11
12# TODO:
13# 此一shell 檔需於安裝時scp至system目錄下
14source ./lang_zh_TW_client_remove
15# 需要 master_install 設定的參數區
16# Master IP here
17Master_IP_Address=input.your.master.ip_address
18# Master Hostname here
19Master_Hostname=input_your_master_hostname
20
21##########  echo function  ##########
22function debug_info () {
23  if [ $? -eq 0 ]; then
24    echo -e "\033[1;35;40m info - $1 \033[0m"
25  fi
26}
27
28
29function show_info () {
30  if [ $? -eq 0 ]; then
31    echo -e "\033[1;32;40m $1 \033[0m"
32  fi
33}
34##########end echo function ##########
35
36# check root
37function check_root(){
38  debug_info "check_root"
39  if [ $USER != "root" ]; then
40    show_info "$check_root_1" # "請切換成 root 身份執行移除程式!!!"
41    exit
42  fi
43  show_info "$check_root_2" # "已確認為root身份, 將繼續執行此移除程式!"
44}
45
46# shutdown service
47function shutdown_service () {
48  show_info "$shutdown_service_echo_1" # "關閉本機服務..."
49  su nutchuser -c "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode"
50  su nutchuser -c "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker"
51  show_info "$shutdown_service_echo_2" # "本機服務已關閉"
52}
53
54# 移除檔案及資料夾
55function remove_folders () {
56  show_info "$remove_folders_echo_1" # "正在刪除安裝時所建立的檔案及資料夾..."
57  rm -rf /opt/nutchez/*
58  rm -rf /var/nutchez/*
59  show_info "$remove_folders_echo_2" # "安裝時所建立的檔案及資料夾已刪除"
60}
61
62
63# 還原/etc/hosts
64function edit_hosts () {
65  show_info "$edit_hosts_echo_1" # "修改/etc/hosts..."
66  Line_NO=`cat /etc/hosts | grep -n $Master_IP_Address | sed 's/:.*//g'`
67  sed -i ''$Line_NO'd' /etc/hosts
68  show_info "$edit_hosts_echo_2" # "完成修改/etc/hosts"
69}
70
71
72# 移除使用者
73function user_delete () {
74  show_info "$user_delete_echo_1" # "正在刪除nutchuser使用者..."
75  userdel -r nutcheruser
76  show_info "$user_delete_echo_2" # "使用者nutchuser已刪除"
77}
78
79# Main function
80function main () {
81  show_info "$main_echo_1" #"警告 - 此一程式為移除此用戶端的nutch node, 若您為誤執行此一程式, 請按Ctrl+c離開此程序!"
82  show_info "$main_echo_2" #"本執行程序將會移除安裝nutchEZ時所新增的檔案及nutchuser使用者帳號"
83# 詢問是否繼續
84  read -p "$main_echo_3" confirm # "請問是否確定移除此一節點:1.確定 2.取消"
85# 確認移除
86  if [ $confirm -eq 1 ]; then
87    check_root
88    shutdown_service
89    remove_folders
90    edit_hosts
91    user_delete
92    show_info "$main_echo_4" # "移除程序已完成!"
93  elif [ $confirm -eq 2 ]; then
94    show_info "$main_echo_5" # "您已取消移除程序!"
95    show_info "$main_echo_6" # "若要移除請再重新執行!"
96  fi
97}
98
99main
Note: See TracBrowser for help on using the repository browser.