From da53015dad3b846044a45c6588f9acca1d66996e Mon Sep 17 00:00:00 2001 From: gauthiier Date: Wed, 28 Nov 2018 08:18:39 +0100 Subject: [PATCH] vhost --- vhost-apache2/vhost.py | 35 +++++++++++++++++++++++++++++++++++ vhost-apache2/vhost_tmpl | 1 - 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 vhost-apache2/vhost.py diff --git a/vhost-apache2/vhost.py b/vhost-apache2/vhost.py new file mode 100755 index 0000000..cab5cae --- /dev/null +++ b/vhost-apache2/vhost.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import sys, os, platform, subprocess, logging, argparse + +platform_support = ['Linux'] + +def sys_check(): + + # check platform + if platform.system() not in platform_support: + sys.exit("Platform " + platform.system() + " not supported. Aborting...") + + # check apache2 + r = subprocess.call("apache2 -v", shell=True) == 0 + + # check apache2 (ubuntu-style) + u = os.path.exists('/etc/apache2/sites-available/') + + if not r and u: + sys.exit("Apache2 (ubuntu-style) not installed on your system. Aborting...") + + +if __name__ == "__main__": + + p = argparse.ArgumentParser(description='vhost helper') + p.add_argument('domain', metavar="domain", help="vhost domain(s)", nargs="+") + g = p.add_mutually_exclusive_group() + g.add_argument('-a', '--add', action='store_true', help="adds vhost for given domain(s)") + g.add_argument('-r', '--remove', action='store_true', help="removes vhost for given domain(s)") + + args = p.parse_args() + + print(args) + + sys_check() diff --git a/vhost-apache2/vhost_tmpl b/vhost-apache2/vhost_tmpl index 01562c3..b7f5a49 100644 --- a/vhost-apache2/vhost_tmpl +++ b/vhost-apache2/vhost_tmpl @@ -12,7 +12,6 @@ ErrorLog /home/%user?/logs/%domain?/error.log CustomLog /home/%user?/logs/%domain?/access.log combined -