#!/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./ \033[0m" echo -e "Example\t: \033[45;37m$0 127.0.0.1\033[0m" echo; exit 1 fi GIT_SVR_PORT=3000 GIT_Status_tmp="/tmp/tmp_git_status" ##### Func 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 $1 -c1 > /dev/null 2>&1 if [[ $? != 0 ]]; then echo -e "\033[41;37mThere is no connection to gitea server ($1). Exit \033[0m" exit 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