diff options
| author | crupest <crupest@outlook.com> | 2022-11-27 10:33:11 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-11-27 10:33:11 +0800 | 
| commit | ac1c8a2265e5eed2598a913a1580cfbb6cba56e5 (patch) | |
| tree | 41132de796999eaa6b8117c33a2d4840e5464810 | |
| parent | f89940d64166a3c9b227436a29d739ec86023e5d (diff) | |
| download | crupest-ac1c8a2265e5eed2598a913a1580cfbb6cba56e5.tar.gz crupest-ac1c8a2265e5eed2598a913a1580cfbb6cba56e5.tar.bz2 crupest-ac1c8a2265e5eed2598a913a1580cfbb6cba56e5.zip  | |
Do some check on system.
| -rwxr-xr-x | tool/aio.py | 37 | 
1 files changed, 32 insertions, 5 deletions
diff --git a/tool/aio.py b/tool/aio.py index 86141c4..4327e95 100755 --- a/tool/aio.py +++ b/tool/aio.py @@ -15,6 +15,7 @@ import argparse  import shutil  import subprocess  import urllib.request +import re  from rich.console import Console  from rich.prompt import Confirm  from modules.path import * @@ -25,15 +26,14 @@ from modules.config import *  console = Console() - -def print_order(number: int, total: int, *, console=console) -> None: -    console.print(f"\[{number}/{total}]", end=" ", style="green") - -  parser = argparse.ArgumentParser(      description="Crupest server all-in-one setup script. Have fun play with it!")  parser.add_argument("--no-hello", action="store_true",                      default=False, help="Do not print hello message.") +parser.add_argument("--no-check-python-version", action="store_true", +                    default=False, help="Do not check python version.") +parser.add_argument("--no-check-system", action="store_true", +                    default=False, help="Do not check system type.")  subparsers = parser.add_subparsers(dest="action") @@ -87,6 +87,33 @@ backup_command_group.add_argument(  args = parser.parse_args() +if not args.no_check_python_version: +    if sys.version_info < (3, 10): +        console.print("This script works well on python 3.10 or higher. Otherwise you may encounter some problems. But I would like to improve some rational compatibility.", style="yellow") + + +def check_ubuntu(): +    if not os.path.exists("/etc/os-release"): +        return False +    else: +        with open("/etc/os-release", "r") as f: +            content = f.read() +            if re.match(r"NAME=\"?Ubuntu\"?", content, re.IGNORECASE) is None: +                return False +            if re.match(r"UBUNTU_CODENAME=\"?jammy\"?", re.IGNORECASE) is None: +                return False +    return True + + +if not args.no_check_system: +    if not check_ubuntu(): +        console.print("This script works well on Ubuntu 22.04. Otherwise you may encounter some problems. But I would like to improve some rational compatibility.", style="yellow") + + +def print_order(number: int, total: int, *, console=console) -> None: +    console.print(f"\[{number}/{total}]", end=" ", style="green") + +  if args.action == "certbot":      if args.create or args.renew or args.expand:          args.no_hello = True  | 
