From 991e1b0f15b8d08a2e8c6f49e28713f07ea18056 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Thu, 26 Mar 2020 22:21:19 +0800 Subject: [PATCH] add git_wrapper.sh --- script/git_wrapper.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 script/git_wrapper.sh diff --git a/script/git_wrapper.sh b/script/git_wrapper.sh new file mode 100755 index 0000000..349be78 --- /dev/null +++ b/script/git_wrapper.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +GIT_PATH=$(which git) +GIT_BAK="${GIT_PATH}.bak" +PROXY_CMD_PATH=$(which proxychains) + +if [ "${UID}" != "0" ]; then + echo "this script need run with root." + exit 1 +fi + +if [ -x ${GIT_BAK} ]; then + mv ${GIT_BAK} ${GIT_PATH} + echo "change git cmd to origin" +else + mv ${GIT_PATH} ${GIT_BAK} + echo "#!/bin/sh" >> ${GIT_PATH} + echo "" >> ${GIT_PATH} + echo "${PROXY_CMD_PATH} ${GIT_BAK} \$*" >> ${GIT_PATH} + chmod +x ${GIT_PATH} + echo "git cmd wraped by proxy" +fi