Adds installer

This commit is contained in:
zachary 2015-07-06 10:40:10 -04:00
parent 6b2e487c15
commit 7975f40d98
5 changed files with 43 additions and 19 deletions

View file

@ -14,18 +14,14 @@ ADD ./dind/wrapdocker /usr/local/bin/wrapdocker
RUN chmod +x /usr/local/bin/wrapdocker
COPY ./env.sh /usr/local/bin/set_env
COPY ./shutdown.sh /usr/local/bin/stop-tor-router
COPY ./startup.sh /usr/local/bin/stop-tor-router
COPY ./startup.sh /usr/local/bin/start-tor-router
COPY ./tor-router.sh /usr/local/bin/tor-router
COPY ./new_ip.sh /usr/local/bin/new-ip
RUN chmod -v +x /usr/local/bin/set_env
RUN chmod -v +x /usr/local/bin/stop-tor-router
RUN chmod -v +x /usr/local/bin/start-tor-router
@ -38,4 +34,8 @@ EXPOSE 9050
ENV TOR_INSTANCES 5
ENV TOR_PORT 9050
ENV INSTANCE_PREFIX tor-
CMD ["/usr/local/bin/tor-router"]

5
env.sh
View file

@ -1,5 +0,0 @@
export TOR_INSTANCES=${TOR_INSTANCES:=5}
export TOR_PORT=${TOR_PORT:=9050}
export INSTANCE_PREFIX="tor-"
export IP_ADDRESS=$1
export CONTROL_PORT_DIR=$2

33
install.sh Normal file
View file

@ -0,0 +1,33 @@
#!/bin/bash
apt-get update -y
apt-get install -yqq curl git tar
echo 'installing docker...'
# START: docker installer
if [ ! -e /usr/lib/apt/methods/https ]; then
apt-get update
apt-get install -y apt-transport-https
fi
# Add the repository to your APT sources
echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list
# Then import the repository key
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# Install docker
apt-get update
apt-get install -y lxc-docker-1.5.0
#
# Alternatively, just use the curl-able install.sh script provided at https://get.docker.com
#
# END: docker installer
echo 'running tor-router...'
/usr/bin/docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock -p 9050:9050 --rm -it znetstar/tor-router:0.0.1
exit 0

View file

@ -1,7 +1,5 @@
#!/bin/bash
source env.sh
index="0"
while [ $index -lt $TOR_INSTANCES ]
@ -16,7 +14,7 @@ echo "stop haproxy"
docker rm -f haproxy
echo "closing port"
sudo iptables -A INPUT -p tcp --dport 9050 -j REJECT
iptables -A INPUT -p tcp --dport 9050 -j REJECT
#sleep 5

View file

@ -1,9 +1,7 @@
#!/bin/bash
source env.sh
TEMP_HA_CONFIG=$(mktemp)
TOR_CMD='tor --MaxCircuitDirtiness 60 --RunAsDaemon 0 --CookieAuthentication 0 --controlport 0.0.0.0:9051 --HashedControlPassword 16:4E9480609FC7089F604C83E788481164C25C205288E17D9E5E73EB050B --PidFile tor.pid --SocksPort 0.0.0.0:9150 --DataDirectory /data/tor --ExcludeSingleHopRelays 0 --NewCircuitPeriod 30 --EnforceDistinctSubnets 0 --AllowDotExit 1'
export TEMP_HA_CONFIG=$(mktemp)
export TOR_CMD='tor --MaxCircuitDirtiness 60 --RunAsDaemon 0 --CookieAuthentication 0 --controlport 0.0.0.0:9051 --HashedControlPassword 16:4E9480609FC7089F604C83E788481164C25C205288E17D9E5E73EB050B --PidFile tor.pid --SocksPort 0.0.0.0:9150 --DataDirectory /data/tor --ExcludeSingleHopRelays 0 --NewCircuitPeriod 30 --EnforceDistinctSubnets 0 --AllowDotExit 1'
index="0"
@ -21,7 +19,7 @@ do
echo "instnce $current_instance will be assigned control port control port $control_port"
echo "creating instance $current_instance..."
docker run --name $current_instance -d -v /data --restart="on-failure" nagev/tor $TOR_CMD
docker run --name $current_instance -d -v /data --restart="on-failure" znetstar/tor $TOR_CMD
echo "instance $current_instance created"
index=$[$index+1]
done
@ -65,7 +63,7 @@ do
current_instance=$INSTANCE_PREFIX$index
instances=$instances" --link $current_instance:$current_instance"
cat <<-EOF >> $TEMP_HA_CONFIG
server $current_instance $current_instance:9150 check
server $current_instance $current_instance:9050 check
EOF
index=$[$index+1]
done