Browse Source

Added ee stack install --wpcli and more similar commands :)

bugfixes
gau1991 10 years ago
parent
commit
4534d4ef18
  1. 79
      ee/cli/plugins/stack.py
  2. 2
      ee/core/download.py

79
ee/cli/plugins/stack.py

@ -36,6 +36,8 @@ class EEStackController(CementBaseController):
dict(help='Install MySQL stack', action='store_true')), dict(help='Install MySQL stack', action='store_true')),
(['--postfix'], (['--postfix'],
dict(help='Install Postfix stack', action='store_true')), dict(help='Install Postfix stack', action='store_true')),
(['--wpcli'],
dict(help='Install WPCLI stack', action='store_true')),
] ]
@expose(hide=True) @expose(hide=True)
@ -44,14 +46,14 @@ class EEStackController(CementBaseController):
print("Inside EEStackController.default().") print("Inside EEStackController.default().")
@expose(hide=True) @expose(hide=True)
def pre_pref(self, apt-packages): def pre_pref(self, apt_packages):
if "postfix" in apt-packages: if "postfix" in apt_packages:
EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type "
"string 'Internet Site'\" | " "string 'Internet Site'\" | "
"debconf-set-selections") "debconf-set-selections")
EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " EEShellExec.cmd_exec("echo \"postfix postfix/mailname string "
"$(hostname -f)\" | debconf-set-selections") "$(hostname -f)\" | debconf-set-selections")
if "mysql" in apt-packages: if "mysql" in apt_packages:
chars = ''.join(random.sample(string.letters, 8)) chars = ''.join(random.sample(string.letters, 8))
EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " EEShellExec.cmd_exec("echo \"percona-server-server-5.6 "
"percona-server-server/root_password " "percona-server-server/root_password "
@ -62,85 +64,92 @@ class EEStackController(CementBaseController):
"password {chars}\" | " "password {chars}\" | "
"debconf-set-selections".format(chars=chars)) "debconf-set-selections".format(chars=chars))
@expose(hide=True)
def post_pref(self, packages):
pass
@expose() @expose()
def install(self): def install(self):
pkg = EEAptGet() pkg = EEAptGet()
apt-packages = [] apt_packages = []
packages = []
if self.app.pargs.web: if self.app.pargs.web:
apt-packages = (apt-packages + EEVariables.ee_nginx + apt_packages = (apt_packages + EEVariables.ee_nginx +
EEVariables.ee_php + EEVariables.ee_mysql) EEVariables.ee_php + EEVariables.ee_mysql)
if self.app.pargs.admin: if self.app.pargs.admin:
pass pass
#apt-packages = apt-packages + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.mail: if self.app.pargs.mail:
pass pass
#apt-packages = apt-packages + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.nginx: if self.app.pargs.nginx:
apt-packages = apt-packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.php: if self.app.pargs.php:
apt-packages = apt-packages + EEVariables.ee_php apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.mysql: if self.app.pargs.mysql:
apt-packages = apt-packages + EEVariables.ee_mysql apt_packages = apt_packages + EEVariables.ee_mysql
if self.app.pargs.postfix: if self.app.pargs.postfix:
apt-packages = apt-packages + EEVariables.ee_postfix apt_packages = apt_packages + EEVariables.ee_postfix
if self.app.pargs.wpcli: if self.app.pargs.wpcli:
packages = packages + [['url', 'path']] packages = packages + [["https://github.com/wp-cli/wp-cli/releases"
"/download/v0.17.1/wp-cli.phar",
"/usr/bin/wp"]]
self.pre_pref(apt-packages) self.pre_pref(apt_packages)
if len(apt-packages) not 0: if len(apt_packages):
pkg.install(apt-packages) pkg.install(apt_packages)
if len(packages) not 0: if len(packages):
EEDownload.download(packages) EEDownload.download(packages)
self.post_pref(apt-packages, packages) self.post_pref(apt_packages, packages)
@expose() @expose()
def remove(self): def remove(self):
pkg = EEAptGet() pkg = EEAptGet()
apt-packages = [] apt_packages = []
if self.app.pargs.web: if self.app.pargs.web:
apt-packages = (apt-packages + EEVariables.ee_nginx + apt_packages = (apt_packages + EEVariables.ee_nginx +
EEVariables.ee_php + EEVariables.ee_mysql) EEVariables.ee_php + EEVariables.ee_mysql)
if self.app.pargs.admin: if self.app.pargs.admin:
pass pass
#apt-packages = apt-packages + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.mail: if self.app.pargs.mail:
pass pass
#apt-packages = apt-packages + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.nginx: if self.app.pargs.nginx:
apt-packages = apt-packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.php: if self.app.pargs.php:
apt-packages = apt-packages + EEVariables.ee_php apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.mysql: if self.app.pargs.mysql:
apt-packages = apt-packages + EEVariables.ee_mysql apt_packages = apt_packages + EEVariables.ee_mysql
if self.app.pargs.postfix: if self.app.pargs.postfix:
apt-packages = apt-packages + EEVariables.ee_postfix apt_packages = apt_packages + EEVariables.ee_postfix
if self.app.pargs.wpcli: if self.app.pargs.wpcli:
pass pass
pkg.remove(apt-packages) pkg.remove(apt_packages)
@expose() @expose()
def purge(self): def purge(self):
pkg = EEAptGet() pkg = EEAptGet()
apt-packages = [] apt_packages = []
if self.app.pargs.web: if self.app.pargs.web:
apt-packages = (apt-packages + EEVariables.ee_nginx apt_packages = (apt_packages + EEVariables.ee_nginx
+ EEVariables.ee_php + EEVariables.ee_mysql) + EEVariables.ee_php + EEVariables.ee_mysql)
if self.app.pargs.admin: if self.app.pargs.admin:
pass pass
#apt-packages = apt-packages + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.mail: if self.app.pargs.mail:
pass pass
#apt-packages = apt-packages + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.nginx: if self.app.pargs.nginx:
apt-packages = apt-packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.php: if self.app.pargs.php:
apt-packages = apt-packages + EEVariables.ee_php apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.mysql: if self.app.pargs.mysql:
apt-packages = apt-packages + EEVariables.ee_mysql apt_packages = apt_packages + EEVariables.ee_mysql
if self.app.pargs.postfix: if self.app.pargs.postfix:
apt-packages = apt-packages + EEVariables.ee_postfix apt_packages = apt_packages + EEVariables.ee_postfix
pkg.purge(apt-packages) pkg.purge(apt_packages)
def load(app): def load(app):

2
ee/core/download.py

@ -28,6 +28,6 @@ class EEDownload():
.format(err=str(e.reason))) .format(err=str(e.reason)))
return False return False
except urllib.error.ContentTooShortError as e: except urllib.error.ContentTooShortError as e:
print("Package download failed. The amount of the print("Package download failed. The amount of the"
"downloaded data is less than the expected amount") "downloaded data is less than the expected amount")
return False return False

Loading…
Cancel
Save