1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
| #!/bin/bash
if [ -f /home/public ] ; then cd /home/public else sudo mkdir -pv /home/public cd /home/public fi
if [ -d ${WORK_DIR}/test ] ; then rm -rf ${WORK_DIR}/test echo "delete ${WORK_DIR}/test" fi
WORK_DIR=`pwd`
echo ${WORK_DIR}
USER_NAME=`whoami`
echo ${USER_NAME}
touch test.txt
TEST_FILE=${WORK_DIR}/test.txt
echo ${TEST_FILE}
NETADDR_OUTER=`curl http://members.3322.org/dyndns/getip`
NETADDR_INNER=`/sbin/ifconfig | grep "inet addr" | grep -v "127.0.0.1" | cut -d ':' -f2 | awk '{print $1}'`
if [ ! "${NETADDR_INNER}" = "" ] ; then NETADDR=${NETADDR_INNER} else NETADDR=${NETADDR_OUTER} fi
echo -e "NETADDR_OUTER:${NETADDR_OUTER}\nNETADDR_INNER:${NETADDR_INNER}" >> ${TEST_FILE}
sed '1i 添加的内容' ${TEST_FILE} sed '$i 添加的内容' ${TEST_FILE} sed '$a 添加的内容' ${TEST_FILE}
echo `cat ${TEST_FILE}`
key_vlaue=`cat ${TEST_FILE} | grep 'NETADDR_OUTER' | awk -F':' '{ print $2 }'`
echo -n "不换行\n" echo "默认换行" echo -e "转译换行\n"
ip=${NETADDR_OUTER} echo $ip | perl -ne 'exit 1 unless /\b(?:(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5]))\b/' if [ $? -eq 1 ] ; then echo "$ip is not availd ip ..." exit fi
while true do echo -e "wait input [y/n]" read -r input case $input in [yY][eE][sS]|[yY]) break esac exit done
loop(){ while true do echo -e "do" case echo -e "case do" esac echo -e "esac do" exit done }
touch lib1 lib2 lib3
if [ ! -x lib1 ] ; then chmod +x lib1 \ lib2 \ lib3 fi
ln -s -f lib1 libone ln -s -f lib2 libtwo ln -s -f lib3 libthree
source_env(){ tar -xf ${1} rm -rf ${1} if [ -f /etc/profile.d/${2} ] ; then sudo rm /etc/profile.d/${2} echo "remove the old env file." fi dos2unix ./${2} sudo mv ${2} /etc/profile.d/ sudo chown ${USER_NAME}:users /etc/profile.d/${2} sudo chmod 700 /etc/profile.d/${2} source /etc/profile.d/${2} echo "source env success." }
if [ -d ${WORK_DIR} ] ; then cd ${WORK_DIR} if [ -f ${TEST_FILE} ] ; then sed -i '/NETADDR_OUTER/c\NETADDR_SED' ${TEST_FILE} echo -e "modify ${TEST_FILE} success.\n" fi cd - fi
nohup vi ${TEST_FILE} >/dev/null 2>&1 &
echo -e "NOW will stop \n" PID=`ps -ef |grep ${USER_NAME}|grep ${TEST_FILE}|grep -v "grep"|awk '{print $2}'`
kill -9 ${PID}
start_server(){ PID=`ps -ef |grep ${USER_NAME}|grep tomcat6|grep -v "grep"|awk '{print $2}'` kill -9 ${PID} sleep 1 echo -e "NOW will start Server\n" cd ${HOME} if [ -f tomcat6/bin/startup.sh ] ; then sh tomcat6/bin/startup.sh fi if [ -f App/app ] ; then nohup App/app >/dev/null 2>&1 & fi }
|