aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dockerignore1
-rw-r--r--.gitignore14
-rw-r--r--Makefile19
-rw-r--r--docker-compose.yml28
-rw-r--r--docker/Dockerfile42
-rwxr-xr-xdocker/install.sh187
-rw-r--r--downloads/.git-keep0
7 files changed, 291 insertions, 0 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..e663a96
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+downloads/*
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..04e47ba
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+.*.swp
+*.pyc
+*.pyo
+.DS_Store
+tags
+.ropeproject
+*.actual
+.vimcache
+.idea
+.mypy_cache
+.envrc
+*.sqlite
+downloads/*
+!downloads/.git-keep
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8f6cd99
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+.PHONY: build
+
+help:
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
+
+build: ## Build the Docker image
+ docker-compose -p transmission build
+
+up: build ## Bring the container up
+ docker-compose -p transmission up -d
+
+down: ## Stop the container
+ docker-compose -p transmission stop
+
+enter: ## Enter the running container
+ docker-compose -p transmission exec nordvpnd /bin/bash
+
+clean: down ## Remove stoped containers
+ docker-compose -p transmission rm -f
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..de618be
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,28 @@
+version: '3'
+services:
+ nordvpnd:
+ build:
+ context: ./
+ dockerfile: ./docker/Dockerfile
+ network_mode: "bridge"
+ container_name: transmission
+ image: thornycrackers/transmission
+ cap_add:
+ - NET_ADMIN
+ ulimits:
+ nproc: 65535
+ nofile:
+ soft: 26677
+ hard: 46677
+ ports:
+ - "8000"
+ volumes:
+ - /dev/net/tun:/dev/net/tun
+ - nord-data:/var/lib/nordvpn/data
+ - ./downloads:/root/Downloads
+ command: /bin/bash
+ tty: true
+ stdin_open: true
+
+volumes:
+ nord-data:
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..a87908e
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,42 @@
+FROM ubuntu:20.04
+
+# Set a term for terminal inside the container, can't clear without it
+ENV TERM screen-256color
+ENV DEBIAN_FRONTEND noninteractive
+
+
+# Update and install
+RUN apt-get update && apt-get install -y \
+ wget \
+ curl \
+ bridge-utils \
+ openvpn \
+ transmission-cli \
+ transmission-daemon \
+ locales
+
+# Generally a good idea to have these, extensions sometimes need them
+RUN locale-gen en_US.UTF-8
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+ENV LC_ALL en_US.UTF-8
+
+# The code is stored here
+WORKDIR /usr/src/app
+
+# Copy code into image for distribution
+COPY . /usr/src/app
+
+# Install Nord
+RUN bash /usr/src/app/docker/install.sh
+
+# Norcvpnd complains about if this isn't present
+RUN mkdir /run/nordvpn
+
+# Convenience
+RUN echo 'alias tsm="transmission-remote"' >> /root/.bashrc
+RUN echo 'alias tsd="transmission-daemon"' >> /root/.bashrc
+RUN echo 'alias tsdk="pkill transmission"' >> /root/.bashrc
+RUN echo 'alias myip="curl ipinfo.io"' >> /root/.bashrc
+
+ENTRYPOINT ["nordvpnd"]
diff --git a/docker/install.sh b/docker/install.sh
new file mode 100755
index 0000000..13e900d
--- /dev/null
+++ b/docker/install.sh
@@ -0,0 +1,187 @@
+#!/bin/sh
+# Copied from command:
+# sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)#
+# I save the script to make apt-get install have '-y' cause hackerman
+
+# check for root access
+SUDO=
+if [ "$(id -u)" -ne 0 ]; then
+ SUDO=$(command -v sudo 2> /dev/null)
+
+ if [ ! -x "$SUDO" ]; then
+ echo "Error: Run this script as root"
+ exit 1
+ fi
+fi
+
+set -e
+ARCH=$(uname -m)
+BASE_URL=https://repo.nordvpn.com/
+KEY_PATH=/gpg/nordvpn_public.asc
+REPO_PATH_DEB=/deb/nordvpn/debian
+REPO_PATH_RPM=/yum/nordvpn/centos
+RELEASE="stable main"
+ASSUME_YES=false
+
+# Parse command line arguments. Available arguments are:
+# -n Non-interactive mode. With this flag present, 'assume yes' or
+# 'non-interactive' flags will be passed when installing packages.
+# -b <url> The base URL of the public key and repository locations.
+# -k <path> Path to the public key for the repository.
+# -d <path|file> Repository location for debian packages.
+# -v <version> Debian package version to use.
+# -r <path|file> Repository location for rpm packages.
+while getopts 'nb:k:d:r:v:' opt
+do
+ case $opt in
+ n) ASSUME_YES=true ;;
+ b) BASE_URL=$OPTARG ;;
+ k) KEY_PATH=$OPTARG ;;
+ d) REPO_PATH_DEB=$OPTARG ;;
+ r) REPO_PATH_RPM=$OPTARG ;;
+ v) RELEASE=$OPTARG ;;
+ *) ;;
+ esac
+done
+
+# Construct the paths to the package repository and its key
+PUB_KEY=${BASE_URL}${KEY_PATH}
+REPO_URL_DEB=${BASE_URL}${REPO_PATH_DEB}
+REPO_URL_RPM=${BASE_URL}${REPO_PATH_RPM}
+
+check_cmd() {
+ command -v "$1" 2> /dev/null
+}
+
+get_install_opts_for_apt() {
+ flags=$(get_install_opts_for "apt")
+ RETVAL="$flags"
+}
+
+get_install_opts_for_yum() {
+ flags=$(get_install_opts_for "yum")
+ RETVAL="$flags"
+}
+
+get_install_opts_for_dnf() {
+ flags=$(get_install_opts_for "dnf")
+ RETVAL="$flags"
+}
+
+get_install_opts_for_zypper() {
+ flags=$(get_install_opts_for "zypper")
+ RETVAL="$flags"
+}
+
+get_install_opts_for() {
+ if $ASSUME_YES; then
+ case "$1" in
+ zypper)
+ echo " -n";;
+ *)
+ echo " -y";;
+ esac
+ fi
+ echo ""
+}
+
+# For any of the following distributions, these steps are performed:
+# 1. Add the NordVPN repository key
+# 2. Add the NordVPN repository
+# 3. Install NordVPN
+
+# Install NordVPN for Debian, Ubuntu, Elementary OS, and Linux Mint
+# (with the apt-get package manager)
+install_apt() {
+ if check_cmd apt-get; then
+ get_install_opts_for_apt
+ install_opts="$RETVAL"
+ # Ensure apt is set up to work with https sources
+ $SUDO apt-get $install_opts update
+ $SUDO apt-get $install_opts install apt-transport-https -y
+
+ # Add the repository key with either wget or curl
+ if check_cmd wget; then
+ wget -qO - "${PUB_KEY}" | $SUDO tee /etc/apt/trusted.gpg.d/nordvpn_public.asc > /dev/null
+ elif check_cmd curl; then
+ curl -s "${PUB_KEY}" | $SUDO tee /etc/apt/trusted.gpg.d/nordvpn_public.asc > /dev/null
+ else
+ echo "Couldn't find wget or curl - one of them is needed to proceed with the installation"
+ exit 1
+ fi
+
+ echo "deb ${REPO_URL_DEB} ${RELEASE}" | $SUDO tee /etc/apt/sources.list.d/nordvpn.list
+ $SUDO apt-get $install_opts update
+ $SUDO apt-get $install_opts install nordvpn -y
+ exit
+ fi
+}
+
+# Install NordVPN for RHEL and CentOS
+# (with the yum package manager)
+install_yum() {
+ if check_cmd yum && check_cmd yum-config-manager; then
+ get_install_opts_for_yum
+ install_opts="$RETVAL"
+
+ repo="${REPO_URL_RPM}"
+ if [ ! -f "${REPO_URL_RPM}" ]; then
+ repo="${repo}/${ARCH}"
+ fi
+
+ $SUDO rpm -v --import "${PUB_KEY}"
+ $SUDO yum-config-manager --add-repo "${repo}"
+ $SUDO yum $install_opts install nordvpn
+ exit
+ fi
+}
+
+# Install NordVPN for Fedora and QubesOS
+# (with the dnf package manager)
+install_dnf() {
+ if check_cmd dnf; then
+ get_install_opts_for_dnf
+ install_opts="$RETVAL"
+
+ repo="${REPO_URL_RPM}"
+ if [ ! -f "${REPO_URL_RPM}" ]; then
+ repo="${repo}/${ARCH}"
+ fi
+
+ $SUDO rpm -v --import "${PUB_KEY}"
+ $SUDO dnf config-manager --add-repo "${repo}"
+ $SUDO dnf $install_opts install nordvpn
+ exit
+ fi
+}
+
+# Install NordVPN for openSUSE
+# (with the zypper package manager)
+install_zypper() {
+ if check_cmd zypper; then
+ if ! check_cmd curl; then
+ echo "Curl is needed to proceed with the installation"
+ exit 1
+ fi
+ get_install_opts_for_zypper
+ install_opts="$RETVAL"
+
+ $SUDO rpm -v --import "${PUB_KEY}"
+ if [ -f "${REPO_URL_RPM}" ]; then
+ $SUDO zypper addrepo -f "${REPO_URL_RPM}"
+ else
+ $SUDO zypper addrepo -g -f "${REPO_URL_RPM}/${ARCH}" nordvpn
+ fi
+ $SUDO zypper $install_opts install nordvpn
+ exit
+ fi
+}
+
+install_apt
+install_yum
+install_dnf
+install_zypper
+
+# None of the known package managers (apt, yum, dnf, zypper) are available
+echo "Error: Couldn't identify the package manager"
+exit 1
diff --git a/downloads/.git-keep b/downloads/.git-keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/downloads/.git-keep