Skip to content

Commit

Permalink
config script: set up bdsh packages
Browse files Browse the repository at this point in the history
  • Loading branch information
logandhillon committed Jul 12, 2024
1 parent 59eb01a commit 2ba0df4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
54 changes: 54 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import json
import os
from paramiko import RSAKey
import requests
import sys


def prompt(prompt: str, on_cancel: callable, **default: str):
Expand Down Expand Up @@ -74,6 +76,58 @@ def exitloop():

print(f"Created {len(users)} user(s)")

print_header("INSTALL BPM")

BPL_URI = "https://raw.githubusercontent.com/badtechnologies/bdsh/main/bpl"

install_packages = True
while install_packages:
res = requests.get(f'{BPL_URI}/bpm/bpl.json')

if not res.ok:
print(f"""Something went wrong while fetching bpm from bpl, more information below:
\tError:\t\tHTTP {res.status_code} {res.reason}
\tLibrary:\t{BPL_URI}
\tResponse:\t{res.content.decode()}""")

prompt("Try again?", lambda: globals().update(
install_packages=False))
else:
break

if install_packages:
meta = res.json()
print(f"Installing bpm-{meta['version']} ({meta['name']})")
res = requests.get(f'{BPL_URI}/bpm/{meta['bin']}')

while install_packages:
if not res.ok:
print(f"""Something went wrong while downloading bpm binaries, more information below:
\tError:\t\tHTTP {res.status_code} {res.reason}
\tLibrary:\t{BPL_URI}
\tResponse:\t{res.content.decode()}
\tRequested Bin:\t{meta['bin']}
\tMetadata:\t{meta}""")

prompt("Try again?", lambda: globals().update(install_packages=False))
else:
break

virtsh = bdsh.Shell(sys.stdout, sys.stdin)

if install_packages:
with open(virtsh.get_path('exec', 'bpm'), 'wb') as f:
f.write(res.content)

print(f"Installation complete: bpm is installed")

print_header("INSTALL PACKAGES")

virtsh.run_line("bpm install -y core")

else:
print("[!] bpm could not be installed, no packages installed.")

print_header("SETUP BADBANDSSH")

key = RSAKey.generate(bits=2048)
Expand Down
8 changes: 3 additions & 5 deletions docs/file-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ This document provides an overview of the file and folder structure of bdsh (Bad
## Root Directory

- **bdsh/**: main directory
- **core/**: pre-installed system scripts and binaries
- **cfg/**: configuration files
- **prf/**: profile-specific home directories
- **exec/**: non-system scripts and binaries
- **exec/**: scripts and binaries

## Profile-specific files

Expand All @@ -22,6 +21,5 @@ Profile-specific home directories contain certain local profile files, such as:
bdsh runs binaries in this order:

1. bdsh scripts: e.g. echo, exit
2. core/
3. exec/
4. prf/[username]/exec/
2. exec/
3. prf/[username]/exec/

0 comments on commit 2ba0df4

Please sign in to comment.