aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xtool/aio.py19
-rw-r--r--tool/modules/path.py7
3 files changed, 25 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 4f5cc0e..8576079 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ crupest-api-config.json
data
nginx-config
log
+tmp
__pycache__
diff --git a/tool/aio.py b/tool/aio.py
index 5498141..d39a839 100755
--- a/tool/aio.py
+++ b/tool/aio.py
@@ -5,9 +5,10 @@ import os.path
import sys
import argparse
import shutil
+import subprocess
import urllib.request
from rich.console import Console
-from rich.prompt import Prompt, Confirm
+from rich.prompt import Confirm
from modules.path import *
from modules.template import Template
from modules.nginx import *
@@ -58,11 +59,14 @@ certbot_command_group.add_argument(
certbot_parser.add_argument(
"-t", "--test", action="store_true", default=False, help="Make the commands for test use.")
-clear_parser = subparsers .add_parser(
+clear_parser = subparsers.add_parser(
"clear", help="Delete existing data so you can make a fresh start.")
clear_parser.add_argument("-D", "--include-data-dir", action="store_true",
default=False, help="Also delete the data directory.")
+install_docker_parser = subparsers.add_parser(
+ "install-docker", help="Install docker and docker-compose.")
+
args = parser.parse_args()
if args.action == "certbot":
@@ -72,6 +76,17 @@ if args.action == "certbot":
if not args.no_hello:
console.print("Nice to see you! :waving_hand:", style="cyan")
+if args.action == "install-docker":
+ ensure_tmp_dir()
+ get_docker_path = os.path.join(tmp_dir, "get-docker.sh")
+ urllib.request.urlretrieve("https://get.docker.com", get_docker_path)
+ os.chmod(get_docker_path, 0o755)
+ subprocess.run(["sudo", "sh", get_docker_path], check=True)
+ subprocess.run(["sudo", "usermod", "-aG", "docker",
+ os.getlogin()], check=True)
+ exit(0)
+
+
if args.action == 'print-path':
console.print("Project path =", project_dir)
console.print("Project absolute path =", project_abs_path)
diff --git a/tool/modules/path.py b/tool/modules/path.py
index c4cf35b..31298ed 100644
--- a/tool/modules/path.py
+++ b/tool/modules/path.py
@@ -8,10 +8,17 @@ template_dir = os.path.join(project_dir, "template")
nginx_template_dir = os.path.join(template_dir, "nginx")
data_dir = os.path.join(project_dir, "data")
tool_dir = os.path.join(project_dir, "tool")
+tmp_dir = os.path.join(project_dir, "tmp")
config_file_path = os.path.join(data_dir, "config")
nginx_config_dir = os.path.join(project_dir, "nginx-config")
log_dir = os.path.join(project_dir, "log")
+
def ensure_log_dir():
if not os.path.exists(log_dir):
os.mkdir(log_dir)
+
+
+def ensure_tmp_dir():
+ if not os.path.exists(tmp_dir):
+ os.mkdir(tmp_dir)