def update_if_needed(self): old = self.get_installed_version() new = self.get_updated_version() if version.first_is_higher(new, old): self.versions = version.get_tree(new) return build() return False, False
def get_status_array(): """ Get the status output for each enabled version of PHP. Return: A two-dimensional array where each child element contains the following: A php version number The status output for the assicated PHP version """ statuses = [] for ver in get_versions(): subversion = version.get_tree(ver)['sub'] #status = subprocess.getoutput("service php-" + subversion + "-fpm status | grep '\s*[Aa]ctive:\s' | sed -E 's/\s*[Aa]ctive:\s//'") status = service.status("php-" + subversion + "-fpm") statuses.append([subversion, status]) return statuses
def writepignore(): from libsw import php, version import os if not os.path.exists('/etc/csf/'): # CSF is not installed, skip return False ignore = "# Do not edit this section\n" ignore += """exe:/bin/bash exe:/lib/systemd/systemd exe:/usr/sbin/uuidd exe:/usr/bin/memcached exe:/usr/bin/screen exe:/usr/lib/dovecot/anvil exe:/usr/lib/dovecot/imap exe:/usr/lib/dovecot/imap-login exe:/usr/lib/dovecot/auth exe:/usr/sbin/atd exe:/usr/sbin/rsyslogd exe:/usr/lib/openssh/sftp-server exe:/bin/nano exe:/usr/bin/vi exe:/usr/bin/vim exe:/usr/bin/emacs exe:/usr/bin/less exe:/bin/less exe:/usr/bin/spamc exe:/usr/bin/spamd cmd:spamd child exe:/usr/bin/freshclam exe:/usr/sbin/clamd exe:/usr/local/nginx/sbin/nginx exe:/usr/local/nginx/sbin/nginx.old """ for ver in php.get_versions(): ver = version.get_tree(ver)['sub'] ignore += "exe:/opt/php-" + ver + "/sbin/php-fpm\n" start_text = '# Start Site Wrangler Rules' end_text = '# End Site Wrangler Rules' filename = '/etc/csf/csf.pignore' success = file_filter.UpdateSection(filename, start_text, end_text, ignore).run() return success
def __init__(self, version_str): self.versions = version.get_tree(version_str) if self.versions['sub'] == self.versions['full']: self.versions = version.get_tree(self.get_updated_version()) super().__init__('php-' + self.versions['sub'])
def is_same_subversion(versions, version_string): """Determine if two versions have the same first two numbers.""" ver2 = version.get_tree(version_string) return versions['sub'] == ver2['sub']