commit a86785411a1dcc89262be426f28b99e786315cbd Author: Andreas Fahrecker Date: Sat Mar 16 01:42:57 2024 +0100 Initial Commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..724f736 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:buster + +WORKDIR /opt/protonmail + +# Copy bash scripts +COPY gpgparams install.sh entrypoint.sh VERSION /protonmail/ + +# Install dependencies and protonmail bridge +RUN bash install.sh + +ENTRYPOINT ["bash", "/opt/protonmail/entrypoint.sh"] + +EXPOSE 25/tcp +EXPOSE 143/tcp \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..a47e264 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,46 @@ +#!groovy + +pipeline { + agent none + + stages { + stage('Build/Push Docker Image') { + when { + beforeAgent true; + branch 'main' + } + agent { + label 'linux' + } + environment { + DOCKER_HUB_CREDENTIALS = credentials('docker-hub-fah16145') + } + stages { + stage('Login') { + steps { + sh 'docker login -u ${DOCKER_HUB_CREDENTIALS_USR} -p ${DOCKER_HUB_CREDENTIALS_PSW}' + } + } + stage('Default Image') { + stages { + stage('Build') { + steps { + sh 'docker build -t fah16145/protonmail-bridge:latest .' + } + } + stage('Push') { + steps { + sh 'docker push fah16145/protonmail-bridge:latest' + } + } + } + } + } + post { + always { + sh 'docker logout' + } + } + } + } +} diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..60c3693 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +3.9.1-1 \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..6bbb77e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -ex + +# Initialize +if [[ $1 == init ]]; then + + # # Parse parameters + # TFP="" # Default empty two factor passcode + # shift # skip `init` + # while [[ $# -gt 0 ]]; do + # key="$1" + # case $key in + # -u|--username) + # USERNAME="$2" + # ;; + # -p|--password) + # PASSWORD="$2" + # ;; + # -t|--twofactor) + # TWOFACTOR="$2" + # ;; + # esac + # shift + # shift + # done + + # Initialize pass + gpg --generate-key --batch /protonmail/gpgparams + pass init pass-key + + # Login + protonmail-bridge --cli + +else + + # socat will make the conn appear to come from 127.0.0.1 + # ProtonMail Bridge currently expects that. + # It also allows us to bind to the real ports :) + socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 & + socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 & + + # Start protonmail + # Fake a terminal, so it does not quit because of EOF... + rm -f faketty + mkfifo faketty + cat faketty | protonmail-bridge --cli + +fi \ No newline at end of file diff --git a/gpgparams b/gpgparams new file mode 100644 index 0000000..355568e --- /dev/null +++ b/gpgparams @@ -0,0 +1,8 @@ +%no-protection +%echo Generating a basic OpenPGP key +Key-Type: RSA +Key-Length: 2048 +Name-Real: pass-key +Expire-Date: 0 +%commit +%echo done diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..dbe3eb5 --- /dev/null +++ b/install.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -ex + +VERSION=`cat VERSION` +DEB_FILE=protonmail-bridge_${VERSION}_amd64.deb + +# Install dependents +apt-get update +apt-get install -y --no-install-recommends socat pass ca-certificates + +# Build time dependencies +apt-get install -y wget binutils xz-utils + +# Repack deb (remove unnecessary dependencies) +mkdir deb +cd deb +wget -q https://protonmail.com/download/bridge/${DEB_FILE} +ar x -v ${DEB_FILE} +mkdir control +tar zxvf control.tar.gz -C control +sed -i "s/^Depends: .*$/Depends: libgl1, libc6, libsecret-1-0, libstdc++6, libgcc1/" control/control +cd control +tar zcvf ../control.tar.gz . +cd ../ +ar rcs -v ${DEB_FILE} debian-binary control.tar.gz data.tar.gz +cd ../ + +# Install protonmail bridge +apt-get install -y --no-install-recommends ./deb/${DEB_FILE} + +# Cleanup +apt-get purge -y wget binutils xz-utils +apt-get autoremove -y +rm -rf /var/lib/apt/lists/* +rm -rf deb