first commit

This commit is contained in:
2026-07-09 22:32:33 +02:00
parent 1ad7504bbe
commit 4ff8c6c627
3 changed files with 111 additions and 15 deletions
+79
View File
@@ -0,0 +1,79 @@
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")
def service_run(service):
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()
if not os.path.exists(f'{DOCKERDIR}/dockhand/docker-compose.yml'):
service_install('dockhand')
if not os.path.exists(f'{DOCKERDIR}/caddy/docker-compose.yml'):
service_install('caddy')
if not os.path.exists(f'{DOCKERDIR}/gitea/docker-compose.yml'):
service_install('gitea')
if not os.path.exists(f'{DOCKERDIR}/nextcloud/docker-compose.yml'):
service_install('nextcloud')
service_run('dockhand')
service_run('caddy')
service_run('gitea')
service_run('nextcloud')
main()