Skip to content

Commit

Permalink
Merge Devel (#10)
Browse files Browse the repository at this point in the history
* Added developer mode

* Automatically installs docker on debian

* Added fi to complete if statement

* Added quotes around platform command

* Fixed typo from darwin>debian (probably atom's fault)

* Set to use install script at get.docker.com

* Updated docker build

* Fixed build issues

* Switched to debian:latest which should ensure max compatibility

* Made it easier and faster to build

* Updated amd64 dockerfile and removed unnecessary code

* Added nopass option, which should fix #7

* Uncommented a line

* Fixed a typo

* Replaced mkdir with useradd -m

* Exposed both udp and tcp ports

* Only exposed 1194/udp

* Added 1194/udp to detect_port

* Added note about the devel branch

* Added note about TCP

* Changed latest to stretch

* Changed latest to stretch

* Fixed issues mentioned in #9

* Fixed issues mentioned in #9
  • Loading branch information
InnovativeInventor committed Jul 16, 2018
1 parent c9b1dcc commit 522252b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 74 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -18,9 +18,9 @@ Options:
-r --rand <amount> Specify the amount of random data (100's of bytes) that you want your Docker container to be seeded with
```

Note: Usage on ARM is not fully supported yet, although feel free to help out in this area.
Note: Usage on ARM is not fully supported yet, although feel free to help out in this area. Also, PiVPN over TCP is not supported.

# Credits & Contributions
Visit PiVPN's GitHub at https://github.com/pivpn/pivpn.

Contributions are always welcome! Just submit a pull request, and I'll review it.
Contributions are always welcome! Just submit a pull request, and I'll review it. Please note that newest features are on the devel branch.
34 changes: 18 additions & 16 deletions amd64/Dockerfile
@@ -1,20 +1,22 @@
FROM ubuntu:16.04
FROM debian:stretch

MAINTAINER InnovativeInventor

RUN apt-get update
RUN apt-get install curl -y
RUN apt-get install software-properties-common -y
RUN apt-get install debconf-utils
RUN apt-get install git -y
RUN apt-get install nano
RUN apt-get install whiptail -y
RUN apt-get install openvpn -y
RUN apt-get install dhcpcd5 -y
RUN apt-get install dnsutils -y
RUN apt-get install expect -y
RUN apt-get install whiptail
RUN mkdir /home/pivpn

RUN apt-get update && apt-get install -y \
curl \
software-properties-common \
debconf-utils \
git \
nano \
whiptail \
openvpn \
dhcpcd5 \
dnsutils \
expect \
whiptail \
&& rm -rf /var/lib/apt/lists/*

RUN curl -L https://install.pivpn.io -o install.sh
RUN useradd pivpn
EXPOSE 1194
RUN useradd -m pivpn
EXPOSE 1194/udp
33 changes: 17 additions & 16 deletions armhf/Dockerfile
@@ -1,20 +1,21 @@
FROM resin/armv7hf-debian
FROM arm32v7/debian:stretch

MAINTAINER InnovativeInventor

RUN apt-get update
RUN apt-get install curl -y
RUN apt-get install software-properties-common -y
RUN apt-get install debconf-utils
RUN apt-get install git -y
RUN apt-get install nano
RUN apt-get install whiptail -y
RUN apt-get install openvpn -y
RUN apt-get install dhcpcd5 -y
RUN apt-get install dnsutils -y
RUN apt-get install expect -y
RUN apt-get install whiptail
RUN mkdir /home/pivpn
RUN apt-get update && apt-get install -y \
curl \
software-properties-common \
debconf-utils \
git \
nano \
whiptail \
openvpn \
dhcpcd5 \
dnsutils \
expect \
whiptail \
&& rm -rf /var/lib/apt/lists/*

RUN curl -L https://install.pivpn.io -o install.sh
RUN useradd pivpn
EXPOSE 1194
RUN useradd -m pivpn
EXPOSE 1194/udp
81 changes: 41 additions & 40 deletions setup.sh
Expand Up @@ -29,6 +29,7 @@
VERSION="1.0"
config="1"
seed="1"
extra=""

while [[ $# -gt 0 ]]
do
Expand All @@ -53,6 +54,14 @@ case $key in
build=YES
shift # past argument
;;
-d|--dev)
dev=YES
shift # past argument
;;
-n|--nopass)
extra="nopass"
shift # past argument
;;
esac
done

Expand All @@ -66,52 +75,45 @@ display_help() {
echo ' -b --build Builds dockerfile'
echo ' -c --config <amount> Specify the amount of client configs you want'
echo ' -r --rand <amount> Specify the amount of random data (in 100s of bytes) that you want your Docker container to be seeded with'
echo ' -d --dev Runs in developer mode'
echo ' -n --nopass Creates a .ovpn file with no password'
exit 1
}

setup_repo() {
if [ -e docker-pivpn ]; then # check if -e will return if directory is detected
install_docker_mac() {
echo "Please install docker at https://download.docker.com/mac/stable/Docker.dmg and restart this script"
}

build_and_setup() {
if [ "$dev" == YES ]; then
echo "You are running as a developer, updates from git will not be fetched and your docker image will be built"
elif [ -e docker-pivpn ]; then # check if -e will return if directory is detected
cd docker-pivpn
git pull
cd ..
else
git clone https://github.com/InnovativeInventor/docker-pivpn --depth 1
fi
}

install_docker_mac() {
echo "Please install docker at https://download.docker.com/mac/stable/Docker.dmg and restart this script"
}

install_docker_linux() {
raspbian_dependencies () {
sudo apt-get update
sudo apt-get install -y apt-transport-https
sudo apt-get install ca-certificates
sudo apt-get install -y curl
sudo apt-get install -y software-properties-common
sudo apt-get install lsof
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce
}
}
if ! [ $(which docker) ]; then
if [ "$platform" == debian ]; then
curl -fsSL get.docker.com | sh
else
echo "This OS is not supported"
fi
fi

build_and_setup() {
if [ "$build" == YES ]; then
build
if [ "$dev" == YES ]; then
build_run
elif [ "$build" == YES ]; then
build_run
else
pull
pull_run
fi
docker_run_build
pivpn_setup
}

build() {
build_run() {
architecture=$(uname -m)
if [[ "$architecture" == "x86_64" ]]; then
tag="amd64"
Expand All @@ -123,15 +125,16 @@ build() {
echo "Architecture not supported"
fi

if [ -e Dockerfile ]; then
docker build -t innovativeinventor/docker-pivpn:$tag $tag/Dockerfile
if [ -e $tag/Dockerfile ]; then
docker build $tag -t docker-pivpn:$tag
else
echo "Dockerfile does not exist, will not build. Defaulting to pull"
pull
fi
container="$(docker run -i -d -P --cap-add=NET_ADMIN docker-pivpn:$tag)" # check if permissons can be lowered
}

pull() {
pull_run() {
architecture=$(uname -m)
if [[ "$architecture" == "x86_64" ]]; then
tag="amd64"
Expand All @@ -144,14 +147,11 @@ pull() {
else
echo "Architecture not supported"
fi
}

docker_run_build () {
container="$(docker run -i -d -P --cap-add=NET_ADMIN innovativeinventor/docker-pivpn:$tag)" # check if permissons can be lowered
}

detect_port() {
output=$(docker port "$container" 1194)
output=$(docker port "$container" 1194/udp)
port=${output#0.0.0.0:}
echo Your port is $port
}
Expand All @@ -178,11 +178,11 @@ gen_config() {
count=0
while [[ $count -lt $config ]]; do
echo "Generating configs . . . Please answer the prompts"
docker exec -it $container pivpn -a
docker exec -it $container pivpn -a $extra
count+=1
done

docker cp $container:/home/pivpn/ovpns .
docker cp $container:/home/pivpn/ovpns ovpns
}

seed_random() {
Expand All @@ -191,7 +191,6 @@ seed_random() {
if [ -e randwrite.sh ]; then
docker cp randwrite.sh $container:/randwrite.sh
else
setup_repo
docker cp docker-pivpn/randwrite.sh $container:/randwrite.sh
fi

Expand All @@ -209,4 +208,6 @@ if [ "$help" == YES ]; then
display_help
fi

platform=$(python -c "import platform; print(platform.dist()[0])")

build_and_setup

0 comments on commit 522252b

Please sign in to comment.