add git_wrapper.sh

This commit is contained in:
2020-03-26 22:21:19 +08:00
parent 3dcda197dd
commit 991e1b0f15

22
script/git_wrapper.sh Executable file
View File

@@ -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