first commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import subprocess
|
||||
|
||||
all = subprocess.check_output(["sudo", "docker", "ps", "-a", "--format", "{{.Names}}"], text=True).strip()
|
||||
on = subprocess.check_output(["sudo", "docker", "ps", "--format", "{{.Names}}"], text=True).strip()
|
||||
namesall = all.splitlines() if all else []
|
||||
nameson = on.splitlines() if on else []
|
||||
print(namesall)
|
||||
print(nameson)
|
||||
+24
-15
@@ -11,9 +11,8 @@ def root_check():
|
||||
|
||||
def first_run():
|
||||
print('This script will automatically install Dockhand on your system. Make sure you:')
|
||||
print('1) Have Debian 11+ installed')
|
||||
print('1) Have Debian 11+ installed.')
|
||||
print('2) Are running this script as a user with sudo privileges.')
|
||||
print('')
|
||||
uinput = input('Continue? [Y/N]: ')
|
||||
if uinput.lower() != "y":
|
||||
sys.exit()
|
||||
@@ -48,7 +47,6 @@ def service_install(service):
|
||||
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}')
|
||||
@@ -60,21 +58,32 @@ def main():
|
||||
if not os.path.exists(DOCKERDIR):
|
||||
first_run()
|
||||
|
||||
if not os.path.exists(f'{DOCKERDIR}/dockhand/docker-compose.yml'):
|
||||
service_install('dockhand')
|
||||
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')
|
||||
|
||||
if not os.path.exists(f'{DOCKERDIR}/caddy/docker-compose.yml'):
|
||||
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')
|
||||
|
||||
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')
|
||||
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')
|
||||
|
||||
service_run('dockhand')
|
||||
service_run('caddy')
|
||||
service_run('gitea')
|
||||
service_run('nextcloud')
|
||||
|
||||
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()
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user