Added checks on install

This commit is contained in:
Spitfireap
2024-04-12 16:12:36 +02:00
parent ef1d7670dd
commit 64ba5eb543
3 changed files with 47 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
name: Update version file
on: push
on:
push:
branches: [ master ]
jobs:
update-version:

33
checks.py Normal file
View File

@@ -0,0 +1,33 @@
"""Checks to be performed before any install or upgrade"""
import sys
from urllib.request import urlopen
from modoboa_installer import utils
def check_version():
local_version = ""
with open("version.txt", "r") as version:
local_version = version.readline()
remote_version = ""
with urlopen("https://raw.githubusercontent.com/modoboa/modoboa-installer/master/version.txt") as r_version:
remote_version = r_version.read().decode()
if local_version == "" or remote_version == "":
utils.printcolor("Could not check that your installer is up to date: "
f"local version: {local_version}, "
f"remote version: {remote_version}",
utils.YELLOW)
if remote_version != local_version:
utils.error("Your installer seems outdated.\n"
"Check the README for instruction on how to update.\n"
"No support will be provided without an up to date installer!")
answer = utils.user_input("Continue anyway? (Y/n) ")
if not answer.lower().startswith("y"):
sys.exit(0)
else:
utils.success("Installer seems up to date!")
def handle():
check_version()

12
run.py
View File

@@ -11,6 +11,7 @@ except ImportError:
import ConfigParser as configparser
import sys
import checks
from modoboa_installer import compatibility_matrix
from modoboa_installer import constants
from modoboa_installer import package
@@ -168,7 +169,10 @@ def main(input_args):
"--restore", type=str, metavar="path",
help="Restore a previously backup up modoboa instance on a NEW machine. "
"You MUST provide backup directory"
)
),
parser.add_argument(
"--skip-checks"; action="store_true", default=False,
help="Skip the checks the installer performs initially")
parser.add_argument("domain", type=str,
help="The main domain of your future mail server")
args = parser.parse_args(input_args)
@@ -189,6 +193,12 @@ def main(input_args):
utils.success("Welcome to Modoboa installer!\n")
# Checks
if not args.skip_checks:
utils.printcolor("Checking the installer...", utils.BLUE)
checks.handle()
utils.success("Checks complete")
is_config_file_available, outdate_config = utils.check_config_file(
args.configfile, args.interactive, args.upgrade, args.backup, is_restoring)