From 51e093dab10fb6c4be54f82f4a0bf37a2a39178d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Dec 2014 14:42:05 +0530 Subject: [PATCH] nginx repo add code --- ee/cli/plugins/stack.py | 9 +++++++++ ee/core/apt_repo.py | 13 ++++++++----- ee/core/variables.py | 13 ++++++++----- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 79ec3aca..c8a1a9f8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -51,15 +51,18 @@ class EEStackController(CementBaseController): @expose(hide=True) def pre_pref(self, apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): + print("Pre-seeding postfix variables ... ") EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " "string 'Internet Site'\" | " "debconf-set-selections") EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): + print("Adding repository for mysql ... ") EERepo.add(ppa=EEVariables.ee_mysql_repo) EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) + print("Pre-seeding mysql variables ... ") EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " @@ -68,6 +71,12 @@ class EEStackController(CementBaseController): "percona-server-server/root_password_again " "password {chars}\" | " "debconf-set-selections".format(chars=chars)) + if set(EEVariables.ee_nginx).issubset(set(apt_packages)): + print("Adding repository for nginx ... ") + if EEVariables.ee_platform_codename == 'squeeze': + EERepo.add(repo_url=EEVariables.ee_mysql_repo) + else: + EERepo.add(repo_url=EEVariables.ee_mysql_repo) @expose(hide=True) def post_pref(self, apt_packages, packages): diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 70b1ef49..66857782 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -40,11 +40,14 @@ class EERepo(): "--remove '{ppa_name}'".format(ppa_name=repo_url)) pass - def add_key(keyserver, keyids): - EEShellExec.cmd_exec("gpg --keyserver {serv}".format(serv=keyserver) - + " --recv-keys {key}".format(key=keyids)) - EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) - + " | apt-key add - ") + def add_key(keyserver=None, keyids): + if keyserver is None: + EEShellExec.cmd_exec("gpg --keyserver {serv}" + .format(serv=(keyserver + or "hkp://keys.gnupg.net")) + + " --recv-keys {key}".format(key=keyids)) + EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) + + " | apt-key add - ") # if __name__ == '__main__': # EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") diff --git a/ee/core/variables.py b/ee/core/variables.py index 358a3dc1..86ef0bd4 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -6,10 +6,17 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine core variables + ee_platform_distro = platform.linux_distribution()[0] + ee_platform_version = platform.linux_distribution()[1] + ee_platform_codename = platform.linux_distribution()[2] # EasyEngine stack installation varibales # Nginx repo and packages - ee_nginx_repo = "ppa:rtcamp/nginx" + if ee_platform_distro == 'Ubuntu': + ee_nginx_repo = "ppa:rtcamp/nginx" + elif ee_platform_distro == 'Debian': + ee_nginx_repo = ("deb http://packages.dotdeb.org {codename} all" + .format(codename=ee_platform_codename)) ee_nginx = ["nginx-custom"] # PHP repo and packages @@ -25,10 +32,6 @@ class EEVariables(): ee_postfix_repo = "" ee_postfix = ["postfix"] - ee_platform_distro = platform.linux_distribution()[0] - ee_platform_version = platform.linux_distribution()[1] - ee_platform_codename = platform.linux_distribution()[2] - # Repo ee_repo_file = "ee-repo.list" ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file)