title: 爱流量发包脚本 #标题
    tags: work #标签
    categories: 工作大杂烩 # 分类
    password: jianzhao87.
    abstract: 有东西被加密了, 请输入密码查看。
    message: 您好, 这里需要密码。
    date: 2020-11-19
    wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试。


    用于保存下业务上发包的脚本。

    1. # Author : lv jian zhao
    2. # Describe : 爱流量发包脚本
    3. # Date : 2020-07-21
    4. set -e
    5. rsync_source_dir=10.252.201.131::NRPE/lvjianzhao/ailiuliang/
    6. backup_dir=/apps/var/backup/
    7. cur_date=$(date +%F_%H%M)
    8. item=0
    9. h2() {
    10. printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
    11. }
    12. USAGE(){
    13. echo -e "\033[33m
    14. $0 Script usage:
    15. -n: Specify the app name to deploy(Such as /apps/var/dfp-flowaccount/ app_name for that:dfp-flowaccount)
    16. -h: Output help information
    17. \033[0m"
    18. }
    19. if [[ $1 == '--help' || $1 == '-h' ]]
    20. then
    21. USAGE
    22. exit 0
    23. fi
    24. h2 "[Step $item]: Assign a value to a variable..."; let item+=1
    25. while getopts ":n:" optname;do
    26. case "$optname" in
    27. "n")
    28. app_name=$OPTARG
    29. ;;
    30. ":")
    31. echo "This option has no value!"
    32. ;;
    33. "*")
    34. echo "error message"
    35. ;;
    36. "?")
    37. echo "Not sure about this option..."
    38. ;;
    39. esac
    40. done
    41. jar_name=$(basename $(ls /apps/var/${app_name}/*.jar))
    42. echo -e "\033[33m
    43. app_name : ${app_name}
    44. After successful deployment, be sure to execute the instructions ( ps -ef |grep ${jar_name} | grep -v grep ) to ensure that the new process exists...
    45. \033[0m"
    46. read -p "Press enter to confirm and continue execution. To terminate, press 'CTRL + C' to terminate the script..."
    47. h2 "[Step $item]: backup the original jar package and Synchronous jar package..."; let item+=1
    48. if [[ ! -d ${backup_dir} ]];then
    49. mkdir ${tmp_dir} -p
    50. fi
    51. cd /apps/var/
    52. tar zcf ${backup_dir}${app_name}_${cur_date}.tgz ${app_name}
    53. echo -e "
    54. "
    55. ls -l ${backup_dir}${app_name}_${cur_date}.tgz
    56. rsync -az --delete ${rsync_source_dir}${app_name} .
    57. chmod 755 -R ${app_name}
    58. h2 "[Step $item]: Start the deployment..."; let item+=1
    59. supervisorctl restart ${app_name} || true
    60. ps -ef | grep ${jar_name} | grep -v grep
    61. echo "---- log path: tail -100f /apps/var/${app_name}/logs/catalina.out ------"