#!/bin/sh function createFile() { for f in "$@"; do if [ ! -f $f ]; then touch $f chmod 777 $f fi done } function init() { dir=`pwd` mkdir -p ${dir}/data/iplist/ #ipFileChina='/data/iplist/sq_iplist_china.txt' #ipFileAbroad='/data/iplist/sq_iplist_abroad.txt' #ipFileAbroadTest='/data/iplist/sq_iplist_abroad_test.txt' # ipFileAbroadKuafu='/data/iplist/sq_iplist_abroad_kuafu.txt' # ipFileAbroadOrder='/data/iplist/sq_iplist_abroad_order.txt' ipListFile="${dir}/data/iplist/iplist.txt" createFile ${ipListFile} #source /data/gameTools/config/toolsConfig.sh #---------------------------------------- #mysql账户密码 slaveUser='a' slavePwd='b' sshPwd='c' } function checkPwd() { pwdCount=1 read -s -p "Please input the password: " thePwd clear while true; do if [ "${pwdCount}" -ge 3 ]; then echo "bye" exit 1 fi if [ "$thePwd" = "7roaddba" ]; then break else echo "Error: The password is error." echo read -s -p "Please input the password: " thePwd clear fi pwdCount=`expr ${pwdCount} + 1` done } function autossh() { SRC_HOST="$1" SRC_PORT="$2" SRC_PWD="$3" commands="$4" expect -c " set timeout 30 spawn ssh -p $SRC_PORT root@$SRC_HOST expect { "(yes/no)?" {send "yes ";exp_continue} "password:" {send "${SRC_PWD} ";exp_continue} "Last login" {send "$commands ";} } interact #expect eof " } function synIPdata() { dataId="$1" saveFile="$2" tmpFile="`pwd`/tmp/sq_iplist_$RANDOM" if [ ! -d `dirname ${tmpFile}` ];then mkdir `dirname ${tmpFile}` fi createFile $tmpFile echo -n "Sync ip list from main data......" mainDataUrl="this is a URL" curl "$mainDataUrl" -o $tmpFile >> /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo -e "