#!/bin/sh
# sig
_SIGNATURE_=eUZ3fOKaWUG

# 需要安装的模块列表
_INSTALL_LISTS_="
UpdateSystem
GetConfiguration
GetMaintainaceTools
GetSoftware
InstallGCC48x
InstallQConfAgent
InstallLibMcrypt
InstallPCRE
InstallJemalloc
InstallNginx
InstallLibIconv
InstallMHash
LinkLiberaryFiles
InstallMcrypt
InstallnLoad
InstallLibEvent
InstallPHP '' '([mysqli]=1 [tokenizer]=1 [gd]=1)'
InstallPHPExtAPCu
InstallPHPExtIgbinary
InstallPHPExtLibEvent
InstallPHPExtRedis
InstallThriftLib
InstallCronolog
InstallTCMalloc
InstallMySQL
InstallMyDumper
InstallBoostLib
InstalLog4CPlus
InstallLua
InstallRedisServer
InstallScons
InstallJsoncpp
InstallLibLuabind
InstallHiredisLib
InstallHtmlCXX
InstallJQ
InstallPigz
InstallPbzip2
InstallParallel
;InstallPythonExtPSUtil
InstallPythonExtSetupToolsBySrc
InstallPythonExtPipBySrc
InstallPythonExtPSUtilBySrc
LinkLiberaryFiles
PerformanceSystem
CreateCrond
EditCmdConfiguration
EditPortsToIptables
"

# @function edit shell script's config sets
function EditCmdConfiguration()
{
    ShowResult "[green]正在初始化维护脚本配置文件设置...[/green]" 1
    
    local cfg_=${_PATH_CMD_}/config.sh
    
#    sed -ri "
#        s@^(_GAME_NAME_=).*@\1${_GAME_NAME_}@g;
#        s@^(_PLATFORM_ID_=).*@\1${_PLATFORM_ID_}@g;
#        s@^(_LOG_PATH_=).*@\1${_PATH_LOG_}@g;
#        s@^(_PHP_SERVER_NAME_=).*@\1`GetInfo "${_HOSTS_[PHP]}" name`@g;
#        s@^(_CPP_SERVER_NAME_=).*@\1`GetInfo "${_HOSTS_[CPP]}" name`@g;
#        s@^(_BACKSTAGE_HOST_=).*@\1`GetInfo "${_HOSTS_[BACKSTAGE]}" name`@g;
#        s@^(_CPP_APP_PATH_=).*@\1${_PATH_CPP_}@g;
#        s@^(_PHP_ROOT_=).*@\1${_PATH_WEB_}@g;
#        s@^(_PHP_WEBSERVICE_WHITELIST_=).*@\1\"`echo ${_WEB_ACCESS_WHITELIST_[WEBSERVICE]}`\"@g;
#        s@^(_DB_ROOT_=).*@\1${_DB_ROOT_PWD_}@g;
#        s@^(_DB_HOST_LOCAL_=).*@\1`GetInfo "${_HOSTS_[DB]}" name`@g;
#        s@^(_DB_CONTROL_\[HOST\]=).*@\1`GetInfo "${_HOSTS_[DBCTRL]}" name`@g;
#        s@^(_DB_GAME_HOSTS_=).*@\1$(echo ${_DB_GAME_ACCOUNT_ALLOW_WHITELIST_[*]} | awk 'BEGIN{i=1;s=""}{while(i<=NF){if(s!=""){s=s" "}s=s"\""$i"\"";i++}print "("s")"}')@g;
#        s@^(_MEMCACHED_HOST_=).*@\1`GetInfo "${_HOSTS_[MEMCACHED]}" name`@g;
#        s@^(_SVN_ROOT_=).*@\1${_SVN_[HOST]}@g;
#        s@^(_SVN_REGION_=).*@\1${_SVN_[REGION]}@g;
#        s@^(_API_PATH_NAME_=).*@\1${_API_NAME_}@g;
#        s@^(_API_KEY_=).*@\1\"${_API_KEY_}\"@g;
#        s@^(_API_WHITELIST_=).*@\1\"`echo ${_WEB_ACCESS_WHITELIST_[API]}`\"@g;
#        s@^(_SYS_TIME_ZONE_=).*@\1${_TIMEZONE_}@g;
#        s@^(_SYS_NET_ADAPTER_EXTERNAL=).*@\1${_NET_EXTERNAL_ADAPTER_}@g;
#        s@^(_SYS_NET_ADAPTER_INTERNAL=).*@\1${_NET_INTERNAL_ADAPTER_}@g;
#        s@^(_WEB_SERVER_MODE_=).*@\1${_WEB_SERVER_TYPE_}@g;
#        s@^(_WEB_SERVER_USING_SSL_=).*@\1${_WEB_SERVER_USING_SSL_}@g;
#        s@^(_WEB_VHOSTS_POSTFIX_=).*@\1${_WEB_VHOSTS_POSTFIX_}@g;
#        s@^(_WEB_VHOSTS_TEMPLATE_STD_PATH_=).*@\1${_WEB_VHOSTS_TEMPLATE_STD_PATH_}@g;
#        s@^(_WEB_VHOSTS_TEMPLATE_SSL_PATH_=).*@\1${_WEB_VHOSTS_TEMPLATE_SSL_PATH_}@g;
#        s@^(_WEB_VHOSTS_STD_SAVE_PATH_=).*@\1${_WEB_VHOSTS_STD_SAVE_PATH_}@g;
#        s@^(_WEB_VHOSTS_SSL_SAVE_PATH_=).*@\1${_WEB_VHOSTS_SSL_SAVE_PATH_}@g;
#        s@^(_WEB_SERVER_SSL_CRT_PATH_=).*@\1${_WEB_SERVER_SSL_CRT_PATH_}@g;
#        s@^(_WEB_SERVER_SSL_KEY_PATH_=).*@\1${_WEB_SERVER_SSL_KEY_PATH_}@g;
#        s@^(_WEB_SERVER_SSL_CHAIN_CRT_PATH_=).*@\1${_WEB_SERVER_SSL_CHAIN_CRT_PATH_}@g;
#        s@^(_PATH_CRON_=).*@\1${_PATH_CRON_}@g;
#        " ${cfg_}
    
    ShowStatus $?
}

