| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #!/bin/bash
- if [ "$#" -ne 1 ]; then
- echo
- echo -e "######################################################################"
- echo -e "######\033[41;37m Wrong paraments input, please refer below usage info !!! \033[0m######"
- echo -e "######################################################################"
- echo
- echo -e "Usage\t: \033[44;37m./<cmd.sh> <user_ID>\033[0m"
- echo -e "Example\t: \033[45;37m$0 ed\033[0m"
- echo; exit 1
- fi
-
- GIT_SVR_IP1=127.0.0.1
- GIT_SVR_IP2=172.201.0.1
- GIT_SVR_IP1_PORT=127.0.0.1:3000
- GIT_SVR_IP2_PORT=172.201.0.1:3000
- OWNER="$1"
- GIT_Status_tmp="/tmp/tmp_git_status"
-
- CHK_gitea_tmp (){
- ls $GIT_Status_tmp > /dev/null 2>&1
- if [[ $? != 0 ]]; then
- echo -e "There is no folder ($GIT_Status_tmp) exist, create a new one. "
- mkdir -p $GIT_Status_tmp
- fi
- }
-
- ping $GIT_SVR_IP1 -c1 > /dev/null 2>&1
- if [[ $? != 0 ]]; then
- ping $GIT_SVR_IP2 -c1 > /dev/null 2>&1
- if [[ $? != 0 ]]; then
- echo -e "\033[41;37mThere is no connection to gitea server ($GIT_SVR_IP1, $GIT_SVR_IP2). Exit \033[0m"
- exit
- else
- GIT_SVR_IP_PORT=$GIT_SVR_IP2
- fi
- else
- GIT_SVR_IP_PORT=$GIT_SVR_IP1
- fi
-
- CHK_gitea_tmp
-
- git status
- echo
- echo -e -n "\033[33mDo you want to do git update? (y|n) \033[0m"
- read yn
- if [[ $yn == "y" ]]; then
- git add --all
- git commit -m "`date +"%Y/%m/%d %H:%M:%S"`"
- git push
- echo "Done"
- echo
- elif [[ $yn == "n" ]]; then
- echo -e "\033[31mYour input is \"$yn\". Exit \033[0m"
- exit
- echo
- else
- echo -e "\033[41;37mWrong input. Exit. \033[0m"
- exit
- echo
- fi
|