Files
dotfiles/script/git_wrapper.sh
2020-03-26 22:21:19 +08:00

23 lines
496 B
Bash
Executable File

#!/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