aboutsummaryrefslogtreecommitdiff
path: root/tool/download.py
blob: a77daa1da035da7fd724dc6b29f1a73cd8ec040d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3

import os.path

SCRIPTS = [("docker-mailserver setup script", "docker-mailserver-setup.sh",
            "https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master/setup.sh")]

this_script_dir = os.path.dirname(os.path.relpath(__file__))

for script in SCRIPTS:
    name, filename, url = script
    path = os.path.join(this_script_dir, filename)
    skip = False
    if os.path.exists(path):
        print(f"{name} already exists, download and overwrite? (y/N)", end=" ")
        if input() != "y":
            skip = True
    else:
        print(f"Download {name} to {path}? (Y/n)", end=" ")
        if input() == "n":
            skip = True
    if not skip:
        print(f"Downloading {name}...")
        os.system(f"curl -s {url} > {path} && chmod +x {path}")
        print(f"Downloaded {name} to {path}.")
    else:
        print(f"Skipped {name}.")