Created
December 1, 2011 07:19
-
-
Save geta6/1414595 to your computer and use it in GitHub Desktop.
brew and tsocks installer
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 | |
accept() { | |
RAW='FALSE' | |
while getopts r: opt | |
do | |
case $opt in | |
r) RAW='TRUE' ;; | |
esac | |
done | |
if [ $RAW = 'TRUE' ]; then | |
ARG=$2 | |
[[ -s `which $ARG` ]] && echo 1 | |
[[ ! -s `which $ARG` ]] && echo 0 | |
else | |
ARG=$1 | |
printf "%-10s" $ARG | |
if [[ -s `which $ARG` ]]; then | |
printf "%5s\n" ok | |
else | |
printf "%5s\n" not | |
fi | |
fi | |
} | |
echo check acceptability... | |
accept brew | |
if [[ `accept -r brew` = 0 ]]; then | |
echo "command not found: brew: do you want to install? [y/n]"; | |
read ANS | |
if [[ $ANS = 'y' ]]; then | |
sudo chown -R `whoami` /usr/local | |
ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)" | |
else | |
echo "interrupt, quit installation." | |
exit 1 | |
fi | |
unset ANS | |
fi | |
accept tsocks | |
if [[ `accept -r tsocks` = 0 ]]; then | |
echo "command not found: tsocks: do you want to install via homebrew? [y/n]"; | |
read ANS | |
if [[ $ANS = 'y' ]]; then | |
brew install https://github.com/adamv/homebrew-alt/raw/master/other/tsocks.rb | |
else | |
echo "interrupt, quit installation." | |
exit 1 | |
fi | |
unset ANS | |
fi | |
[[ -z `cat /usr/local/etc/tsocks.conf | grep 2929` ]] && echo server = 127.0.0.1$'\n'server_type = 4$'\n'server_port = 2929 >> /usr/local/etc/tsocks.conf | |
echo "install done, now tsocks available." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment