Last active
December 18, 2015 00:48
-
-
Save jiskanulo/5698831 to your computer and use it in GitHub Desktop.
.subversion/servers ファイルを予め2つ用意しておいてコマンド1つで切り替える
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
subversion_base_config_path="${HOME}/.subversion" | |
config_file="${subversion_base_config_path}/servers" | |
function abort() | |
{ | |
echo $1 2>&1 | |
exit 1 | |
} | |
function switch_config() | |
{ | |
mode=$1 | |
if [ "${mode}" = "proxy" ]; then | |
echo "switch mode 'proxy'." | |
ln -fs "${config_file}.connect-with-proxy" $config_file | |
elif [ "${mode}" = "direct" ]; then | |
echo "switch mode to 'direct'." | |
ln -fs "${config_file}.connect-direct" $config_file | |
else | |
abort "invalid arg ${mode}" | |
fi | |
} | |
target_file="`readlink ${config_file}`" | |
base_name="`basename ${target_file}`" | |
if [ "${base_name}" = "servers.connect-direct" ]; then | |
switch_config proxy | |
elif [ "${base_name}" = "servers.connect-with-proxy" ]; then | |
switch_config direct | |
else | |
abort "can not read ${config_file}, please check file-path." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment