#!/bin/bash
#===============================================================================
#
#          FILE: killall_wz
#
#         USAGE: killall_wz
#
#   DESCRIPTION: Kill all WorldServer and ZoneServer by sending signal SIGKILL
#
#  REQUIREMENTS: sendscript
#
#         NOTES: DANGER!
#
#          BUGS:  ---
#        AUTHOR: rickz (Rick Zhang), xlrickz@gmail.com
#       COMPANY: X-LEGEND Entertainment Corp.
#       CREATED: Mon May 30 00:35:15 EDT 2011
#      REVISION: 1.0
#
#          TODO:
#
#===============================================================================

#set -o nounset                              # Treat unset variables as an error
#set -m                                      # Enable job control

source ~/.gamerc

echo "DANGER, THIS WILL KILL ALL THE WorldServer and ZoneServer BY SIGNAL SIGKILL TO ALL THE LIVE SERVERS" | colorize red
echo

Q1="$RANDOM"

read -p "Please type $Q1 to confirm you want to do this: " Q1A

[ "$Q1" == "$Q1A" ] || exec echo "Error: Wrong answer."

read -p "Are you sure you want to do this?(YES/NO) " Q2A
[ "YES" == "$Q2A" ] || exec echo "Error: You didn't say YES."


sendscript allwz <<< "ps -Ao cmd|grep '[a-z]Server'|awk -F'/' '{print \"killall -9 \"\$2}'|grep Server|sh"
