import os, subprocess, sys USERNAME = os.environ.get('USER') ZEZIDIR = os.getcwd() DOCKERDIR = f'/home/{USERNAME}/docker' def root_check(): if USERNAME == 'root': print('Do NOT run this script as root! Run it as a user with sudo privileges.') sys.exit() def first_run(): print('This script will automatically install Dockhand on your system. Make sure you:') print('1) Have Debian 11+ installed.') print('2) Are running this script as a user with sudo privileges.') uinput = input('Continue? [Y/N]: ') if uinput.lower() != "y": sys.exit() docker_install() def docker_install(): os.system('sudo apt update') os.system('sudo apt install ca-certificates curl -y') os.system('sudo install -m 0755 -d /etc/apt/keyrings') os.system('sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc') os.system('sudo chmod a+r /etc/apt/keyrings/docker.asc') os.system(f'sudo cp {ZEZIDIR}/zezidock/docker/docker.sources /etc/apt/sources.list.d/docker.sources') codename = subprocess.check_output('. /etc/os-release && echo "$VERSION_CODENAME"', shell=True, text=True).strip() arch = subprocess.check_output('dpkg --print-architecture', shell=True, text=True).strip() os.system(f"sudo sed -i 's/\\[CODENAME\\]/{codename}/g' /etc/apt/sources.list.d/docker.sources") os.system(f"sudo sed -i 's/\\[ARCH\\]/{arch}/g' /etc/apt/sources.list.d/docker.sources") os.system('sudo apt update') os.system('sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y') os.system(f'mkdir {DOCKERDIR}') def service_install(service): os.system(f'cp -r {ZEZIDIR}/zezidock/{service} {DOCKERDIR}') os.system(f"sudo sed -i \"s|\\[DOCKERDIR\\]|{DOCKERDIR}|g\" {DOCKERDIR}/{service}/docker-compose.yml") if service == 'caddy': http = input(f"[{service.upper()}] Choose port for HTTP: ") https = input(f"[{service.upper()}] Choose port for HTTPS: ") os.system(f"sudo sed -i \"s|\\[HTTP\\]|{http}|g\" {DOCKERDIR}/{service}/docker-compose.yml") os.system(f"sudo sed -i \"s|\\[HTTPS\\]|{https}|g\" {DOCKERDIR}/{service}/docker-compose.yml") if service == 'dockhand' or service == 'gitea' or service == 'nextcloud': webui = input(f'[{service.upper()}] Choose port for Web UI: ') os.system(f"sudo sed -i \"s|\\[WEBUI\\]|{webui}|g\" {DOCKERDIR}/{service}/docker-compose.yml") os.chdir(f'{DOCKERDIR}/{service}') os.system('sudo docker compose up -d') os.chdir(f'{ZEZIDIR}') print(f'Success! {service} is running!') def main(): root_check() if not os.path.exists(DOCKERDIR): first_run() uinput = input("Docker installed! Do you want to install some containers? [Y/N]: ") if uinput.lower() == "y": print("Caddy is an open-source web server that automatically manages HTTPS with Let's Encrypt and makes it easy to configure sites using simple, human-friendly syntax.") uinput = input("Do you want to install Caddy? [Y/N]: ") if uinput.lower() == "y": service_install('caddy') print("Dockhand is a self-hosted Docker management web app that lets you control containers and Compose stacks across local and remote hosts with features like real-time logs, terminal access, and automation.") uinput = input("Do you want to install Dockhand? [Y/N]: ") if uinput.lower() == "y": service_install('dockhand') print("Gitea is an open-source self-hosted Git service for hosting repositories, managing issues and pull requests, and providing web-based collaboration.") uinput = input("Do you want to install Gitea? [Y/N]: ") if uinput.lower() == "y": service_install('gitea') print("Nextcloud is an open-source self-hosted platform for syncing and sharing files with collaboration tools like calendars, contacts, and document editing.") uinput = input("Do you want to install Nextcloud? [Y/N]: ") if uinput.lower() == "y": service_install('nextcloud') else: sys.exit() main()