[162] | 1 | #!/bin/bash |
---|
| 2 | # Program: |
---|
| 3 | # NutchEz management interface |
---|
| 4 | # Author: |
---|
| 5 | # Waue, Shunfa, Rock {waue, shunfa, rock}@nchc.org.tw |
---|
| 6 | # Version: |
---|
| 7 | # 1.0 |
---|
| 8 | # History: |
---|
| 9 | # 2010/06/07 Rock First release (1.0) |
---|
| 10 | |
---|
[172] | 11 | # [Variables Declaration] # |
---|
[186] | 12 | DIALOG="dialog" |
---|
[162] | 13 | main_choice= |
---|
[186] | 14 | lang= |
---|
[162] | 15 | |
---|
[172] | 16 | # [PATH Declaration] # |
---|
[186] | 17 | NutchEZ_Install_PATH="/opt/nutchez" |
---|
| 18 | Tomcat_HOME="/opt/nutchez/tomcat" |
---|
| 19 | NutchEZ_HOME="/home/nutchuser/nutchez" |
---|
[224] | 20 | Work_Path=$NutchEZ_HOME/system |
---|
[171] | 21 | |
---|
[219] | 22 | #Work_Path="./" |
---|
| 23 | #Work_Path_J=0 |
---|
| 24 | ## Work Path setup ## |
---|
| 25 | #echo $0 | grep '/' || Work_Path_J=1 |
---|
| 26 | #if [ "$Work_Path_J" == "0" ]; then |
---|
| 27 | # Work_Path=$(echo $0 | sed 's/nutchez//') |
---|
| 28 | #fi |
---|
[196] | 29 | |
---|
[186] | 30 | # [Env Declaration] # |
---|
[209] | 31 | . $Work_Path/lang/lang_en_US_nutchez |
---|
[186] | 32 | |
---|
[172] | 33 | # [Functions Declaration] # |
---|
[186] | 34 | ## [Pre-check for language] ## |
---|
| 35 | function prepare_lang(){ |
---|
| 36 | lang=$(locale | grep 'LANG=' | cut -d "=" -f2) |
---|
| 37 | |
---|
| 38 | # if lang=zh then source lang_zh_TW_nutchez |
---|
[237] | 39 | echo $lang | grep 'zh' && source $Work_Path/lang/lang_zh_TW |
---|
[186] | 40 | } |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | ## [Pre-Check for nutch_nodes file] ## |
---|
[162] | 44 | function prepare_check(){ |
---|
[172] | 45 | # 若無 nutchez_nodes 則跳出 |
---|
| 46 | if [ ! -e "${NutchEZ_HOME}/system/nutch_nodes" ]; then |
---|
[186] | 47 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_pre_check_title_1" \ |
---|
| 48 | --msgbox "$dia_pre_check_msg_1 $NutchEZ_HOME/system/nutch_nodes !!!" 10 40 |
---|
[162] | 49 | exit |
---|
| 50 | fi |
---|
| 51 | |
---|
[172] | 52 | # 判斷 nutch_nodes 和 nutch_nodes.back |
---|
| 53 | # 第一次執行則要求 user 更新 /etc/hosts |
---|
| 54 | if [ ! -e "${NutchEZ_HOME}/system/nutch_nodes.bak" ]; then |
---|
[186] | 55 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_pre_check_title_2" \ |
---|
| 56 | --yesno "$dia_pre_check_yesno_1\n$dia_pre_check_yesno_2" 10 55 |
---|
[162] | 57 | |
---|
[186] | 58 | echo -e "$pre_check_echo_1" |
---|
[219] | 59 | $Work_Path/duplicate_del "${NutchEZ_HOME}/system/nutch_nodes" |
---|
| 60 | su root -c "$Work_Path/duplicate_del /etc/hosts && $Work_Path/add_hosts ${NutchEZ_HOME}/system/nutch_nodes /etc/hosts" |
---|
[172] | 61 | # 若密碼輸入失敗則跳出 |
---|
| 62 | if [ $? == "1" ]; then |
---|
[186] | 63 | echo "$pre_check_echo_2" |
---|
[172] | 64 | exit |
---|
| 65 | fi |
---|
| 66 | # 若 nutch_nodes 被更新過,則要求更新 /etc/hosts |
---|
| 67 | elif [ ${NutchEZ_HOME}/system/nutch_nodes -nt ${NutchEZ_HOME}/system/nutch_nodes.bak ]; then |
---|
[186] | 68 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_pre_check_title_2" \ |
---|
| 69 | --yesno "$dia_pre_check_yesno_3\n$dia_pre_check_yesno_2" 10 55 |
---|
[165] | 70 | |
---|
[186] | 71 | echo -e "$pre_check_echo_1" |
---|
[219] | 72 | $Work_Path/duplicate_del "${NutchEZ_HOME}/system/nutch_nodes" |
---|
| 73 | su root -c "$Work_Path/duplicate_del /etc/hosts && $Work_Path/add_hosts ${NutchEZ_HOME}/system/nutch_nodes /etc/hosts" |
---|
[172] | 74 | # 若密碼輸入失敗則跳出 |
---|
| 75 | if [ $? == "1" ]; then |
---|
[186] | 76 | echo "$pre_check_echo_2=" |
---|
[172] | 77 | exit |
---|
| 78 | fi |
---|
| 79 | fi |
---|
[162] | 80 | } |
---|
| 81 | |
---|
[172] | 82 | ## [Main Menu] ## |
---|
[162] | 83 | function main_menu(){ |
---|
| 84 | main_choice="/tmp/main_choice" |
---|
| 85 | |
---|
[186] | 86 | $DIALOG --clear --backtitle "$dia_back" \ |
---|
| 87 | --title "$dia_main_title_1" \ |
---|
| 88 | --menu "$dia_choose" 15 60 7 \ |
---|
| 89 | "cluster_status" "$dia_main_menu_1_1" \ |
---|
| 90 | "cluster_setup" "$dia_main_menu_1_2" \ |
---|
| 91 | "server_setup" "$dia_main_menu_1_3" \ |
---|
| 92 | "tomcat_switch" "$dia_main_menu_1_4" \ |
---|
| 93 | "tomcat_port" "$dia_main_menu_1_5" \ |
---|
| 94 | "lang_switch" "$dia_main_menu_1_6" \ |
---|
| 95 | "exit" "$dia_exit" 2>$main_choice |
---|
[162] | 96 | } |
---|
| 97 | |
---|
[174] | 98 | ## [Cluster Status (datanode & tasktracker)] ## |
---|
| 99 | function cluster_status(){ |
---|
| 100 | IP_list=$(cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#' | awk '{print $1}') |
---|
| 101 | clusterStatus="/tmp/clusterStatus" |
---|
| 102 | rm $clusterStatus 2> /dev/null |
---|
| 103 | #printf '%16s\t %11s\t %10s\t %25s\n' "[IP] [Hostanme] [Network] [Dtatnode & Tasktracker]" >>$clusterStatus |
---|
[186] | 104 | echo -e "$cluster_status_echo_1" >>$clusterStatus |
---|
[174] | 105 | echo -e "------------------------------------------------------------------------" >>$clusterStatus |
---|
[186] | 106 | echo -e "\n$cluster_status_echo_2" |
---|
[174] | 107 | for ip in $IP_list |
---|
| 108 | do |
---|
| 109 | # Check Network status |
---|
| 110 | ip_status="online" |
---|
| 111 | ping -c1 -w1 $ip 2>&1 > /dev/null || ip_status="offline" |
---|
| 112 | # Check Hadoop/Nutch service through ssh |
---|
[243] | 113 | Task_Data_status="shutdown" |
---|
[174] | 114 | if [ $ip_status == "online" ]; then |
---|
| 115 | Task_Data=$(ssh -o StrictHostKeyChecking=no $ip "jps |grep TaskTracker ; jps | grep DataNode") |
---|
| 116 | fi |
---|
| 117 | |
---|
[175] | 118 | [ -z "$Task_Data" ] || Task_Data_status="running" |
---|
[174] | 119 | host_name=$(cat $NutchEZ_HOME/system/nutch_nodes | grep $ip | awk '{print $2}') |
---|
[186] | 120 | echo -e "$ip $host_name \t\t $ip_status \t $Task_Data_status" >>$clusterStatus |
---|
[174] | 121 | # printf '%16s\t %11s\t %10s\t %25s\n' "$ip $host_name $ip_status $Task_Data_status" >>$clusterStatus |
---|
| 122 | done |
---|
| 123 | |
---|
[186] | 124 | read -p "$cluster_status_read_1" |
---|
| 125 | $DIALOG --clear --backtitle "$dia_back" \ |
---|
| 126 | --title "$dia_cluster_status_title_1" --textbox $clusterStatus 20 90 |
---|
[210] | 127 | |
---|
| 128 | # Back to main menu |
---|
| 129 | main_menu |
---|
| 130 | menu_choose |
---|
[174] | 131 | } |
---|
| 132 | |
---|
[183] | 133 | |
---|
[186] | 134 | ## [Server Setup (namenode & jobtracker)] ## |
---|
[183] | 135 | function server_setup(){ |
---|
| 136 | serverSetup=/tmp/serverSetup |
---|
| 137 | pid_name=$(jps | grep NameNode) |
---|
| 138 | pid_job=$(jps | grep JobTracker) |
---|
| 139 | |
---|
| 140 | if [ -z "$pid_name" -a -z "$pid_job" ]; then |
---|
[186] | 141 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_server_title_1" \ |
---|
| 142 | --msgbox "$dia_server_msg_1" 7 50 |
---|
[183] | 143 | elif [ -z "$pid_name" -a -n "$pid_job" ]; then |
---|
[186] | 144 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_server_title_1" \ |
---|
| 145 | --msgbox "$dia_server_msg_2" 7 50 |
---|
[183] | 146 | elif [ -n "$pid_name" -a -z "$pid_job" ]; then |
---|
[186] | 147 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_server_title_1" \ |
---|
| 148 | --msgbox "$dia_server_msg_3" 7 50 |
---|
[183] | 149 | else |
---|
[186] | 150 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_server_title_1" \ |
---|
| 151 | --msgbox "$dia_server_msg_4" 7 50 |
---|
[183] | 152 | fi |
---|
| 153 | |
---|
[186] | 154 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_server_title_2" \ |
---|
| 155 | --menu "$dia_choose" 15 65 4 \ |
---|
| 156 | "start" "$dia_server_menu_1_1" \ |
---|
[243] | 157 | "shutdown" "$dia_server_menu_1_2" \ |
---|
[186] | 158 | "restart" "$dia_server_menu_1_3" \ |
---|
[237] | 159 | "main" "$dia_backto_main" 2>$serverSetup |
---|
[183] | 160 | |
---|
| 161 | if [ "$(cat $serverSetup)" == "start" ]; then |
---|
| 162 | $NutchEZ_Install_PATH/nutch/bin/start-dfs.sh |
---|
| 163 | $NutchEZ_Install_PATH/nutch/bin/start-mapred.sh |
---|
[237] | 164 | # Back to main menu |
---|
| 165 | main_menu |
---|
| 166 | menu_choose |
---|
[243] | 167 | elif [ "$(cat $serverSetup)" == "shutdown" ]; then |
---|
[183] | 168 | $NutchEZ_Install_PATH/nutch/bin/stop-dfs.sh |
---|
| 169 | $NutchEZ_Install_PATH/nutch/bin/stop-mapred.sh |
---|
[237] | 170 | # Back to main menu |
---|
| 171 | main_menu |
---|
| 172 | menu_choose |
---|
[183] | 173 | elif [ "$(cat $serverSetup)" == "restart" ]; then |
---|
| 174 | $NutchEZ_Install_PATH/nutch/bin/stop-dfs.sh |
---|
| 175 | $NutchEZ_Install_PATH/nutch/bin/stop-mapred.sh |
---|
| 176 | $NutchEZ_Install_PATH/nutch/bin/start-dfs.sh |
---|
| 177 | $NutchEZ_Install_PATH/nutch/bin/start-mapred.sh |
---|
[237] | 178 | # Back to main menu |
---|
| 179 | main_menu |
---|
| 180 | menu_choose |
---|
| 181 | elif [ "$(cat $serverSetup)" == "main" ]; then |
---|
| 182 | main_menu |
---|
| 183 | menu_choose |
---|
[183] | 184 | else |
---|
| 185 | exit |
---|
| 186 | fi |
---|
[210] | 187 | |
---|
[183] | 188 | } |
---|
| 189 | |
---|
| 190 | |
---|
[172] | 191 | ## [Cluster Setup (datanode & tasktracker)] ## |
---|
[162] | 192 | function cluster_setup(){ |
---|
[172] | 193 | # 從 nutch_nodes 讀出 ip 和 hostname |
---|
| 194 | #IP_list=$(cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#' | awk '{print $1}') |
---|
| 195 | #HOST_list=$(cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#' | awk '{print $2}') |
---|
| 196 | LIST_status="off" |
---|
| 197 | allpart="/tmp/allpart" |
---|
| 198 | runNodes="/tmp/runNodes" |
---|
| 199 | clusterSetup="/tmp/clusterSetup" |
---|
[162] | 200 | |
---|
[186] | 201 | $DIALOG --clear --backtitle "$dia_back" \ |
---|
| 202 | --title "$dia_cluster_setup_title_1" \ |
---|
| 203 | --menu "$dia_choose" 15 55 3 \ |
---|
| 204 | "All" "$dia_cluster_setup_menu_1_1" \ |
---|
| 205 | "Part" "$dia_cluster_setup_menu_1_2" \ |
---|
[237] | 206 | "Main" "$dia_backto_main" 2>$allpart |
---|
[162] | 207 | |
---|
[172] | 208 | # 判斷是否選 all 和 part,若是 all 直接到服務選單,若是 part 則先到機器選單 |
---|
[177] | 209 | if [ "$(cat $allpart)" == "All" ]; then |
---|
[172] | 210 | cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#' | awk '{print $1}' >$runNodes |
---|
[177] | 211 | elif [ "$(cat $allpart)" == "Part" ]; then |
---|
[186] | 212 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_cluster_setup_title_2" \ |
---|
| 213 | --checklist "$dia_cluster_setup_check_1" 15 55 7 $(cat $NutchEZ_HOME/system/nutch_nodes | \ |
---|
[172] | 214 | grep -v '^$' | grep -v '#' | awk '{print $1 "\t" $2 "\t" "$LIST_status" }') 2>$runNodes |
---|
[243] | 215 | # read -p "$runNodes and $(cat $runNodes)" |
---|
[237] | 216 | elif [ "$(cat $allpart)" == "Main" ]; then |
---|
| 217 | main_menu |
---|
| 218 | menu_choose |
---|
[177] | 219 | else |
---|
| 220 | exit |
---|
[172] | 221 | fi |
---|
| 222 | |
---|
[177] | 223 | if [ -z "$(cat $runNodes)" ]; then |
---|
[180] | 224 | exit |
---|
[243] | 225 | else |
---|
| 226 | $(cat $runNodes) | sed -i 's/"//g' $runNodes |
---|
[177] | 227 | fi |
---|
| 228 | |
---|
[186] | 229 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_cluster_setup_title_3" \ |
---|
| 230 | --menu "$dia_choose" 15 65 4 \ |
---|
| 231 | "start" "$dia_cluster_setup_menu_2_1" \ |
---|
[243] | 232 | "shutdown" "$dia_cluster_setup_menu_2_2" \ |
---|
[186] | 233 | "restart" "$dia_cluster_setup_menu_2_3" \ |
---|
[238] | 234 | "main" "$dia_backto_main" 2>$clusterSetup |
---|
[162] | 235 | |
---|
| 236 | if [ "$(cat $clusterSetup)" == "start" ]; then |
---|
[186] | 237 | echo -e "\n$cluster_setup_echo_1" |
---|
| 238 | for node in $(cat $runNodes) |
---|
[162] | 239 | do |
---|
[176] | 240 | ssh -o StrictHostKeyChecking=no $node "$NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh start datanode \ |
---|
[186] | 241 | ; $NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh start tasktracker" 2>/dev/null |
---|
| 242 | [ $? == "0" ] || echo "$cluster_setup_echo_error $node !!!" |
---|
[162] | 243 | done |
---|
[237] | 244 | main_menu |
---|
| 245 | menu_choose |
---|
[243] | 246 | elif [ "$(cat $clusterSetup)" == "shutdown" ]; then |
---|
[186] | 247 | echo -e "\n$cluster_setup_echo_3" |
---|
[172] | 248 | for node in $(cat $runNodes) |
---|
[162] | 249 | do |
---|
[176] | 250 | ssh -o StrictHostKeyChecking=no $node "$NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh stop datanode \ |
---|
[186] | 251 | ; $NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh stop tasktracker" 2>/dev/null |
---|
| 252 | [ $? == "0" ] || echo "$cluster_setup_echo_error $node !!!" |
---|
[162] | 253 | done |
---|
[237] | 254 | main_menu |
---|
| 255 | menu_choose |
---|
[177] | 256 | elif [ "$(cat $clusterSetup)" == "restart" ]; then |
---|
[186] | 257 | echo -e "\n$cluster_setup_echo_5" |
---|
[172] | 258 | for node in $(cat $runNodes) |
---|
| 259 | do |
---|
[176] | 260 | ssh -o StrictHostKeyChecking=no $node "$NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh stop datanode \ |
---|
[177] | 261 | ; $NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh stop tasktracker \ |
---|
| 262 | ; $NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh start datanode \ |
---|
[186] | 263 | ; $NutchEZ_Install_PATH/nutch/bin/hadoop-daemon.sh start tasktracker" 2>/dev/null |
---|
| 264 | [ $? == "0" ] || echo "$cluster_setup_echo_error $node !!!" |
---|
[172] | 265 | done |
---|
[237] | 266 | main_menu |
---|
| 267 | menu_choose |
---|
[238] | 268 | |
---|
| 269 | elif [ "$(cat $clusterSetup)" == "main" ]; then |
---|
| 270 | main_menu |
---|
| 271 | menu_choose |
---|
[237] | 272 | else |
---|
[177] | 273 | exit |
---|
[162] | 274 | fi |
---|
[237] | 275 | # Back to main menu |
---|
| 276 | # main_menu |
---|
| 277 | # menu_choose |
---|
[162] | 278 | } |
---|
| 279 | |
---|
[172] | 280 | ## [Tomcat Severice start/stop/restart] ## |
---|
[162] | 281 | function tomcat_switch(){ |
---|
[186] | 282 | tom_pids=$(ps x | grep -v 'grep' | grep "tomcat" | awk '{print $1}') |
---|
| 283 | if [ -n "$tom_pids" ]; then |
---|
| 284 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_tomcat_switch_title_1" \ |
---|
| 285 | --msgbox "$dia_tomcat_switch_msg_1" 7 50 |
---|
[162] | 286 | else |
---|
[186] | 287 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_tomcat_switch_title_1" \ |
---|
| 288 | --msgbox "$dia_tomcat_switch_msg_2" 7 50 |
---|
[162] | 289 | fi |
---|
| 290 | tomcatSwitch="/tmp/tomcatSwitch" |
---|
[186] | 291 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_tomcat_switch_title_2" \ |
---|
| 292 | --menu "$dia_choose" 15 55 4 \ |
---|
| 293 | "start" "$dia_tomcat_switch_menu_1_1" \ |
---|
[243] | 294 | "shutdown" "$dia_tomcat_switch_menu_1_2" \ |
---|
[186] | 295 | "restart" "$dia_tomcat_switch_menu_1_3" \ |
---|
[237] | 296 | "main" "$dia_backto_main" 2>$tomcatSwitch |
---|
[162] | 297 | |
---|
[177] | 298 | if [ "$(cat $tomcatSwitch)" == "exit" ]; then |
---|
| 299 | exit 0 |
---|
[237] | 300 | |
---|
| 301 | elif [ "$(cat $tomcatSwitch)" == "main" ]; then |
---|
| 302 | main_menu |
---|
| 303 | menu_choose |
---|
[177] | 304 | fi |
---|
| 305 | |
---|
| 306 | # jude $Tomcat_HOME/bin/startup.sh |
---|
| 307 | if [ ! -e $Tomcat_HOME/bin/startup.sh ]; then |
---|
[186] | 308 | echo -e "\n$tomcat_switch_echo_1 $Tomcat_HOME/bin/startup.sh" |
---|
[177] | 309 | exit |
---|
| 310 | fi |
---|
| 311 | |
---|
[184] | 312 | if [ ! -e $Tomcat_HOME/bin/shutdown.sh ]; then |
---|
[186] | 313 | echo -e "\n$tomcat_switch_echo_1 $Tomcat_HOME/bin/shutdown.sh" |
---|
[177] | 314 | exit |
---|
| 315 | fi |
---|
| 316 | |
---|
[162] | 317 | if [ "$(cat $tomcatSwitch)" == "start" ]; then |
---|
[186] | 318 | echo "$tomcat_switch_echo_3" |
---|
[176] | 319 | $Tomcat_HOME/bin/startup.sh |
---|
[243] | 320 | elif [ "$(cat $tomcatSwitch)" == "shutdown" ]; then |
---|
[186] | 321 | echo "$tomcat_switch_echo_4" |
---|
[176] | 322 | $Tomcat_HOME/bin/shutdown.sh |
---|
[186] | 323 | for tom_pid in $tom_pids |
---|
| 324 | do |
---|
| 325 | kill -9 $tom_pid 2>/dev/null |
---|
| 326 | done |
---|
[162] | 327 | elif [ "$(cat $tomcatSwitch)" == "restart" ]; then |
---|
[186] | 328 | echo "$tomcat_switch_echo_5" |
---|
[176] | 329 | $Tomcat_HOME/bin/shutdown.sh |
---|
[186] | 330 | for tom_pid in $tom_pids |
---|
| 331 | do |
---|
| 332 | kill -9 $tom_pid 2>/dev/null |
---|
| 333 | done |
---|
[176] | 334 | $Tomcat_HOME/bin/startup.sh |
---|
[162] | 335 | else |
---|
| 336 | exit 0 |
---|
| 337 | fi |
---|
[210] | 338 | |
---|
| 339 | # Back to main menu |
---|
| 340 | main_menu |
---|
| 341 | menu_choose |
---|
[162] | 342 | } |
---|
| 343 | |
---|
[172] | 344 | ## [Tomcat Port Change] ## |
---|
[162] | 345 | function tomcat_port(){ |
---|
| 346 | |
---|
[176] | 347 | if [ ! -e $Tomcat_HOME/conf/server.xml ]; then |
---|
[186] | 348 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_tomcat_port_title_1" \ |
---|
| 349 | --msgbox "$dia_tomcat_port_msg_1 $Tomcat_HOME/conf/server.xml !!!" 10 50 |
---|
[162] | 350 | exit |
---|
| 351 | fi |
---|
| 352 | tomcatPort="/tmp/tomcatPort" |
---|
[186] | 353 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_tomcat_port_title_2" \ |
---|
| 354 | --inputbox "$dia_tomcat_port_input_1" 10 55 2>$tomcatPort |
---|
[162] | 355 | |
---|
[177] | 356 | if [ -z "$(cat $tomcatPort)" ]; then |
---|
[210] | 357 | # Back to main menu |
---|
| 358 | main_menu |
---|
| 359 | menu_choose |
---|
[162] | 360 | else |
---|
[176] | 361 | modify_line_nu=$(cat -n $Tomcat_HOME/conf/server.xml | grep -v SSL | grep 'HTTP/1.1' | grep '<Connector' | awk '{print $1}') |
---|
[182] | 362 | sed -i "${modify_line_nu}c <Connector port=\"$(cat $tomcatPort)\" protocol=\"HTTP/1.1\"" $Tomcat_HOME/conf/server.xml |
---|
[186] | 363 | |
---|
| 364 | tom_pids=$(ps x | grep -v 'grep' | grep "tomcat" | awk '{print $1}') |
---|
[176] | 365 | $Tomcat_HOME/bin/shutdown.sh |
---|
[186] | 366 | for tom_pid in $tom_pids |
---|
| 367 | do |
---|
| 368 | kill -9 $tom_pid 2>/dev/null |
---|
| 369 | done |
---|
[176] | 370 | $Tomcat_HOME/bin/startup.sh |
---|
[162] | 371 | fi |
---|
[210] | 372 | |
---|
| 373 | # Back to main menu |
---|
| 374 | main_menu |
---|
| 375 | menu_choose |
---|
[162] | 376 | } |
---|
| 377 | |
---|
| 378 | |
---|
[172] | 379 | ## [Language Change] ## |
---|
[162] | 380 | function lang_switch(){ |
---|
| 381 | langSwitch="/tmp/langSwitch" |
---|
[186] | 382 | $DIALOG --clear --backtitle "$dia_back" --title "$dia_lang_title_1" \ |
---|
| 383 | --menu "$dia_choose" 15 55 3 \ |
---|
| 384 | "en_US" "$dia_lang_menu_1_1" \ |
---|
| 385 | "zh_TW" "$dia_lang_menu_1_2" \ |
---|
[237] | 386 | "main" "$dia_backto_main" 2>$langSwitch |
---|
[162] | 387 | # |
---|
[177] | 388 | if [ "$(cat $langSwitch)" == "Exit" ]; then |
---|
| 389 | exit |
---|
[186] | 390 | elif [ "$(cat $langSwitch)" == "en_US" ]; then |
---|
[209] | 391 | source $Work_Path/lang/lang_en_US_nutchez |
---|
[186] | 392 | main_menu |
---|
| 393 | menu_choose |
---|
| 394 | elif [ "$(cat $langSwitch)" == "zh_TW" ]; then |
---|
[209] | 395 | source $Work_Path/lang/lang_zh_TW_nutchez |
---|
[186] | 396 | main_menu |
---|
| 397 | menu_choose |
---|
[177] | 398 | fi |
---|
[162] | 399 | } |
---|
| 400 | |
---|
[186] | 401 | ## [Menu_choose] ## |
---|
| 402 | function menu_choose(){ |
---|
[162] | 403 | case $(cat $main_choice) in |
---|
[174] | 404 | "cluster_status") |
---|
| 405 | cluster_status;; |
---|
[186] | 406 | "cluster_setup") |
---|
| 407 | cluster_setup;; |
---|
[183] | 408 | "server_setup") |
---|
| 409 | server_setup;; |
---|
[162] | 410 | "tomcat_switch") |
---|
| 411 | tomcat_switch;; |
---|
| 412 | "tomcat_port") |
---|
| 413 | tomcat_port;; |
---|
| 414 | "lang_switch") |
---|
| 415 | lang_switch;; |
---|
| 416 | esac |
---|
[186] | 417 | } |
---|
| 418 | |
---|
| 419 | # [Main Code] # |
---|
| 420 | if [ $USER != "nutchuser" ]; then |
---|
| 421 | echo -e "\n$user_error" |
---|
| 422 | exit |
---|
| 423 | fi |
---|
| 424 | |
---|
| 425 | prepare_lang |
---|
| 426 | prepare_check |
---|
| 427 | main_menu |
---|
| 428 | menu_choose |
---|