def default(self, disp_msg=False): # All package update apt_packages = [] packages = [] self.msg = [] pargs = self.app.pargs if ((not pargs.web) and (not pargs.nginx) and (not pargs.php) and (not pargs.php73) and (not pargs.mysql) and (not pargs.ngxblocker) and (not pargs.all) and (not pargs.wpcli) and (not pargs.netdata) and (not pargs.composer) and (not pargs.phpmyadmin) and (not pargs.dashboard) and (not pargs.redis)): pargs.web = True pargs.admin = True if pargs.all: pargs.web = True pargs.admin = True pargs.redis = True pargs.php73 = True pargs.ngxblocker = True if pargs.web: pargs.nginx = True pargs.php = True pargs.mysql = True pargs.wpcli = True if pargs.admin: pargs.netdata = True pargs.composer = True pargs.dashboard = True pargs.phpmyadmin = True pargs.wpcli = True # nginx if pargs.nginx: if WOAptGet.is_installed(self, 'nginx-custom'): apt_packages = apt_packages + WOVar.wo_nginx else: if os.path.isfile('/usr/sbin/nginx'): Log.info(self, "Updating Nginx templates") post_pref(self, WOVar.wo_nginx, []) else: Log.info(self, "Nginx Stable is not already installed") # php 7.2 if pargs.php: if WOAptGet.is_installed(self, 'php7.2-fpm'): apt_packages = apt_packages + WOVar.wo_php + \ WOVar.wo_php_extra else: Log.info(self, "PHP 7.2 is not installed") # php 7.3 if pargs.php73: if WOAptGet.is_installed(self, 'php7.3-fpm'): apt_packages = apt_packages + WOVar.wo_php73 + \ WOVar.wo_php_extra else: Log.info(self, "PHP 7.3 is not installed") # mysql if pargs.mysql: if WOShellExec.cmd_exec(self, 'mysqladmin ping'): apt_packages = apt_packages + ['mariadb-server'] else: Log.info(self, "MariaDB is not installed") # redis if pargs.redis: if WOAptGet.is_installed(self, 'redis-server'): apt_packages = apt_packages + ['redis-server'] else: Log.info(self, "Redis is not installed") # wp-cli if pargs.wpcli: if os.path.isfile('/usr/local/bin/wp'): packages = packages + [[ "https://github.com/wp-cli/wp-cli/" "releases/download/v{0}/" "wp-cli-{0}.phar".format(WOVar.wo_wp_cli), "/usr/local/bin/wp", "WP-CLI"]] else: Log.info(self, "WPCLI is not installed with WordOps") # netdata if pargs.netdata: # detect static binaries install if os.path.isdir('/opt/netdata'): packages = packages + [[ 'https://my-netdata.io/kickstart-static64.sh', '/var/lib/wo/tmp/kickstart.sh', 'Netdata']] # detect install from source elif os.path.isdir('/etc/netdata'): packages = packages + [[ 'https://my-netdata.io/kickstart.sh', '/var/lib/wo/tmp/kickstart.sh', 'Netdata']] else: Log.info(self, 'Netdata us not installed') # wordops dashboard if pargs.dashboard: if (os.path.isfile('/var/www/22222/htdocs/index.php') or os.path.isfile('/var/www/22222/htdocs/index.html')): packages = packages + [[ "https://github.com/WordOps/wordops-dashboard/" "releases/download/v{0}/wordops-dashboard.tar.gz" .format(WOVar.wo_dashboard), "/var/lib/wo/tmp/wo-dashboard.tar.gz", "WordOps Dashboard"]] else: Log.info(self, 'WordOps dashboard is not installed') # phpmyadmin if pargs.phpmyadmin: if os.path.isdir('/var/www/22222/htdocs/db/pma'): packages = packages + [[ "https://files.phpmyadmin.net" "/phpMyAdmin/{0}/phpMyAdmin-{0}-" "all-languages.tar.gz" .format(WOVar.wo_phpmyadmin), "/var/lib/wo/tmp/pma.tar.gz", "PHPMyAdmin"]] else: Log.info(self, "phpMyAdmin isn't installed") # composer if pargs.composer: if os.path.isfile('/usr/local/bin/composer'): packages = packages + [[ "https://getcomposer.org/installer", "/var/lib/wo/tmp/composer-install", "Composer"]] else: Log.info(self, "Composer isn't installed") # ngxblocker if pargs.ngxblocker: if os.path.exists('/usr/local/sbin/install-ngxblocker'): packages = packages + [[ 'https://raw.githubusercontent.com/mitchellkrogza/' 'nginx-ultimate-bad-bot-blocker/master/update-ngxblocker', '/usr/local/sbin/update-ngxblocker', 'ngxblocker' ]] else: Log.info(self, "ngxblocker is not installed") if ((not (apt_packages)) and (not(packages))): self.app.args.print_help() else: pre_stack(self) if (apt_packages): if (("php7.2-fpm" not in apt_packages) and ("php7.3-fpm" not in apt_packages) and ("nginx-custom" not in apt_packages) and ("mariadb-server" not in apt_packages)): pass else: Log.info( self, "Your sites may be down for few seconds if " "you are upgrading Nginx, PHP-FPM, MariaDB or Redis") # Check prompt if ((not pargs.no_prompt) and (not pargs.force)): 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") Log.wait(self, "Updating APT packages") # apt-get update WOAptGet.update(self) Log.valide(self, "Updating APT packages") # additional pre_pref if "nginx-custom" in apt_packages: pre_pref(self, WOVar.wo_nginx) if "php7.2-fpm" in apt_packages: WOAptGet.remove(self, ['php7.2-fpm'], auto=False, purge=True) if "php7.3-fpm" in apt_packages: WOAptGet.remove(self, ['php7.3-fpm'], auto=False, purge=True) # check if nginx upgrade is blocked if os.path.isfile( '/etc/apt/preferences.d/nginx-block'): post_pref(self, WOVar.wo_nginx, [], True) # upgrade packages WOAptGet.install(self, apt_packages) Log.wait(self, "Configuring APT Packages") post_pref(self, apt_packages, [], True) if "mariadb-server" in apt_packages: WOShellExec.cmd_exec(self, 'mysql_upgrade') Log.valide(self, "Configuring APT Packages") # Post Actions after package updates if (packages): if pargs.wpcli: WOFileUtils.rm(self, '/usr/local/bin/wp') if pargs.netdata: WOFileUtils.rm(self, '/var/lib/wo/tmp/kickstart.sh') if pargs.ngxblocker: WOFileUtils.rm(self, '/usr/local/sbin/update-ngxblocker') if pargs.dashboard: if os.path.isfile('/var/www/22222/htdocs/index.php'): WOFileUtils.rm(self, '/var/www/22222/htdocs/index.php') if os.path.isfile('/var/www/22222/htdocs/index.html'): WOFileUtils.rm( self, '/var/www/22222/htdocs/index.html') Log.debug(self, "Downloading following: {0}".format(packages)) WODownload.download(self, packages) if pargs.wpcli: WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775) if pargs.ngxblocker: WOFileUtils.chmod( self, '/usr/local/sbin/update-ngxblocker', 0o700) WOShellExec.cmd_exec( self, '/usr/local/sbin/update-ngxblocker -nq' ) # Netdata if pargs.netdata: Log.wait(self, "Upgrading Netdata") # detect static binaries install if os.path.isdir('/opt/netdata'): if os.path.exists( '/opt/netdata/usr/libexec/' 'netdata/netdata-updater.sh'): WOShellExec.cmd_exec( self, "bash /opt/netdata/usr/" "libexec/netdata/netdata-" "updater.sh") else: WOShellExec.cmd_exec( self, "bash /var/lib/wo/tmp/kickstart.sh") # detect install from source elif os.path.isdir('/etc/netdata'): if os.path.exists( '/usr/libexec/netdata/netdata-updater.sh'): WOShellExec.cmd_exec( self, 'bash /usr/libexec/netdata/netdata-updater.sh') else: WOShellExec.cmd_exec( self, "bash /var/lib/wo/tmp/kickstart.sh") Log.valide(self, "Upgrading Netdata") if pargs.dashboard: post_pref( self, [], [["https://github.com/WordOps" "/wordops-dashboard/" "releases/download/v{0}/" "wordops-dashboard.tar.gz" .format(WOVar.wo_dashboard), "/var/lib/wo/tmp/wo-dashboard.tar.gz", "WordOps Dashboard"]]) if pargs.composer: Log.wait(self, "Upgrading Composer") if WOShellExec.cmd_exec( self, '/usr/bin/php -v'): WOShellExec.cmd_exec( self, "php -q /var/lib/wo" "/tmp/composer-install " "--install-dir=/var/lib/wo/tmp/") shutil.copyfile('/var/lib/wo/tmp/composer.phar', '/usr/local/bin/composer') WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) Log.valide(self, "Upgrading Composer ") if pargs.phpmyadmin: Log.wait(self, "Upgrading phpMyAdmin") WOExtract.extract(self, '/var/lib/wo/tmp/pma.tar.gz', '/var/lib/wo/tmp/') shutil.copyfile(('{0}22222/htdocs/db/pma' '/config.inc.php' .format(WOVar.wo_webroot)), ('/var/lib/wo/tmp/phpMyAdmin-{0}' '-all-languages/config.inc.php' .format(WOVar.wo_phpmyadmin)) ) WOFileUtils.rm(self, '{0}22222/htdocs/db/pma' .format(WOVar.wo_webroot)) shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}' '-all-languages/' .format(WOVar.wo_phpmyadmin), '{0}22222/htdocs/db/pma/' .format(WOVar.wo_webroot)) WOFileUtils.chown(self, "{0}22222/htdocs" .format(WOVar.wo_webroot), 'www-data', 'www-data', recursive=True) Log.valide(self, "Upgrading phpMyAdmin") Log.info(self, "Successfully updated packages")
def default(self, disp_msg=False): # All package update apt_packages = [] packages = [] self.msg = [] pargs = self.app.pargs wo_phpmyadmin = WODownload.pma_release(self) if not (pargs.web or pargs.nginx or pargs.php or pargs.php72 or pargs.php73 or pargs.php74 or pargs.mysql or pargs.ngxblocker or pargs.all or pargs.netdata or pargs.wpcli or pargs.composer or pargs.phpmyadmin or pargs.adminer or pargs.dashboard or pargs.mysqltuner or pargs.redis or pargs.fail2ban or pargs.security): pargs.web = True pargs.admin = True pargs.security = True if pargs.php: pargs.php72 = True if pargs.all: pargs.web = True pargs.admin = True pargs.security = True pargs.redis = True if pargs.web: pargs.nginx = True pargs.php72 = True pargs.php73 = True pargs.php74 = True pargs.mysql = True pargs.wpcli = True if pargs.admin: pargs.netdata = True pargs.composer = True pargs.dashboard = True pargs.phpmyadmin = True pargs.wpcli = True pargs.adminer = True pargs.mysqltuner = True if pargs.security: pargs.ngxblocker = True pargs.fail2ban = True # nginx if pargs.nginx: if WOAptGet.is_installed(self, 'nginx-custom'): apt_packages = apt_packages + WOVar.wo_nginx else: if os.path.isfile('/usr/sbin/nginx'): Log.info(self, "Updating Nginx templates") post_pref(self, WOVar.wo_nginx, []) else: Log.info(self, "Nginx Stable is not already installed") # php 7.2 if pargs.php72: if WOAptGet.is_installed(self, 'php7.2-fpm'): apt_packages = apt_packages + WOVar.wo_php72 + \ WOVar.wo_php_extra # php 7.3 if pargs.php73: if WOAptGet.is_installed(self, 'php7.3-fpm'): apt_packages = apt_packages + WOVar.wo_php73 + \ WOVar.wo_php_extra # php 7.4 if pargs.php74: if WOAptGet.is_installed(self, 'php7.4-fpm'): apt_packages = apt_packages + WOVar.wo_php74 + \ WOVar.wo_php_extra # mysql if pargs.mysql: if WOShellExec.cmd_exec(self, 'mysqladmin ping'): apt_packages = apt_packages + ['mariadb-server'] # redis if pargs.redis: if WOAptGet.is_installed(self, 'redis-server'): apt_packages = apt_packages + ['redis-server'] # fail2ban if pargs.fail2ban: if WOAptGet.is_installed(self, 'fail2ban'): apt_packages = apt_packages + ['fail2ban'] # wp-cli if pargs.wpcli: if os.path.isfile('/usr/local/bin/wp'): packages = packages + [[ "https://github.com/wp-cli/wp-cli/" "releases/download/v{0}/" "wp-cli-{0}.phar".format(WOVar.wo_wp_cli), "/usr/local/bin/wp", "WP-CLI"]] else: Log.info(self, "WPCLI is not installed with WordOps") # netdata if pargs.netdata: # detect static binaries install if os.path.isdir('/opt/netdata'): packages = packages + [[ 'https://my-netdata.io/kickstart-static64.sh', '/var/lib/wo/tmp/kickstart.sh', 'Netdata']] # detect install from source elif os.path.isdir('/etc/netdata'): packages = packages + [[ 'https://my-netdata.io/kickstart.sh', '/var/lib/wo/tmp/kickstart.sh', 'Netdata']] else: Log.info(self, 'Netdata is not installed') # wordops dashboard if pargs.dashboard: if (os.path.isfile('/var/www/22222/htdocs/index.php') or os.path.isfile('/var/www/22222/htdocs/index.html')): packages = packages + [[ "https://github.com/WordOps/wordops-dashboard/" "releases/download/v{0}/wordops-dashboard.tar.gz" .format(WOVar.wo_dashboard), "/var/lib/wo/tmp/wo-dashboard.tar.gz", "WordOps Dashboard"]] else: Log.info(self, 'WordOps dashboard is not installed') # phpmyadmin if pargs.phpmyadmin: if os.path.isdir('/var/www/22222/htdocs/db/pma'): packages = packages + [[ "https://files.phpmyadmin.net" "/phpMyAdmin/{0}/phpMyAdmin-{0}-" "all-languages.tar.gz" .format(wo_phpmyadmin), "/var/lib/wo/tmp/pma.tar.gz", "PHPMyAdmin"]] else: Log.info(self, "phpMyAdmin isn't installed") # adminer if pargs.adminer: if os.path.isfile("{0}22222/htdocs/db/" "adminer/index.php" .format(WOVar.wo_webroot)): Log.debug(self, "Setting packages variable for Adminer ") packages = packages + [[ "https://www.adminer.org/latest.php", "{0}22222/" "htdocs/db/adminer/index.php" .format(WOVar.wo_webroot), "Adminer"], ["https://raw.githubusercontent.com" "/vrana/adminer/master/designs/" "pepa-linha/adminer.css", "{0}22222/" "htdocs/db/adminer/adminer.css" .format(WOVar.wo_webroot), "Adminer theme"]] else: Log.debug(self, "Adminer isn't installed") Log.info(self, "Adminer isn't installed") # composer if pargs.composer: if os.path.isfile('/usr/local/bin/composer'): packages = packages + [[ "https://getcomposer.org/installer", "/var/lib/wo/tmp/composer-install", "Composer"]] else: Log.info(self, "Composer isn't installed") # mysqltuner if pargs.mysqltuner: if WOAptGet.is_exec(self, 'mysqltuner'): Log.debug(self, "Setting packages variable " "for MySQLTuner ") packages = packages + [["https://raw." "githubusercontent.com/" "major/MySQLTuner-perl" "/master/mysqltuner.pl", "/usr/bin/mysqltuner", "MySQLTuner"]] # ngxblocker if pargs.ngxblocker: if os.path.exists('/usr/local/sbin/install-ngxblocker'): packages = packages + [[ 'https://raw.githubusercontent.com/mitchellkrogza/' 'nginx-ultimate-bad-bot-blocker/master/update-ngxblocker', '/usr/local/sbin/update-ngxblocker', 'ngxblocker' ]] if ((not (apt_packages)) and (not(packages))): self.app.args.print_help() else: pre_stack(self) if (apt_packages): if not ("php7.2-fpm" in apt_packages or "php7.3-fpm" in apt_packages or "php7.4-fpm" in apt_packages or "redis-server" in apt_packages or "nginx-custom" in apt_packages or "mariadb-server" in apt_packages): pass else: Log.warn( self, "Your sites may be down for few seconds if " "you are upgrading Nginx, PHP-FPM, MariaDB or Redis") # Check prompt if not (pargs.no_prompt or pargs.force): 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") Log.wait(self, "Updating APT cache") # apt-get update WOAptGet.update(self) Log.valide(self, "Updating APT cache") # additional pre_pref if "nginx-custom" in apt_packages: pre_pref(self, WOVar.wo_nginx) if "php7.2-fpm" in apt_packages: WOAptGet.remove(self, ['php7.2-fpm'], auto=False, purge=True) if "php7.3-fpm" in apt_packages: WOAptGet.remove(self, ['php7.3-fpm'], auto=False, purge=True) if "php7.4-fpm" in apt_packages: WOAptGet.remove(self, ['php7.4-fpm'], auto=False, purge=True) # check if nginx upgrade is blocked if os.path.isfile( '/etc/apt/preferences.d/nginx-block'): post_pref(self, WOVar.wo_nginx, [], True) # upgrade packages WOAptGet.install(self, apt_packages) Log.wait(self, "Configuring APT Packages") post_pref(self, apt_packages, [], True) if "mariadb-server" in apt_packages: WOShellExec.cmd_exec(self, 'mysql_upgrade') Log.valide(self, "Configuring APT Packages") # Post Actions after package updates if (packages): if WOAptGet.is_selected(self, 'WP-CLI', packages): WOFileUtils.rm(self, '/usr/local/bin/wp') if WOAptGet.is_selected(self, 'Netdata', packages): WOFileUtils.rm(self, '/var/lib/wo/tmp/kickstart.sh') if WOAptGet.is_selected(self, 'ngxblocker', packages): WOFileUtils.rm(self, '/usr/local/sbin/update-ngxblocker') if WOAptGet.is_selected(self, 'WordOps Dashboard', packages): if os.path.isfile('/var/www/22222/htdocs/index.php'): WOFileUtils.rm(self, '/var/www/22222/htdocs/index.php') if os.path.isfile('/var/www/22222/htdocs/index.html'): WOFileUtils.rm( self, '/var/www/22222/htdocs/index.html') Log.debug(self, "Downloading following: {0}".format(packages)) WODownload.download(self, packages) if WOAptGet.is_selected(self, 'WP-CLI', packages): WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775) if WOAptGet.is_selected(self, 'ngxblocker', packages): if os.path.exists('/etc/nginx/conf.d/variables-hash.conf'): WOFileUtils.rm( self, '/etc/nginx/conf.d/variables-hash.conf') WOFileUtils.chmod( self, '/usr/local/sbin/update-ngxblocker', 0o775) WOShellExec.cmd_exec( self, '/usr/local/sbin/update-ngxblocker -nq') if WOAptGet.is_selected(self, 'MySQLTuner', packages): WOFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775) if os.path.exists('/usr/local/bin/mysqltuner'): WOFileUtils.rm(self, '/usr/local/bin/mysqltuner') # Netdata if WOAptGet.is_selected(self, 'Netdata', packages): WOService.stop_service(self, 'netdata') Log.wait(self, "Upgrading Netdata") # detect static binaries install WOShellExec.cmd_exec( self, "bash /var/lib/wo/tmp/kickstart.sh " "--dont-wait --no-updates", errormsg='', log=False) Log.valide(self, "Upgrading Netdata") if WOAptGet.is_selected(self, 'WordOps Dashboard', packages): post_pref( self, [], [["https://github.com/WordOps" "/wordops-dashboard/" "releases/download/v{0}/" "wordops-dashboard.tar.gz" .format(WOVar.wo_dashboard), "/var/lib/wo/tmp/wo-dashboard.tar.gz", "WordOps Dashboard"]]) if WOAptGet.is_selected(self, 'Composer', packages): Log.wait(self, "Upgrading Composer") if WOShellExec.cmd_exec( self, '/usr/bin/php -v'): WOShellExec.cmd_exec( self, "php -q /var/lib/wo" "/tmp/composer-install " "--install-dir=/var/lib/wo/tmp/") shutil.copyfile('/var/lib/wo/tmp/composer.phar', '/usr/local/bin/composer') WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) Log.valide(self, "Upgrading Composer ") if WOAptGet.is_selected(self, 'PHPMyAdmin', packages): Log.wait(self, "Upgrading phpMyAdmin") WOExtract.extract(self, '/var/lib/wo/tmp/pma.tar.gz', '/var/lib/wo/tmp/') shutil.copyfile(('{0}22222/htdocs/db/pma' '/config.inc.php' .format(WOVar.wo_webroot)), ('/var/lib/wo/tmp/phpMyAdmin-{0}' '-all-languages/config.inc.php' .format(wo_phpmyadmin)) ) WOFileUtils.rm(self, '{0}22222/htdocs/db/pma' .format(WOVar.wo_webroot)) shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}' '-all-languages/' .format(wo_phpmyadmin), '{0}22222/htdocs/db/pma/' .format(WOVar.wo_webroot)) WOFileUtils.chown(self, "{0}22222/htdocs" .format(WOVar.wo_webroot), 'www-data', 'www-data', recursive=True) Log.valide(self, "Upgrading phpMyAdmin") if os.path.exists('{0}22222/htdocs'.format(WOVar.wo_webroot)): WOFileUtils.chown(self, "{0}22222/htdocs" .format(WOVar.wo_webroot), 'www-data', 'www-data', recursive=True) Log.info(self, "Successfully updated packages")
def install(self, packages=[], apt_packages=[], disp_msg=True): """Start installation of packages""" self.msg = [] empty_packages = [] wo_webroot = "/var/www/" pargs = self.app.pargs try: # Default action for stack installation if ((not pargs.web) and (not pargs.admin) and (not pargs.nginx) and (not pargs.php) and (not pargs.mysql) and (not pargs.wpcli) and (not pargs.phpmyadmin) and (not pargs.composer) and (not pargs.netdata) and (not pargs.dashboard) and (not pargs.fail2ban) and (not pargs.security) and (not pargs.mysqlclient) and (not pargs.mysqltuner) and (not pargs.adminer) and (not pargs.utils) and (not pargs.redis) and (not pargs.proftpd) and (not pargs.extplorer) and (not pargs.clamav) and (not pargs.cheat) and (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.php73)): pargs.web = True pargs.admin = True pargs.fail2ban = True if pargs.all: pargs.web = True pargs.admin = True pargs.php73 = True pargs.redis = True pargs.proftpd = True if pargs.web: pargs.nginx = True pargs.php = True pargs.mysql = True pargs.wpcli = True pargs.sendmail = True if pargs.admin: pargs.web = True pargs.adminer = True pargs.phpmyadmin = True pargs.composer = True pargs.utils = True pargs.netdata = True pargs.dashboard = True pargs.phpredisadmin = True pargs.extplorer = True pargs.cheat = True if pargs.security: pargs.fail2ban = True pargs.clamav = True pargs.ngxblocker = True # Nginx if pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") if not (WOAptGet.is_installed(self, 'nginx-custom')): if not (WOAptGet.is_installed(self, 'nginx-plus') or WOAptGet.is_installed(self, 'nginx')): if not os.path.isfile('/usr/sbin/nginx'): apt_packages = apt_packages + WOVar.wo_nginx else: if WOAptGet.is_installed(self, 'nginx-plus'): Log.info(self, "NGINX PLUS Detected ...") apt = ["nginx-plus"] + WOVar.wo_nginx post_pref(self, apt, empty_packages) elif WOAptGet.is_installed(self, 'nginx'): Log.info(self, "WordOps detected an already " "installed nginx package." "It may or may not have " "required modules.\n") apt = ["nginx"] + WOVar.wo_nginx post_pref(self, apt, empty_packages) else: Log.debug(self, "Nginx already installed") # Redis if pargs.redis: if not WOAptGet.is_installed(self, 'redis-server'): apt_packages = apt_packages + WOVar.wo_redis else: Log.info(self, "Redis already installed") # PHP 7.2 if pargs.php: Log.debug(self, "Setting apt_packages variable for PHP 7.2") if not (WOAptGet.is_installed(self, 'php7.2-fpm')): apt_packages = (apt_packages + WOVar.wo_php + WOVar.wo_php_extra) else: Log.debug(self, "PHP 7.2 already installed") Log.info(self, "PHP 7.2 already installed") # PHP 7.3 if pargs.php73: Log.debug(self, "Setting apt_packages variable for PHP 7.3") if not WOAptGet.is_installed(self, 'php7.3-fpm'): apt_packages = (apt_packages + WOVar.wo_php + WOVar.wo_php73 + WOVar.wo_php_extra) else: Log.debug(self, "PHP 7.3 already installed") Log.info(self, "PHP 7.3 already installed") # MariaDB 10.3 if pargs.mysql: pargs.mysqltuner = True Log.debug(self, "Setting apt_packages variable for MySQL") if not WOShellExec.cmd_exec(self, "mysqladmin ping"): apt_packages = apt_packages + WOVar.wo_mysql else: Log.debug(self, "MySQL already installed and alive") Log.info(self, "MySQL already installed and alive") # mysqlclient if pargs.mysqlclient: Log.debug(self, "Setting apt_packages variable " "for MySQL Client") if not WOShellExec.cmd_exec(self, "mysqladmin ping"): apt_packages = apt_packages + WOVar.wo_mysql_client else: Log.debug(self, "MySQL already installed and alive") Log.info(self, "MySQL already installed and alive") # WP-CLI if pargs.wpcli: Log.debug(self, "Setting packages variable for WP-CLI") if ((not os.path.isfile("/usr/local/bin/wp")) and (not os.path.isfile("/usr/bin/wp"))): packages = packages + [["https://github.com/wp-cli/wp-cli/" "releases/download/v{0}/" "wp-cli-{0}.phar" "".format(WOVar.wo_wp_cli), "/usr/local/bin/wp", "WP-CLI"]] else: Log.debug(self, "WP-CLI is already installed") Log.info(self, "WP-CLI is already installed") # fail2ban if pargs.fail2ban: Log.debug(self, "Setting apt_packages variable for Fail2ban") if not WOAptGet.is_installed(self, 'fail2ban'): apt_packages = apt_packages + WOVar.wo_fail2ban else: Log.debug(self, "Fail2ban already installed") Log.info(self, "Fail2ban already installed") # ClamAV if pargs.clamav: Log.debug(self, "Setting apt_packages variable for ClamAV") if not WOAptGet.is_installed(self, 'clamav'): apt_packages = apt_packages + WOVar.wo_clamav else: Log.debug(self, "ClamAV already installed") Log.info(self, "ClamAV already installed") # UFW if pargs.ufw: Log.debug(self, "Setting apt_packages variable for UFW") apt_packages = apt_packages + ["ufw"] # sendmail if pargs.sendmail: Log.debug(self, "Setting apt_packages variable for Sendmail") if (not WOAptGet.is_installed(self, 'sendmail') and not WOAptGet.is_installed(self, 'postfix')): apt_packages = apt_packages + ["sendmail"] else: if WOAptGet.is_installed(self, 'sendmail'): Log.debug(self, "Sendmail already installed") Log.info(self, "Sendmail already installed") else: Log.debug( self, "Another mta (Postfix) is already installed") Log.info( self, "Another mta (Postfix) is already installed") # proftpd if pargs.proftpd: Log.debug(self, "Setting apt_packages variable for ProFTPd") if not WOAptGet.is_installed(self, 'proftpd-basic'): apt_packages = apt_packages + ["proftpd-basic"] else: Log.debug(self, "ProFTPd already installed") Log.info(self, "ProFTPd already installed") # PHPMYADMIN if pargs.phpmyadmin: pargs.composer = True if not os.path.isdir('/var/www/22222/htdocs/db/pma'): Log.debug(self, "Setting packages variable " "for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/" "phpmyadmin/archive/STABLE.tar.gz", "/var/lib/wo/tmp/pma.tar.gz", "phpMyAdmin"]] else: Log.debug(self, "phpMyAdmin already installed") Log.info(self, "phpMyAdmin already installed") # PHPREDISADMIN if pargs.phpredisadmin: pargs.composer = True if not os.path.isdir('/var/www/22222/htdocs/' 'cache/redis/phpRedisAdmin'): Log.debug( self, "Setting packages variable for phpRedisAdmin") packages = packages + [["https://github.com/" "erikdubbelboer/" "phpRedisAdmin/archive" "/v1.11.3.tar.gz", "/var/lib/wo/tmp/pra.tar.gz", "phpRedisAdmin"]] else: Log.debug(self, "phpRedisAdmin already installed") Log.info(self, "phpRedisAdmin already installed") # Composer if pargs.composer: if ((not WOAptGet.is_installed(self, 'php7.2-fpm')) and (not WOAptGet.is_installed(self, 'php7.3-fpm'))): pargs.php = True if not os.path.isfile('/usr/local/bin/composer'): Log.debug(self, "Setting packages variable for Composer ") packages = packages + [["https://getcomposer.org/" "installer", "/var/lib/wo/tmp/composer-install", "Composer"]] else: Log.debug(self, "Composer already installed") Log.info(self, "Composer already installed") # ADMINER if pargs.adminer: if not os.path.isfile("{0}22222/htdocs/db/" "adminer/index.php" .format(wo_webroot)): Log.debug(self, "Setting packages variable for Adminer ") packages = packages + [[ "https://github.com/vrana/adminer/" "releases/download/v{0}" "/adminer-{0}.php" .format(WOVar.wo_adminer), "{0}22222/" "htdocs/db/adminer/index.php" .format(WOVar.wo_webroot), "Adminer"], ["https://raw.githubusercontent.com" "/vrana/adminer/master/designs/" "pepa-linha/adminer.css", "{0}22222/" "htdocs/db/adminer/adminer.css" .format(WOVar.wo_webroot), "Adminer theme"]] else: Log.debug(self, "Adminer already installed") Log.info(self, "Adminer already installed") # mysqltuner if pargs.mysqltuner: if not os.path.isfile("/usr/bin/mysqltuner"): Log.debug(self, "Setting packages variable " "for MySQLTuner ") packages = packages + [["https://raw." "githubusercontent.com/" "major/MySQLTuner-perl" "/master/mysqltuner.pl", "/usr/bin/mysqltuner", "MySQLTuner"]] else: Log.debug(self, "MySQLtuner already installed") Log.info(self, "MySQLtuner already installed") # Netdata if pargs.netdata: if (not os.path.isdir('/opt/netdata') and not os.path.isdir("/etc/netdata")): Log.debug( self, "Setting packages variable for Netdata") if WOVar.wo_distro == 'raspbian': packages = packages + [['https://my-netdata.io/' 'kickstart.sh', '/var/lib/wo/tmp/kickstart.sh', 'Netdata']] else: packages = packages + [['https://my-netdata.io/' 'kickstart-static64.sh', '/var/lib/wo/tmp/kickstart.sh', 'Netdata']] else: Log.debug(self, "Netdata already installed") Log.info(self, "Netdata already installed") # WordOps Dashboard if pargs.dashboard: if not os.path.isfile('/var/www/22222/htdocs/index.php'): Log.debug(self, "Setting packages variable for WO-Dashboard") packages = packages + [[ "https://github.com/WordOps" "/wordops-dashboard/" "releases/download/v{0}/" "wordops-dashboard.tar.gz" .format(WOVar.wo_dashboard), "/var/lib/wo/tmp/wo-dashboard.tar.gz", "WordOps Dashboard"]] else: Log.debug(self, "WordOps dashboard already installed") Log.info(self, "WordOps dashboard already installed") # eXtplorer if pargs.extplorer: if not os.path.isdir('/var/www/22222/htdocs/files'): Log.debug(self, "Setting packages variable for eXtplorer") packages = packages + \ [["https://github.com/soerennb/" "extplorer/archive/v{0}.tar.gz" .format(WOVar.wo_extplorer), "/var/lib/wo/tmp/extplorer.tar.gz", "eXtplorer"]] else: Log.debug(self, "eXtplorer is already installed") Log.info(self, "eXtplorer is already installed") # ultimate ngx_blocker if pargs.ngxblocker: if not os.path.isdir('/etc/nginx/bots.d'): Log.debug(self, "Setting packages variable for ngxblocker") packages = packages + \ [["https://raw.githubusercontent.com/" "mitchellkrogza/nginx-ultimate-bad-bot-blocker" "/master/install-ngxblocker", "/usr/local/sbin/install-ngxblocker", "ngxblocker"]] else: Log.debug(self, "ngxblocker is already installed") Log.info(self, "ngxblocker is already installed") # cheat.sh if pargs.cheat: if ((not os.path.exists('/usr/local/bin/cht.sh')) and (not os.path.exists('/usr/bin/cht.sh'))): Log.debug(self, 'Setting packages variable for cheat.sh') packages = packages + [[ "https://raw.githubusercontent.com/chubin/cheat.sh" "/master/share/cht.sh.txt", "/usr/local/bin/cht.sh", "cheat.sh"], ["https://raw.githubusercontent.com/chubin/cheat.sh" "/master/share/bash_completion.txt", "/etc/bash_completion.d/cht.sh", "bash_completion"]] # UTILS if pargs.utils: Log.debug(self, "Setting packages variable for utils") packages = packages + [[ "https://raw.githubusercontent.com" "/rtCamp/eeadmin/master/cache/nginx/" "clean.php", "{0}22222/htdocs/cache/" "nginx/clean.php" .format(WOVar.wo_webroot), "clean.php"], ["https://raw.github.com/rlerdorf/" "opcache-status/master/opcache.php", "{0}22222/htdocs/cache/" "opcache/opcache.php" .format(WOVar.wo_webroot), "opcache.php"], ["https://raw.github.com/amnuts/" "opcache-gui/master/index.php", "{0}22222/htdocs/" "cache/opcache/opgui.php" .format(WOVar.wo_webroot), "Opgui"], ["https://raw.githubusercontent.com/" "mlazarov/ocp/master/ocp.php", "{0}22222/htdocs/cache/" "opcache/ocp.php" .format(WOVar.wo_webroot), "OCP.php"], ["https://github.com/jokkedk/webgrind/" "archive/master.tar.gz", '/var/lib/wo/tmp/webgrind.tar.gz', 'Webgrind'], ["https://www.percona.com/" "get/pt-query-digest", "/usr/bin/pt-query-advisor", "pt-query-advisor"], ["https://github.com/box/Anemometer/" "archive/master.tar.gz", '/var/lib/wo/tmp/anemometer.tar.gz', 'Anemometer']] except Exception as e: Log.debug(self, "{0}".format(e)) if (apt_packages) or (packages): pre_stack(self) if (apt_packages): Log.debug(self, "Calling pre_pref") pre_pref(self, apt_packages) # meminfo = (os.popen('/bin/cat /proc/meminfo ' # '| grep MemTotal').read()).split(":") # memsplit = re.split(" kB", meminfo[1]) # wo_mem = int(memsplit[0]) # if (wo_mem < 4000000): # WOSwap.add(self) Log.wait(self, "Updating apt-cache ") WOAptGet.update(self) Log.valide(self, "Updating apt-cache ") Log.wait(self, "Installing APT packages ") WOAptGet.install(self, apt_packages) Log.valide(self, "Installing APT packages ") Log.wait(self, "Configuring APT packages ") post_pref(self, apt_packages, []) Log.valide(self, "Configuring APT packages ") if (packages): Log.debug(self, "Downloading following: {0}".format(packages)) WODownload.download(self, packages) Log.debug(self, "Calling post_pref") Log.wait(self, "Configuring packages") post_pref(self, [], packages) Log.valide(self, "Configuring packages") if disp_msg: if (self.msg): for msg in self.msg: Log.info(self, Log.ENDC + msg) Log.info(self, "Successfully installed packages") else: return self.msg return 0