Reduce WO size
This commit is contained in:
@@ -37,22 +37,23 @@ class WOCleanController(CementBaseController):
|
||||
|
||||
@expose(hide=True)
|
||||
def default(self):
|
||||
if (not (self.app.pargs.all or self.app.pargs.fastcgi or
|
||||
self.app.pargs.memcached or self.app.pargs.opcache or
|
||||
self.app.pargs.redis)):
|
||||
pargs = self.app.pargs
|
||||
if (not (pargs.all or pargs.fastcgi or
|
||||
pargs.memcached or pargs.opcache or
|
||||
pargs.redis)):
|
||||
self.clean_fastcgi()
|
||||
if self.app.pargs.all:
|
||||
if pargs.all:
|
||||
self.clean_memcached()
|
||||
self.clean_fastcgi()
|
||||
self.clean_opcache()
|
||||
self.clean_redis()
|
||||
if self.app.pargs.fastcgi:
|
||||
if pargs.fastcgi:
|
||||
self.clean_fastcgi()
|
||||
if self.app.pargs.memcached:
|
||||
if pargs.memcached:
|
||||
self.clean_memcached()
|
||||
if self.app.pargs.opcache:
|
||||
if pargs.opcache:
|
||||
self.clean_opcache()
|
||||
if self.app.pargs.redis:
|
||||
if pargs.redis:
|
||||
self.clean_redis()
|
||||
|
||||
@expose(hide=True)
|
||||
|
||||
@@ -35,31 +35,33 @@ class WOSecureController(CementBaseController):
|
||||
|
||||
@expose(hide=True)
|
||||
def default(self):
|
||||
if self.app.pargs.auth:
|
||||
pargs = self.app.pargs
|
||||
if pargs.auth:
|
||||
self.secure_auth()
|
||||
if self.app.pargs.port:
|
||||
if pargs.port:
|
||||
self.secure_port()
|
||||
if self.app.pargs.ip:
|
||||
if pargs.ip:
|
||||
self.secure_ip()
|
||||
|
||||
@expose(hide=True)
|
||||
def secure_auth(self):
|
||||
"""This function secures authentication"""
|
||||
pargs = self.app.pargs
|
||||
passwd = ''.join([random.choice
|
||||
(string.ascii_letters + string.digits)
|
||||
for n in range(24)])
|
||||
if not self.app.pargs.user_input:
|
||||
if not pargs.user_input:
|
||||
username = input("Provide HTTP authentication user "
|
||||
"name [{0}] :".format(WOVariables.wo_user))
|
||||
self.app.pargs.user_input = username
|
||||
pargs.user_input = username
|
||||
if username == "":
|
||||
self.app.pargs.user_input = WOVariables.wo_user
|
||||
if not self.app.pargs.user_pass:
|
||||
pargs.user_input = WOVariables.wo_user
|
||||
if not pargs.user_pass:
|
||||
password = getpass.getpass("Provide HTTP authentication "
|
||||
"password [{0}] :".format(passwd))
|
||||
self.app.pargs.user_pass = password
|
||||
pargs.user_pass = password
|
||||
if password == "":
|
||||
self.app.pargs.user_pass = passwd
|
||||
pargs.user_pass = passwd
|
||||
Log.debug(self, "printf username:"
|
||||
"$(openssl passwd -crypt "
|
||||
"password 2> /dev/null)\n\""
|
||||
@@ -68,8 +70,8 @@ class WOSecureController(CementBaseController):
|
||||
"$(openssl passwd -crypt "
|
||||
"{password} 2> /dev/null)\n\""
|
||||
"> /etc/nginx/htpasswd-wo 2>/dev/null"
|
||||
.format(username=self.app.pargs.user_input,
|
||||
password=self.app.pargs.user_pass),
|
||||
.format(username=pargs.user_input,
|
||||
password=pargs.user_pass),
|
||||
log=False)
|
||||
WOGit.add(self, ["/etc/nginx"],
|
||||
msg="Adding changed secure auth into Git")
|
||||
@@ -77,41 +79,42 @@ class WOSecureController(CementBaseController):
|
||||
@expose(hide=True)
|
||||
def secure_port(self):
|
||||
"""This function Secures port"""
|
||||
if self.app.pargs.user_input:
|
||||
while not self.app.pargs.user_input.isdigit():
|
||||
pargs = self.app.pargs
|
||||
if pargs.user_input:
|
||||
while not pargs.user_input.isdigit():
|
||||
Log.info(self, "Please enter a valid port number ")
|
||||
self.app.pargs.user_input = input("WordOps "
|
||||
pargs.user_input = input("WordOps "
|
||||
"admin port [22222]:")
|
||||
if not self.app.pargs.user_input:
|
||||
if not pargs.user_input:
|
||||
port = input("WordOps admin port [22222]:")
|
||||
if port == "":
|
||||
self.app.pargs.user_input = 22222
|
||||
pargs.user_input = 22222
|
||||
while not port.isdigit() and port != "":
|
||||
Log.info(self, "Please Enter valid port number :")
|
||||
port = input("WordOps admin port [22222]:")
|
||||
self.app.pargs.user_input = port
|
||||
pargs.user_input = port
|
||||
WOShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen "
|
||||
"{port} default_server ssl http2;/\" "
|
||||
"/etc/nginx/sites-available/22222"
|
||||
.format(port=self.app.pargs.user_input))
|
||||
.format(port=pargs.user_input))
|
||||
WOGit.add(self, ["/etc/nginx"],
|
||||
msg="Adding changed secure port into Git")
|
||||
if not WOService.reload_service(self, 'nginx'):
|
||||
Log.error(self, "service nginx reload failed. "
|
||||
"check issues with `nginx -t` command")
|
||||
Log.info(self, "Successfully port changed {port}"
|
||||
.format(port=self.app.pargs.user_input))
|
||||
.format(port=pargs.user_input))
|
||||
|
||||
@expose(hide=True)
|
||||
def secure_ip(self):
|
||||
"""IP whitelisting"""
|
||||
newlist = []
|
||||
if not self.app.pargs.user_input:
|
||||
pargs = self.app.pargs
|
||||
if not pargs.user_input:
|
||||
ip = input("Enter the comma separated IP addresses "
|
||||
"to white list [127.0.0.1]:")
|
||||
self.app.pargs.user_input = ip
|
||||
pargs.user_input = ip
|
||||
try:
|
||||
user_ip = self.app.pargs.user_input.split(',')
|
||||
user_ip = pargs.user_input.split(',')
|
||||
except Exception as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
user_ip = ['127.0.0.1']
|
||||
|
||||
@@ -1235,7 +1235,8 @@ def post_pref(self, apt_packages, packages):
|
||||
'/usr/local/bin/composer')
|
||||
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
|
||||
Log.info(self, "Updating phpMyAdmin, please wait...")
|
||||
WOShellExec.cmd_exec(self, "/usr/local/bin/composer update --no-plugins --no-scripts "
|
||||
WOShellExec.cmd_exec(self, "/usr/local/bin/composer update "
|
||||
"--no-plugins --no-scripts "
|
||||
"-n --no-dev -d "
|
||||
"/var/www/22222/htdocs/db/pma/")
|
||||
WOFileUtils.chown(self, '{0}22222/htdocs/db/pma'
|
||||
|
||||
@@ -18,24 +18,25 @@ class WOStackStatusController(CementBaseController):
|
||||
def start(self):
|
||||
"""Start services"""
|
||||
services = []
|
||||
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||
self.app.pargs.php73 or
|
||||
self.app.pargs.mysql or
|
||||
self.app.pargs.redis or
|
||||
self.app.pargs.fail2ban or
|
||||
self.app.pargs.proftpd or
|
||||
self.app.pargs.netdata):
|
||||
self.app.pargs.nginx = True
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
pargs = pargs = self.app.pargs
|
||||
if not (pargs.nginx or pargs.php or
|
||||
pargs.php73 or
|
||||
pargs.mysql or
|
||||
pargs.redis or
|
||||
pargs.fail2ban or
|
||||
pargs.proftpd or
|
||||
pargs.netdata):
|
||||
pargs.nginx = True
|
||||
pargs.php = True
|
||||
pargs.mysql = True
|
||||
|
||||
if self.app.pargs.nginx:
|
||||
if pargs.nginx:
|
||||
if (WOAptGet.is_installed(self, 'nginx-custom')):
|
||||
services = services + ['nginx']
|
||||
else:
|
||||
Log.info(self, "Nginx is not installed")
|
||||
|
||||
if self.app.pargs.php:
|
||||
if pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
services = services + ['php7.2-fpm']
|
||||
else:
|
||||
@@ -45,13 +46,13 @@ class WOStackStatusController(CementBaseController):
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
services = services + ['php7.3-fpm']
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.mysql:
|
||||
if pargs.mysql:
|
||||
if ((WOVariables.wo_mysql_host is "localhost") or
|
||||
(WOVariables.wo_mysql_host is "127.0.0.1")):
|
||||
if (WOAptGet.is_installed(self, 'mysql-server') or
|
||||
@@ -64,27 +65,27 @@ class WOStackStatusController(CementBaseController):
|
||||
Log.warn(self, "Remote MySQL found, "
|
||||
"Unable to check MySQL service status")
|
||||
|
||||
if self.app.pargs.redis:
|
||||
if pargs.redis:
|
||||
if WOAptGet.is_installed(self, 'redis-server'):
|
||||
services = services + ['redis-server']
|
||||
else:
|
||||
Log.info(self, "Redis server is not installed")
|
||||
|
||||
if self.app.pargs.fail2ban:
|
||||
if pargs.fail2ban:
|
||||
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||
services = services + ['fail2ban']
|
||||
else:
|
||||
Log.info(self, "fail2ban is not installed")
|
||||
|
||||
# proftpd
|
||||
if self.app.pargs.proftpd:
|
||||
if pargs.proftpd:
|
||||
if WOAptGet.is_installed(self, 'proftpd-basic'):
|
||||
services = services + ['proftpd']
|
||||
else:
|
||||
Log.info(self, "ProFTPd is not installed")
|
||||
|
||||
# netdata
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
if os.path.isdir("/opt/netdata"):
|
||||
services = services + ['netdata']
|
||||
else:
|
||||
@@ -98,26 +99,27 @@ class WOStackStatusController(CementBaseController):
|
||||
def stop(self):
|
||||
"""Stop services"""
|
||||
services = []
|
||||
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||
self.app.pargs.php73 or
|
||||
self.app.pargs.mysql or
|
||||
self.app.pargs.fail2ban or
|
||||
self.app.pargs.netdata or
|
||||
self.app.pargs.proftpd or
|
||||
self.app.pargs.redis):
|
||||
self.app.pargs.nginx = True
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
pargs = self.app.pargs
|
||||
if not (pargs.nginx or pargs.php or
|
||||
pargs.php73 or
|
||||
pargs.mysql or
|
||||
pargs.fail2ban or
|
||||
pargs.netdata or
|
||||
pargs.proftpd or
|
||||
pargs.redis):
|
||||
pargs.nginx = True
|
||||
pargs.php = True
|
||||
pargs.mysql = True
|
||||
|
||||
# nginx
|
||||
if self.app.pargs.nginx:
|
||||
if pargs.nginx:
|
||||
if (WOAptGet.is_installed(self, 'nginx-custom')):
|
||||
services = services + ['nginx']
|
||||
else:
|
||||
Log.info(self, "Nginx is not installed")
|
||||
|
||||
# php7.2
|
||||
if self.app.pargs.php:
|
||||
if pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
services = services + ['php7.2-fpm']
|
||||
else:
|
||||
@@ -129,14 +131,14 @@ class WOStackStatusController(CementBaseController):
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
# php7.3
|
||||
if self.app.pargs.php73:
|
||||
if pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
services = services + ['php7.3-fpm']
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
# mysql
|
||||
if self.app.pargs.mysql:
|
||||
if pargs.mysql:
|
||||
if ((WOVariables.wo_mysql_host is "localhost") or
|
||||
(WOVariables.wo_mysql_host is "127.0.0.1")):
|
||||
if (WOAptGet.is_installed(self, 'mysql-server') or
|
||||
@@ -150,28 +152,28 @@ class WOStackStatusController(CementBaseController):
|
||||
"Unable to check MySQL service status")
|
||||
|
||||
# redis
|
||||
if self.app.pargs.redis:
|
||||
if pargs.redis:
|
||||
if WOAptGet.is_installed(self, 'redis-server'):
|
||||
services = services + ['redis-server']
|
||||
else:
|
||||
Log.info(self, "Redis server is not installed")
|
||||
|
||||
# fail2ban
|
||||
if self.app.pargs.fail2ban:
|
||||
if pargs.fail2ban:
|
||||
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||
services = services + ['fail2ban']
|
||||
else:
|
||||
Log.info(self, "fail2ban is not installed")
|
||||
|
||||
# proftpd
|
||||
if self.app.pargs.proftpd:
|
||||
if pargs.proftpd:
|
||||
if WOAptGet.is_installed(self, 'proftpd-basic'):
|
||||
services = services + ['proftpd']
|
||||
else:
|
||||
Log.info(self, "ProFTPd is not installed")
|
||||
|
||||
# netdata
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
if os.path.isdir("/opt/netdata"):
|
||||
services = services + ['netdata']
|
||||
else:
|
||||
@@ -185,24 +187,25 @@ class WOStackStatusController(CementBaseController):
|
||||
def restart(self):
|
||||
"""Restart services"""
|
||||
services = []
|
||||
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||
self.app.pargs.php73 or
|
||||
self.app.pargs.mysql or
|
||||
self.app.pargs.netdata or
|
||||
self.app.pargs.proftpd or
|
||||
self.app.pargs.redis or
|
||||
self.app.pargs.fail2ban):
|
||||
self.app.pargs.nginx = True
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
pargs = self.app.pargs
|
||||
if not (pargs.nginx or pargs.php or
|
||||
pargs.php73 or
|
||||
pargs.mysql or
|
||||
pargs.netdata or
|
||||
pargs.proftpd or
|
||||
pargs.redis or
|
||||
pargs.fail2ban):
|
||||
pargs.nginx = True
|
||||
pargs.php = True
|
||||
pargs.mysql = True
|
||||
|
||||
if self.app.pargs.nginx:
|
||||
if pargs.nginx:
|
||||
if (WOAptGet.is_installed(self, 'nginx-custom')):
|
||||
services = services + ['nginx']
|
||||
else:
|
||||
Log.info(self, "Nginx is not installed")
|
||||
|
||||
if self.app.pargs.php:
|
||||
if pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
services = services + ['php7.2-fpm']
|
||||
else:
|
||||
@@ -213,13 +216,13 @@ class WOStackStatusController(CementBaseController):
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
services = services + ['php7.3-fpm']
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.mysql:
|
||||
if pargs.mysql:
|
||||
if ((WOVariables.wo_mysql_host is "localhost") or
|
||||
(WOVariables.wo_mysql_host is "127.0.0.1")):
|
||||
if ((WOAptGet.is_installed(self, 'mysql-server') or
|
||||
@@ -233,27 +236,27 @@ class WOStackStatusController(CementBaseController):
|
||||
Log.warn(self, "Remote MySQL found, "
|
||||
"Unable to check MySQL service status")
|
||||
|
||||
if self.app.pargs.redis:
|
||||
if pargs.redis:
|
||||
if WOAptGet.is_installed(self, 'redis-server'):
|
||||
services = services + ['redis-server']
|
||||
else:
|
||||
Log.info(self, "Redis server is not installed")
|
||||
|
||||
if self.app.pargs.fail2ban:
|
||||
if pargs.fail2ban:
|
||||
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||
services = services + ['fail2ban']
|
||||
else:
|
||||
Log.info(self, "fail2ban is not installed")
|
||||
|
||||
# proftpd
|
||||
if self.app.pargs.proftpd:
|
||||
if pargs.proftpd:
|
||||
if WOAptGet.is_installed(self, 'proftpd-basic'):
|
||||
services = services + ['proftpd']
|
||||
else:
|
||||
Log.info(self, "ProFTPd is not installed")
|
||||
|
||||
# netdata
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
if os.path.isdir("/opt/netdata"):
|
||||
services = services + ['netdata']
|
||||
else:
|
||||
@@ -267,24 +270,25 @@ class WOStackStatusController(CementBaseController):
|
||||
def status(self):
|
||||
"""Status of services"""
|
||||
services = []
|
||||
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||
self.app.pargs.php73 or
|
||||
self.app.pargs.mysql or
|
||||
self.app.pargs.netdata or
|
||||
self.app.pargs.proftpd or
|
||||
self.app.pargs.redis or
|
||||
self.app.pargs.fail2ban):
|
||||
self.app.pargs.nginx = True
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
pargs = self.app.pargs
|
||||
if not (pargs.nginx or pargs.php or
|
||||
pargs.php73 or
|
||||
pargs.mysql or
|
||||
pargs.netdata or
|
||||
pargs.proftpd or
|
||||
pargs.redis or
|
||||
pargs.fail2ban):
|
||||
pargs.nginx = True
|
||||
pargs.php = True
|
||||
pargs.mysql = True
|
||||
|
||||
if self.app.pargs.nginx:
|
||||
if pargs.nginx:
|
||||
if (WOAptGet.is_installed(self, 'nginx-custom')):
|
||||
services = services + ['nginx']
|
||||
else:
|
||||
Log.info(self, "Nginx is not installed")
|
||||
|
||||
if self.app.pargs.php:
|
||||
if pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
services = services + ['php7.2-fpm']
|
||||
else:
|
||||
@@ -295,13 +299,13 @@ class WOStackStatusController(CementBaseController):
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
services = services + ['php7.3-fpm']
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.mysql:
|
||||
if pargs.mysql:
|
||||
if ((WOVariables.wo_mysql_host is "localhost") or
|
||||
(WOVariables.wo_mysql_host is "127.0.0.1")):
|
||||
if (WOAptGet.is_installed(self, 'mysql-server') or
|
||||
@@ -314,27 +318,27 @@ class WOStackStatusController(CementBaseController):
|
||||
Log.warn(self, "Remote MySQL found, "
|
||||
"Unable to check MySQL service status")
|
||||
|
||||
if self.app.pargs.redis:
|
||||
if pargs.redis:
|
||||
if WOAptGet.is_installed(self, 'redis-server'):
|
||||
services = services + ['redis-server']
|
||||
else:
|
||||
Log.info(self, "Redis server is not installed")
|
||||
|
||||
if self.app.pargs.fail2ban:
|
||||
if pargs.fail2ban:
|
||||
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||
services = services + ['fail2ban']
|
||||
else:
|
||||
Log.info(self, "fail2ban is not installed")
|
||||
|
||||
# proftpd
|
||||
if self.app.pargs.proftpd:
|
||||
if pargs.proftpd:
|
||||
if WOAptGet.is_installed(self, 'proftpd-basic'):
|
||||
services = services + ['proftpd']
|
||||
else:
|
||||
Log.info(self, "ProFTPd is not installed")
|
||||
|
||||
# netdata
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
if os.path.isdir("/opt/netdata"):
|
||||
services = services + ['netdata']
|
||||
else:
|
||||
@@ -348,25 +352,26 @@ class WOStackStatusController(CementBaseController):
|
||||
def reload(self):
|
||||
"""Reload service"""
|
||||
services = []
|
||||
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||
self.app.pargs.php73 or
|
||||
self.app.pargs.mysql or
|
||||
self.app.pargs.netdata or
|
||||
self.app.pargs.proftpd or
|
||||
self.app.pargs.redis or
|
||||
self.app.pargs.fail2ban):
|
||||
self.app.pargs.nginx = True
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
pargs = self.app.pargs
|
||||
if not (pargs.nginx or pargs.php or
|
||||
pargs.php73 or
|
||||
pargs.mysql or
|
||||
pargs.netdata or
|
||||
pargs.proftpd or
|
||||
pargs.redis or
|
||||
pargs.fail2ban):
|
||||
pargs.nginx = True
|
||||
pargs.php = True
|
||||
pargs.mysql = True
|
||||
|
||||
if self.app.pargs.nginx:
|
||||
if pargs.nginx:
|
||||
if (WOAptGet.is_installed(self, 'nginx-custom') or
|
||||
WOAptGet.is_installed(self, 'nginx-mainline')):
|
||||
services = services + ['nginx']
|
||||
else:
|
||||
Log.info(self, "Nginx is not installed")
|
||||
|
||||
if self.app.pargs.php:
|
||||
if pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
services = services + ['php7.2-fpm']
|
||||
else:
|
||||
@@ -377,13 +382,13 @@ class WOStackStatusController(CementBaseController):
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
services = services + ['php7.3-fpm']
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM is not installed")
|
||||
|
||||
if self.app.pargs.mysql:
|
||||
if pargs.mysql:
|
||||
if ((WOVariables.wo_mysql_host is "localhost") or
|
||||
(WOVariables.wo_mysql_host is "127.0.0.1")):
|
||||
if (WOAptGet.is_installed(self, 'mysql-server') or
|
||||
@@ -396,27 +401,27 @@ class WOStackStatusController(CementBaseController):
|
||||
Log.warn(self, "Remote MySQL found, "
|
||||
"Unable to check MySQL service status")
|
||||
|
||||
if self.app.pargs.redis:
|
||||
if pargs.redis:
|
||||
if WOAptGet.is_installed(self, 'redis-server'):
|
||||
services = services + ['redis-server']
|
||||
else:
|
||||
Log.info(self, "Redis server is not installed")
|
||||
|
||||
if self.app.pargs.fail2ban:
|
||||
if pargs.fail2ban:
|
||||
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||
services = services + ['fail2ban']
|
||||
else:
|
||||
Log.info(self, "fail2ban is not installed")
|
||||
|
||||
# proftpd
|
||||
if self.app.pargs.proftpd:
|
||||
if pargs.proftpd:
|
||||
if WOAptGet.is_installed(self, 'proftpd-basic'):
|
||||
services = services + ['proftpd']
|
||||
else:
|
||||
Log.info(self, "ProFTPd is not installed")
|
||||
|
||||
# netdata
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
if os.path.isdir("/opt/netdata"):
|
||||
services = services + ['netdata']
|
||||
else:
|
||||
|
||||
@@ -57,35 +57,36 @@ class WOStackUpgradeController(CementBaseController):
|
||||
apt_packages = []
|
||||
packages = []
|
||||
empty_packages = []
|
||||
pargs = pargs = self.app.pargs
|
||||
|
||||
if ((not self.app.pargs.web) and (not self.app.pargs.nginx) and
|
||||
(not self.app.pargs.php) and (not self.app.pargs.php73) and
|
||||
(not self.app.pargs.mysql) and
|
||||
(not self.app.pargs.all) and (not self.app.pargs.wpcli) and
|
||||
(not self.app.pargs.netdata) and (not self.app.pargs.composer) and
|
||||
(not self.app.pargs.phpmyadmin) and
|
||||
(not self.app.pargs.redis)):
|
||||
self.app.pargs.web = True
|
||||
if ((not pargs.web) and (not pargs.nginx) and
|
||||
(not pargs.php) and (not pargs.php73) and
|
||||
(not pargs.mysql) and
|
||||
(not pargs.all) and (not pargs.wpcli) and
|
||||
(not pargs.netdata) and (not pargs.composer) and
|
||||
(not pargs.phpmyadmin) and
|
||||
(not pargs.redis)):
|
||||
pargs.web = True
|
||||
|
||||
if self.app.pargs.all:
|
||||
self.app.pargs.web = True
|
||||
if pargs.all:
|
||||
pargs.web = True
|
||||
|
||||
if self.app.pargs.web:
|
||||
if pargs.web:
|
||||
if WOAptGet.is_installed(self, 'nginx-custom'):
|
||||
self.app.pargs.nginx = True
|
||||
pargs.nginx = True
|
||||
else:
|
||||
Log.info(self, "Nginx is not already installed")
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
self.app.pargs.wpcli = True
|
||||
pargs.php = True
|
||||
pargs.mysql = True
|
||||
pargs.wpcli = True
|
||||
|
||||
if self.app.pargs.nginx:
|
||||
if pargs.nginx:
|
||||
if WOAptGet.is_installed(self, 'nginx-custom'):
|
||||
apt_packages = apt_packages + WOVariables.wo_nginx
|
||||
else:
|
||||
Log.info(self, "Nginx Stable is not already installed")
|
||||
|
||||
if self.app.pargs.php:
|
||||
if pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
apt_packages = apt_packages + WOVariables.wo_php + \
|
||||
@@ -95,7 +96,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
else:
|
||||
Log.info(self, "PHP 7.2 is not installed")
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
if not WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
apt_packages = apt_packages + WOVariables.wo_php73 + \
|
||||
@@ -105,19 +106,19 @@ class WOStackUpgradeController(CementBaseController):
|
||||
else:
|
||||
Log.info(self, "PHP 7.3 is not installed")
|
||||
|
||||
if self.app.pargs.mysql:
|
||||
if pargs.mysql:
|
||||
if WOAptGet.is_installed(self, 'mariadb-server'):
|
||||
apt_packages = apt_packages + WOVariables.wo_mysql
|
||||
else:
|
||||
Log.info(self, "MariaDB is not installed")
|
||||
|
||||
if self.app.pargs.redis:
|
||||
if pargs.redis:
|
||||
if WOAptGet.is_installed(self, 'redis-server'):
|
||||
apt_packages = apt_packages + WOVariables.wo_redis
|
||||
else:
|
||||
Log.info(self, "Redis is not installed")
|
||||
|
||||
if self.app.pargs.wpcli:
|
||||
if pargs.wpcli:
|
||||
if os.path.isfile('/usr/local/bin/wp'):
|
||||
packages = packages + [["https://github.com/wp-cli/wp-cli/"
|
||||
"releases/download/v{0}/"
|
||||
@@ -128,13 +129,13 @@ class WOStackUpgradeController(CementBaseController):
|
||||
else:
|
||||
Log.info(self, "WPCLI is not installed with WordOps")
|
||||
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
if os.path.isdir('/opt/netdata'):
|
||||
packages = packages + [['https://my-netdata.io/'
|
||||
'kickstart-static64.sh',
|
||||
'/var/lib/wo/tmp/kickstart.sh',
|
||||
'Netdata']]
|
||||
if self.app.pargs.phpmyadmin:
|
||||
if pargs.phpmyadmin:
|
||||
if os.path.isdir('/var/www/22222/htdocs/db/pma'):
|
||||
packages = packages + \
|
||||
[["https://files.phpmyadmin.net"
|
||||
@@ -147,7 +148,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
else:
|
||||
Log.error(self, "phpMyAdmin isn't installed")
|
||||
|
||||
if self.app.pargs.composer:
|
||||
if pargs.composer:
|
||||
if os.path.isfile('/usr/local/bin/composer'):
|
||||
packages = packages + [["https://getcomposer.org/installer",
|
||||
"/var/lib/wo/tmp/composer-install",
|
||||
@@ -160,7 +161,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
Log.info(self, "During package update process non nginx-cached"
|
||||
" parts of your site may remain down")
|
||||
# Check prompt
|
||||
if (not self.app.pargs.no_prompt):
|
||||
if (not pargs.no_prompt):
|
||||
start_upgrade = input("Do you want to continue:[y/N]")
|
||||
if start_upgrade != "Y" and start_upgrade != "y":
|
||||
Log.error(self, "Not starting package update")
|
||||
@@ -191,25 +192,25 @@ class WOStackUpgradeController(CementBaseController):
|
||||
WOService.restart_service(self, 'redis-server')
|
||||
|
||||
if len(packages):
|
||||
if self.app.pargs.wpcli:
|
||||
if pargs.wpcli:
|
||||
WOFileUtils.remove(self, ['/usr/local/bin/wp'])
|
||||
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
WOFileUtils.remove(self, ['/var/lib/wo/tmp/kickstart.sh'])
|
||||
|
||||
Log.debug(self, "Downloading following: {0}".format(packages))
|
||||
WODownload.download(self, packages)
|
||||
|
||||
if self.app.pargs.wpcli:
|
||||
if pargs.wpcli:
|
||||
WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775)
|
||||
|
||||
if self.app.pargs.netdata:
|
||||
if pargs.netdata:
|
||||
Log.info(self, "Upgrading Netdata, please wait...")
|
||||
WOShellExec.cmd_exec(self, "/bin/bash /var/lib/wo/tmp/"
|
||||
"kickstart.sh "
|
||||
"--dont-wait")
|
||||
|
||||
if self.app.pargs.composer:
|
||||
if pargs.composer:
|
||||
Log.info(self, "Upgrading Composer, please wait...")
|
||||
WOShellExec.cmd_exec(self, "php -q /var/lib/wo"
|
||||
"/tmp/composer-install "
|
||||
@@ -218,7 +219,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
'/usr/local/bin/composer')
|
||||
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
|
||||
|
||||
if self.app.pargs.phpmyadmin:
|
||||
if pargs.phpmyadmin:
|
||||
Log.info(self, "Upgrading phpMyAdmin, please wait...")
|
||||
WOExtract.extract(self, '/var/lib/wo/tmp/pma.tar.gz',
|
||||
'/var/lib/wo/tmp/')
|
||||
|
||||
@@ -36,20 +36,21 @@ class WOUpdateController(CementBaseController):
|
||||
|
||||
@expose(hide=True)
|
||||
def default(self):
|
||||
pargs = self.app.pargs
|
||||
filename = "woupdate" + time.strftime("%Y%m%d-%H%M%S")
|
||||
|
||||
if self.app.pargs.travis:
|
||||
if pargs.travis:
|
||||
wo_branch = "updating-configuration"
|
||||
install_args = "--travis --force "
|
||||
elif self.app.pargs.beta:
|
||||
elif pargs.beta:
|
||||
wo_branch = "beta"
|
||||
install_args = ""
|
||||
else:
|
||||
wo_branch = "master"
|
||||
install_args = ""
|
||||
if self.app.pargs.force:
|
||||
if pargs.force:
|
||||
install_args = install_args + "--force "
|
||||
if self.app.pargs.preserve:
|
||||
if pargs.preserve:
|
||||
install_args = install_args + "--preserve "
|
||||
|
||||
WODownload.download(self, [["https://raw.githubusercontent.com/"
|
||||
|
||||
Reference in New Issue
Block a user