Skip to content

Commit

Permalink
docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
itsnebulalol committed Jul 26, 2022
1 parent b94a899 commit b624d4e
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 11 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Push to Docker Hub

on:
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: itsnebulalol/permasigner:latest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@ ldid
dpkg*
dpkg/
.DS_Store
*/.DS_Store
*/.DS_Store
ipas
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.10.0-slim-bullseye
WORKDIR /usr/src/permasigner

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# system dependencies
RUN apt-get update
RUN apt-get upgrade -y
RUN apt install -y git gcc python3-dev

# python dependencies
COPY ./requirements.txt .
COPY . .
RUN pip install --upgrade pip setuptools wheel
RUN pip install -r requirements.txt

ENV IS_DOCKER_CONTAINER Yes
ENTRYPOINT [ "data/docker-entrypoint.sh" ]
15 changes: 15 additions & 0 deletions data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

ARGS=""

if [ ! -z "$URL" ]; then
ARGS="$ARGS -u $URL"
fi

if [ ! -z "$DEBUG" ]; then
ARGS="$ARGS -d"
fi

echo "Running Permasigner with args:$ARGS"
echo ""
python -u main.py $ARGS -n
32 changes: 22 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def cmd_in_path(args, cmd):
if is_ios():
if args.debug:
print(f"[DEBUG] Checking for ldid on iOS")

if os.path.exists("/.bootstrapped"):
print("[-] Your device seems to be strapped with Elucubratus. Unfortunately, we do not support these devices. You can switch to a device that uses Procursus (Taurine, odysseyra1n), or use the online method on our GitHub.")
print(" https://github.com/itsnebulalol/permasigner/wiki/Run-Online")
Expand Down Expand Up @@ -190,7 +190,7 @@ def main(args):
# Prompt the user if they'd like to use an external IPA or a local IPA
if not (args.url or args.path):
option = input(
"[?] Would you like to use an external or a local IPA? [E, L] ")
"[?] Would you like to use an external or a local IPA? [E, L] ").lower()

with tempfile.TemporaryDirectory() as tmpfolder:
print("[*] Created temporary directory.")
Expand Down Expand Up @@ -231,7 +231,7 @@ def main(args):
print(
"[-] That file does not exist! Make sure you're using a direct path to the IPA file.")
exit(1)
elif option == "E":
elif option == "e":
url = input("[?] Paste in the *direct* path to an IPA online: ")

if not os.path.splitext(urlparse(url).path)[1] == ".ipa":
Expand All @@ -254,9 +254,17 @@ def main(args):
except requests.exceptions.RequestException as err:
print(f"[-] URL provided is not reachable. Error: {err}")
exit(1)
elif option == "L":
path = input(
"[?] Paste in the path to an IPA in your file system: ")
elif option == "l":
if os.environ.get('IS_DOCKER_CONTAINER', False):
print(
"[*] Running in Docker container, please place an IPA in the ipas folder, then put the name of the file below.")
ipa_name = input(
' IPA name (ex. Taurine.ipa, DemoApp.ipa): ')
path = f"/usr/src/permasigner/ipas/{ipa_name}"
else:
path = input(
"[?] Paste in the path to an IPA in your file system: ")

path = path.strip().lstrip("'").rstrip("'")

if Path(path).exists():
Expand Down Expand Up @@ -497,15 +505,19 @@ def main(args):
if p.returncode == 0 or 'password' in p.stderr.decode():
print("User is in sudoers, using sudo command")
if args.debug:
print(f"[DEBUG] Running command: sudo dpkg -i {path_to_deb}")
print(
f"[DEBUG] Running command: sudo dpkg -i {path_to_deb}")

subprocess.run(["sudo", "dpkg", "-i", f"{path_to_deb}"], stdout=PIPE, stderr=PIPE)
subprocess.run(
["sudo", "dpkg", "-i", f"{path_to_deb}"], stdout=PIPE, stderr=PIPE)

subprocess.run(['sudo', 'apt-get', 'install', '-f'], stdout=PIPE, stderr=PIPE)
subprocess.run(
['sudo', 'apt-get', 'install', '-f'], stdout=PIPE, stderr=PIPE)
else:
print("User is not in sudoers, using su instead")
if args.debug:
print(f"[DEBUG] Running command: su root -c 'dpkg -i {path_to_deb}")
print(
f"[DEBUG] Running command: su root -c 'dpkg -i {path_to_deb}")

subprocess.run(
["su", "root", "-c", "'dpkg", "-i", f"{path_to_deb}'"], stdout=PIPE, stderr=PIPE)
Expand Down

0 comments on commit b624d4e

Please sign in to comment.