Files
ZeziDock/zezidock.py
T
2026-09-12 08:13:36 +00:00

83 lines
3.6 KiB
Python

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 Docker 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}')
print("Docker installed!")
print("")
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")
else:
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!')
print("")
def main():
root_check()
if not os.path.exists(DOCKERDIR):
first_run()
uinput = input("Do you want to install some containers? [Y/N]: ")
if uinput.lower() == "y":
services = {
'caddy': "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.",
'dockhand': "Dockhand is a self-hosted web app to manage local and remote Docker containers and stacks, featuring real-time logs, terminal access, and automation.",
'gitea': "Gitea is an open-source self-hosted Git service for hosting repositories, managing issues and pull requests, and providing web-based collaboration.",
'nextcloud': "Nextcloud is an open-source self-hosted platform for syncing and sharing files with collaboration tools like calendars, contacts, and document editing.",
'ytzero': "YT Zero - own rules, own algorithm, no login required. Every video from every channel you follow, and nothing else."
}
for service, description in services.items():
print(description)
uinput = input(f"Do you want to install {service}? [Y/N]: ")
if uinput.lower() == "y":
service_install(service)
else:
sys.exit()
main()