您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Z001.git_update.sh 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. if [ "$#" -ne 1 ]; then
  3. echo
  4. echo -e "######################################################################"
  5. echo -e "######\033[41;37m Wrong paraments input, please refer below usage info !!! \033[0m######"
  6. echo -e "######################################################################"
  7. echo
  8. echo -e "Usage\t: \033[44;37m./<cmd.sh> <gitea SVR IP>\033[0m"
  9. echo -e "Example\t: \033[45;37m$0 127.0.0.1\033[0m"
  10. echo; exit 1
  11. fi
  12. GIT_SVR_PORT=3000
  13. GIT_Status_tmp="/tmp/tmp_git_status"
  14. ##### Func
  15. CHK_gitea_tmp (){
  16. ls $GIT_Status_tmp > /dev/null 2>&1
  17. if [[ $? != 0 ]]; then
  18. echo -e "There is no folder ($GIT_Status_tmp) exist, create a new one. "
  19. mkdir -p $GIT_Status_tmp
  20. fi
  21. }
  22. ping $1 -c1 > /dev/null 2>&1
  23. if [[ $? != 0 ]]; then
  24. echo -e "\033[41;37mThere is no connection to gitea server ($1). Exit \033[0m"
  25. exit
  26. fi
  27. CHK_gitea_tmp
  28. git status
  29. echo
  30. echo -e -n "\033[33mDo you want to do git update? (y|n) \033[0m"
  31. read yn
  32. if [[ $yn == "y" ]]; then
  33. git add --all
  34. git commit -m "`date +"%Y/%m/%d %H:%M:%S"`"
  35. git push
  36. echo "Done"
  37. echo
  38. elif [[ $yn == "n" ]]; then
  39. echo -e "\033[31mYour input is \"$yn\". Exit \033[0m"
  40. exit
  41. echo
  42. else
  43. echo -e "\033[41;37mWrong input. Exit. \033[0m"
  44. exit
  45. echo
  46. fi