def upgrade_php56(self): if WOVariables.wo_platform_distro == "ubuntu": if os.path.isfile("/etc/apt/sources.list.d/ondrej-php5-5_6-{0}." "list".format(WOVariables.wo_platform_codename)): Log.error(self, "Unable to find PHP 5.5") else: if not(os.path.isfile(WOVariables.wo_repo_file_path) and WOFileUtils.grep(self, WOVariables.wo_repo_file_path, "php55")): Log.error(self, "Unable to find PHP 5.5") Log.info(self, "During PHP update process non nginx-cached" " parts of your site may remain down.") # Check prompt if (not self.app.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 PHP package update") if WOVariables.wo_platform_distro == "ubuntu": WORepo.remove(self, ppa="ppa:ondrej/php5") WORepo.add(self, ppa=WOVariables.wo_php_repo) Log.info(self, "Updating apt-cache, please wait...") WOAptGet.update(self) Log.info(self, "Installing packages, please wait ...") if (WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic'): WOAptGet.install(self, WOVariables.wo_php + WOVariables.wo_php_extra) else: WOAptGet.install(self, WOVariables.wo_php) if WOVariables.wo_platform_distro == "debian": WOShellExec.cmd_exec(self, "pecl install xdebug")
def migrate_mariadb(self, ci=False): # Backup all database WOMysql.backupAll(self, fulldump=True) # Remove previous MariaDB repository wo_mysql_old_repo = ("deb [arch=amd64,ppc64el] " "http://mariadb.mirrors.ovh.net/MariaDB/repo/" "10.3/{distro} {codename} main".format( distro=WOVar.wo_distro, codename=WOVar.wo_platform_codename)) if WOFileUtils.grepcheck(self, '/etc/apt/sources.list.d/wo-repo.list', wo_mysql_old_repo): WORepo.remove(self, repo_url=wo_mysql_old_repo) # Add MariaDB repo pre_pref(self, WOVar.wo_mysql) # Install MariaDB Log.wait(self, "Updating apt-cache ") WOAptGet.update(self) Log.valide(self, "Updating apt-cache ") Log.wait(self, "Upgrading MariaDB ") WOAptGet.remove(self, ["mariadb-server"]) WOAptGet.auto_remove(self) WOAptGet.install(self, WOVar.wo_mysql) if not ci: WOAptGet.dist_upgrade(self) WOAptGet.auto_remove(self) Log.valide(self, "Upgrading MariaDB ") WOFileUtils.mvfile(self, '/etc/mysql/my.cnf', '/etc/mysql/my.cnf.old') WOFileUtils.create_symlink( self, ['/etc/mysql/mariadb.cnf', '/etc/mysql/my.cnf']) WOShellExec.cmd_exec(self, 'systemctl daemon-reload') WOShellExec.cmd_exec(self, 'systemctl enable mariadb') post_pref(self, WOVar.wo_mysql, [])
def download_only(self,package_name,repo_url=None,repo_key=None): """ Similar to `apt-get install --download-only PACKAGE_NAME` """ packages = ' '.join(package_name) try: with open('/var/log/wo/wordops.log', 'a') as f: if repo_url is not None: WORepo.add(self, repo_url=repo_url) if repo_key is not None: WORepo.add_key(self, repo_key) proc = subprocess.Popen("apt-get update && DEBIAN_FRONTEND=noninteractive " "apt-get install -o " "Dpkg::Options::=\"--force-confdef\"" " -o " "Dpkg::Options::=\"--force-confold\"" " -y --download-only {0}" .format(packages), shell=True, stdin=None, stdout=f, stderr=f, executable="/bin/bash") proc.wait() if proc.returncode == 0: return True else: Log.error(self,"Error in fetching dpkg package.\nReverting changes ..",False) if repo_url is not None: WORepo.remove(self, repo_url=repo_url) return False except Exception as e: Log.error(self, "Error while downloading packages, " "apt-get exited with error")
def upgrade_php56(self): if WOVariables.wo_platform_distro == "ubuntu": if os.path.isfile("/etc/apt/sources.list.d/ondrej-php5-5_6-{0}." "list".format(WOVariables.wo_platform_codename)): Log.error(self, "Unable to find PHP 5.5") else: if not(os.path.isfile(WOVariables.wo_repo_file_path) and WOFileUtils.grep(self, WOVariables.wo_repo_file_path, "php55")): Log.error(self, "Unable to find PHP 5.5") Log.info(self, "During PHP update process non nginx-cached" " parts of your site may remain down.") # Check prompt if (not self.app.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 PHP package update") if WOVariables.wo_platform_distro == "ubuntu": WORepo.remove(self, ppa="ppa:ondrej/php5") WORepo.add(self, ppa=WOVariables.wo_php_repo) else: WOAptGet.remove(self, ["php5-xdebug"]) WOFileUtils.searchreplace(self, WOVariables.wo_repo_file_path, "php55", "php56") Log.info(self, "Updating apt-cache, please wait...") WOAptGet.update(self) Log.info(self, "Installing packages, please wait ...") if (WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic'): WOAptGet.install(self, WOVariables.wo_php5_6 + WOVariables.wo_php_extra) else: WOAptGet.install(self, WOVariables.wo_php) if WOVariables.wo_platform_distro == "debian": WOShellExec.cmd_exec(self, "pecl install xdebug") with open("/etc/php5/mods-available/xdebug.ini", encoding='utf-8', mode='a') as myfile: myfile.write(";zend_extension=/usr/lib/php5/20131226/" "xdebug.so\n") WOFileUtils.create_symlink(self, ["/etc/php5/mods-available/" "xdebug.ini", "/etc/php5/fpm/conf.d" "/20-xedbug.ini"]) Log.info(self, "Successfully upgraded from PHP 5.5 to PHP 5.6")