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