菜单脚本1
[root@c5-sc-vcollege-cli01 tools]# cat /usr/local/shell/submit-code.sh
#!/bin/bash
vcollege-twenty-file-server-pre () {
# ansible 172.17.100.9 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-file-server-pre.jar
ansible 172.17.100.9 -m copy -a 'src=/workspace/tools/vcollege-twenty-file-server-pre.jar dest=/workspace/deploy/svcollege/twenty-file-server-pre/ owner=root group=root mode=644'
ansible 172.17.100.9 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-file-server-pre &'
ansible 172.17.100.10 -m copy -a 'src=/workspace/tools/vcollege-twenty-file-server-pre.jar dest=/workspace/deploy/svcollege/twenty-file-server-pre/ owner=root group=root mode=644'
ansible 172.17.100.10 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-file-server-pre &'
rm -f vcollege-twenty-file-server-pre.jar
}
vcollege-twenty-school-pre () {
# ansible 172.17.10.8 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-school-pre.jar
ansible 172.17.10.14 -m copy -a 'src=/workspace/tools/vcollege-twenty-school-pre.jar dest=/workspace/deploy/svcollege/twenty-school-pre/ owner=root group=root mode=644'
ansible 172.17.10.14 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-school-pre &'
ansible 172.17.100.8 -m copy -a 'src=/workspace/tools/vcollege-twenty-school-pre.jar dest=/workspace/deploy/svcollege/twenty-school-pre/ owner=root group=root mode=644'
ansible 172.17.100.8 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-school-pre &'
rm -f vcollege-twenty-school-pre.jar
}
vcollege-twenty-student-pre () {
# ansible 172.17.100.8 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-student-pre.jar
ansible 172.17.10.14 -m copy -a 'src=/workspace/tools/vcollege-twenty-student-pre.jar dest=/workspace/deploy/svcollege/twenty-student-pre/ owner=root group=root mode=644'
ansible 172.17.10.14 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-student-pre &'
ansible 172.17.100.8 -m copy -a 'src=/workspace/tools/vcollege-twenty-student-pre.jar dest=/workspace/deploy/svcollege/twenty-student-pre/ owner=root group=root mode=644'
ansible 172.17.100.8 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-student-pre &'
rm -f vcollege-twenty-student-pre.jar
}
vcollege-twenty-sysadmin-pre () {
# ansible 172.17.100.9 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-sysadmin-pre.jar
ansible 172.17.100.9 -m copy -a 'src=/workspace/tools/vcollege-twenty-sysadmin-pre.jar dest=/workspace/deploy/svcollege/twenty-sysadmin-pre/ owner=root group=root mode=644'
ansible 172.17.100.9 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-sysadmin-pre &'
rm -f vcollege-twenty-sysadmin-pre.jar
}
vcollege-twenty-teacher-pre () {
# ansible 172.17.100.8 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-teacher-pre.jar
ansible 172.17.10.14 -m copy -a 'src=/workspace/tools/vcollege-twenty-teacher-pre.jar dest=/workspace/deploy/svcollege/twenty-teacher-pre/ owner=root group=root mode=644'
ansible 172.17.10.14 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-teacher-pre &'
ansible 172.17.100.8 -m copy -a 'src=/workspace/tools/vcollege-twenty-teacher-pre.jar dest=/workspace/deploy/svcollege/twenty-teacher-pre/ owner=root group=root mode=644'
ansible 172.17.100.8 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-teacher-pre &'
rm -f vcollege-twenty-teacher-pre.jar
}
vcollege-twenty-uims-core () {
# ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-uims-core.jar
ansible 172.17.10.2 -m copy -a 'src=/workspace/tools/vcollege-twenty-uims-core.jar dest=/workspace/deploy/svcollege/twenty-uims-core/ owner=root group=root mode=644'
ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-uims-core &'
ansible 172.17.10.5 -m copy -a 'src=/workspace/tools/vcollege-twenty-uims-core.jar dest=/workspace/deploy/svcollege/twenty-uims-core/ owner=root group=root mode=644'
ansible 172.17.10.5 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-uims-core &'
ansible 172.17.10.6 -m copy -a 'src=/workspace/tools/vcollege-twenty-uims-core.jar dest=/workspace/deploy/svcollege/twenty-uims-core/ owner=root group=root mode=644'
ansible 172.17.10.6 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-uims-core &'
rm -f vcollege-twenty-uims-core.jar
}
vcollege-twenty-common-core () {
# ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-common-core.jar
ansible 172.17.10.2 -m copy -a 'src=/workspace/tools/vcollege-twenty-common-core.jar dest=/workspace/deploy/svcollege/twenty-common-core/ owner=root group=root mode=644'
ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-common-core &'
ansible 172.17.10.5 -m copy -a 'src=/workspace/tools/vcollege-twenty-common-core.jar dest=/workspace/deploy/svcollege/twenty-common-core/ owner=root group=root mode=644'
ansible 172.17.10.5 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-common-core &'
ansible 172.17.10.6 -m copy -a 'src=/workspace/tools/vcollege-twenty-common-core.jar dest=/workspace/deploy/svcollege/twenty-common-core/ owner=root group=root mode=644'
ansible 172.17.10.6 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-common-core &'
rm -f vcollege-twenty-common-core.jar
}
vcollege-twenty-file-server () {
# ansible 172.17.100.11 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-file-server.jar
ansible 172.17.100.11 -m copy -a 'src=/workspace/tools/vcollege-twenty-file-server.jar dest=/workspace/deploy/svcollege/twenty-file-server/ owner=root group=root mode=644'
ansible 172.17.100.11 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-file-server &'
ansible 172.17.100.12 -m copy -a 'src=/workspace/tools/vcollege-twenty-file-server.jar dest=/workspace/deploy/svcollege/twenty-file-server/ owner=root group=root mode=644'
ansible 172.17.100.12 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-file-server &'
rm -f vcollege-twenty-file-server.jar
}
vcollege-twenty-mq-core () {
# ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-mq-core.jar
ansible 172.17.10.2 -m copy -a 'src=/workspace/tools/vcollege-twenty-mq-core.jar dest=/workspace/deploy/svcollege/twenty-mq-core/ owner=root group=root mode=644'
ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-mq-core &'
ansible 172.17.10.5 -m copy -a 'src=/workspace/tools/vcollege-twenty-mq-core.jar dest=/workspace/deploy/svcollege/twenty-mq-core/ owner=root group=root mode=644'
ansible 172.17.10.5 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-mq-core &'
rm -f vcollege-twenty-mq-core.jar
}
vcollege-twenty-welcomenew-core () {
# ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-welcomenew-core.jar
ansible 172.17.10.2 -m copy -a 'src=/workspace/tools/vcollege-twenty-welcomenew-core.jar dest=/workspace/deploy/svcollege/twenty-welcomenew-core/ owner=root group=root mode=644'
ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-welcomenew-core &'
ansible 172.17.10.5 -m copy -a 'src=/workspace/tools/vcollege-twenty-welcomenew-core.jar dest=/workspace/deploy/svcollege/twenty-welcomenew-core/ owner=root group=root mode=644'
ansible 172.17.10.5 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-welcomenew-core &'
ansible 172.17.10.6 -m copy -a 'src=/workspace/tools/vcollege-twenty-welcomenew-core.jar dest=/workspace/deploy/svcollege/twenty-welcomenew-core/ owner=root group=root mode=644'
ansible 172.17.10.6 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-welcomenew-core &'
rm -f vcollege-twenty-welcomenew-core.jar
}
vcollege-twenty-register-server () {
# ansible 172.17.10.7 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-register-server.jar
ansible 172.17.10.7 -m copy -a 'src=/workspace/tools/vcollege-twenty-register-server.jar dest=/workspace/deploy/svcollege/register-server/ owner=root group=root mode=644'
ansible 172.17.10.7 -m shell -a 'nohup /bin/sh /usr/local/shell/7restart.sh twenty-register-server &'
rm -f vcollege-twenty-register-server.jar
sleep 6
}
vcollege-openplat-core () {
# ansible 172.17.100.9 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-welcomenew-core.jar
ansible 172.17.100.9 -m copy -a 'src=/workspace/tools/vcollege-openplat-core.jar dest=/workspace/deploy/svcollege/openplat-core/ owner=root group=root mode=644'
ansible 172.17.100.9 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh openplat-core &'
ansible 172.17.100.10 -m copy -a 'src=/workspace/tools/vcollege-openplat-core.jar dest=/workspace/deploy/svcollege/openplat-core/ owner=root group=root mode=644'
ansible 172.17.100.10 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh openplat-core &'
rm -f vcollege-openplat-core.jar
}
smct_admin () {
cd /workspace/tools/ && bash /usr/local/shell/down.sh smct_admin.tar.gz
if [ -f /workspace/tools/smct_admin.tar.gz ]; then
ansible 172.17.10.10 -m copy -a 'src=/workspace/tools/smct_admin.tar.gz dest=/etc/nginx/smct_admin/ owner=root group=root mode=755'
fi
ansible 172.17.10.10 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh smct_admin &'
rm -f /workspace/tools/smct_admin.tar.gz
}
smct_school () {
cd /workspace/tools/ && bash /usr/local/shell/down.sh smct_school.tar.gz
if [ -f /workspace/tools/smct_school.tar.gz ]; then
ansible 172.17.10.10 -m copy -a 'src=/workspace/tools/smct_school.tar.gz dest=/etc/nginx/smct_school/ owner=root group=root mode=755'
fi
ansible 172.17.10.10 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh smct_school &'
rm -f /workspace/tools/smct_school.tar.gz
}
app-ui () {
cd /workspace/tools/ && bash /usr/local/shell/down.sh app-ui.zip
if [ -f /workspace/tools/app-ui.zip ]; then
ansible 172.17.10.10 -m copy -a 'src=/workspace/tools/app-ui.zip dest=/etc/nginx/smct_app owner=root group=root mode=755'
fi
ansible 172.17.10.10 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh app-ui &'
rm -f /workspace/tools/app-ui.zip
}
teacher-app-ui () {
cd /workspace/tools/ && bash /usr/local/shell/down.sh teacher-app-ui.zip
if [ -f /workspace/tools/teacher-app-ui.zip ]; then
ansible 172.17.10.10 -m copy -a 'src=/workspace/tools/teacher-app-ui.zip dest=/etc/nginx/smct_app_teacher/ owner=root group=root mode=755'
fi
ansible 172.17.10.10 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh teacher-app-ui &'
rm -f /workspace/tools/teacher-app-ui.zip
}
vcollege-twenty-leave-core () {
# ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-leave-core.jar
ansible 172.17.100.11 -m copy -a 'src=/workspace/tools/vcollege-twenty-leave-core.jar dest=/workspace/deploy/svcollege/twenty-leave-core/ owner=root group=root mode=644'
ansible 172.17.100.11 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-leave-core &'
ansible 172.17.100.12 -m copy -a 'src=/workspace/tools/vcollege-twenty-leave-core.jar dest=/workspace/deploy/svcollege/twenty-leave-core/ owner=root group=root mode=644'
ansible 172.17.100.12 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-leave-core &'
rm -f vcollege-twenty-leave-core.jar
}
vcollege-twenty-ws-server () {
# ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-ws-server.jar
ansible 172.17.100.11 -m copy -a 'src=/workspace/tools/vcollege-twenty-ws-server.jar dest=/workspace/deploy/svcollege/twenty-ws-server/ owner=root group=root mode=644'
ansible 172.17.100.11 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-ws-server &'
ansible 172.17.100.12 -m copy -a 'src=/workspace/tools/vcollege-twenty-ws-server.jar dest=/workspace/deploy/svcollege/twenty-ws-server/ owner=root group=root mode=644'
ansible 172.17.100.12 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-ws-server &'
rm -f twenty-ws-serverjar
}
extapp-ui () {
cd /workspace/tools/ && bash /usr/local/shell/down.sh extapp-ui.zip
if [ -f /workspace/tools/extapp-ui.zip ]; then
ansible 172.17.10.10 -m copy -a 'src=/workspace/tools/extapp-ui.zip dest=/etc/nginx/smct_extapp-ui/ owner=root group=root mode=755'
fi
ansible 172.17.10.10 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh extapp-ui &'
rm -f /workspace/tools/extapp-ui.zip
}
vcollege-twenty-task-core () {
# ansible 172.17.10.2 -m shell -a 'nohup /bin/sh /usr/local/shell/bak.sh' -b
cd /workspace/tools/ && bash /usr/local/shell/down.sh vcollege-twenty-task-core.jar
ansible 172.17.100.11 -m copy -a 'src=/workspace/tools/vcollege-twenty-task-core.jar dest=/workspace/deploy/svcollege/twenty-task-core/ owner=root group=root mode=644'
ansible 172.17.100.11 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-task-core &'
ansible 172.17.100.12 -m copy -a 'src=/workspace/tools/vcollege-twenty-task-core.jar dest=/workspace/deploy/svcollege/twenty-task-core/ owner=root group=root mode=644'
ansible 172.17.100.12 -m shell -a 'nohup /bin/sh /usr/local/shell/restart.sh twenty-task-core &'
rm -f vcollege-twenty-task-core.jar
}
while :
do
echo "***********************************************************************************************************************************************************************************************************"
echo "* > Submit code products < `date` *"
echo "*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*"
echo "* 1.vcollege-twenty-register-server 2.vcollege-twenty-uims-core 3.vcollege-twenty-common-core 4.vcollege-twenty-file-server 5.vcollege-twenty-mq-core *"
echo "* 6.vcollege-twenty-welcomenew-core 7.vcollege-twenty-file-server-pre 8.vcollege-twenty-school-pre 9.vcollege-twenty-student-pre 10.vcollege-twenty-sysadmin-pre *"
echo "* 11.vcollege-twenty-teacher-pre 12.vcollege-openplat-core 13.smct_school 14.smct_admin 15.app-ui *"
echo "* 16.teacher-app-ui 17.vcollege-twenty-leave-core 18.vcollege-twenty-ws-server 19.extapp-ui 20.vcollege-twenty-task-core *"
echo "* 21.break *"
echo "***********************************************************************************************************************************************************************************************************"
read -p "Please input your choice:[1-21]" choice
case $choice in
1) vcollege-twenty-register-server ;;
2) vcollege-twenty-uims-core ;;
3) vcollege-twenty-common-core ;;
4) vcollege-twenty-file-server ;;
5) vcollege-twenty-mq-core ;;
6) vcollege-twenty-welcomenew-core ;;
7) vcollege-twenty-file-server-pre ;;
8) vcollege-twenty-school-pre ;;
9) vcollege-twenty-student-pre ;;
10) vcollege-twenty-sysadmin-pre ;;
11) vcollege-twenty-teacher-pre ;;
12) vcollege-openplat-core ;;
13) smct_school ;;
14) smct_admin ;;
15) app-ui ;;
16) teacher-app-ui ;;
17) vcollege-twenty-leave-core ;;
18) vcollege-twenty-ws-server ;;
19) extapp-ui ;;
20) vcollege-twenty-task-core ;;
21) break ;;
*) echo "$1 is not in (1-21)" `continue` ;;
esac
done
调用脚本
[root@c5-sc-vcollege-elk01 shell]# cat restart.sh
#!/bin/bash
now_time=`date +%Y%m%d`
cd /workspace/deploy/svcollege/
mkdir -p bak/${now_time}bak
while [ -n "$1" ]
do
case "$1" in
twenty-mq-core)
ps -ef|grep twenty-mq-core|egrep -v "grep|restart.sh"|awk '{print "kill -9 " $2}'|bash
sleep 1
nohup java -jar /workspace/deploy/svcollege/twenty-mq-core/vcollege-twenty-mq-core.jar --spring.profiles.active=prod >> /workspace/deploy/svcollege/logs/twenty-mq-core.log &
;;
twenty-uims-core)
ps -ef|grep twenty-uims-core|egrep -v "grep|restart.sh"|awk '{print "kill -9 " $2}'|bash
sleep 1
nohup java -jar /workspace/deploy/svcollege/twenty-uims-core/vcollege-twenty-uims-core.jar --spring.profiles.active=prod >> /workspace/deploy/svcollege/logs/twenty-uims-core.log &
;;
twenty-common-core)
ps -ef|grep "$1"|egrep -v "grep|restart.sh"|awk '{print "kill -9 " $2}'|bash
sleep 1
nohup java -jar /workspace/deploy/svcollege/"$1"/vcollege-"$1".jar --spring.profiles.active=prod >> /workspace/deploy/svcollege/logs/"$1".log &
;;
twenty-welcomenew-core)
ps -ef|grep "$1"|egrep -v "grep|restart.sh"|awk '{print "kill -9 " $2}'|bash
sleep 1
nohup java -jar /workspace/deploy/svcollege/"$1"/vcollege-"$1".jar --spring.profiles.active=prod >> /workspace/deploy/svcollege/logs/"$1".log &
;;
*)
echo "$1 is not an option"
;;
esac
shift
done
调用脚本备份
[root@c5-sc-vcollege-if01 ~]# cat /usr/local/shell/bak.sh
#!/bin/bash
now_time=`date +%Y%m%d`
cd /tmp/
if [ ! -d "/tmp/bak/${now_time}bak" ]; then
mkdir -p bak/${now_time}bak
fi
if [ -d "/etc/nginx/smct_student" ]; then
cp -R /etc/nginx/smct_student bak/${now_time}bak/
fi
if [ -d "/etc/nginx/smct_teacher" ]; then
cp -R /etc/nginx/smct_teacher bak/${now_time}bak/
fi