Update main.py according to cement docs

This commit is contained in:
VirtuBox
2019-09-15 14:47:58 +02:00
parent e444886c52
commit a70a45a484
3 changed files with 90 additions and 92 deletions

View File

@@ -9,7 +9,7 @@
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# wget -qO wo wops.cc && sudo bash wo # wget -qO wo wops.cc && sudo bash wo
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Version 3.9.8.10 - 2019-09-04 # Version 3.9.8.11 - 2019-09-07
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# CONTENTS # CONTENTS
@@ -541,6 +541,7 @@ wo_upgrade_nginx() {
sed -i "s/locations-php73.conf/locations-wo.conf/" /etc/nginx/sites-available/* sed -i "s/locations-php73.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/php.conf/php72.conf/" /etc/nginx/sites-available/* sed -i "s/php.conf/php72.conf/" /etc/nginx/sites-available/*
sed -i "s/php7.conf/php72.conf/" /etc/nginx/sites-available/* sed -i "s/php7.conf/php72.conf/" /etc/nginx/sites-available/*
sed -i "s/php7.conf/php72.conf/" /etc/nginx/sites-available/*
sed -i 's/ssl on;/#ssl on;/' /var/www/*/conf/nginx/ssl.conf sed -i 's/ssl on;/#ssl on;/' /var/www/*/conf/nginx/ssl.conf
# update redis.conf headers # update redis.conf headers
@@ -970,10 +971,10 @@ else
elif [ "$wo_upgrade" = "1" ]; then elif [ "$wo_upgrade" = "1" ]; then
wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!" wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!"
echo echo
wo_lib_echo "To upgrade Nginx use the command:" wo_lib_echo "To upgrade WordOps stacks use the command:"
wo_lib_echo_info "wo stack upgrade --nginx" wo_lib_echo_info "wo stack upgrade --all"
echo echo
wo_lib_echo "To update other packages use the command:" wo_lib_echo "To update all other server packages use the command:"
wo_lib_echo_info "wo maintenance" wo_lib_echo_info "wo maintenance"
else else
wo_lib_echo "WordOps (wo) installed successfully" wo_lib_echo "WordOps (wo) installed successfully"

View File

@@ -79,10 +79,9 @@ class WOTestApp(WOApp):
# Define the applicaiton object outside of main, as some libraries might wish # Define the applicaiton object outside of main, as some libraries might wish
# to import it as a global (rather than passing it into another class/func) # to import it as a global (rather than passing it into another class/func)
app = WOApp()
def main(): def main():
with WOApp() as app:
try: try:
global sys global sys
# Default our exit status to 0 (non-error) # Default our exit status to 0 (non-error)

View File

@@ -780,7 +780,8 @@ def post_pref(self, apt_packages, packages, upgrade=False):
with open("/etc/php/7.3/fpm/pool.d/debug.conf", with open("/etc/php/7.3/fpm/pool.d/debug.conf",
encoding='utf-8', mode='a') as myfile: encoding='utf-8', mode='a') as myfile:
myfile.write("php_admin_value[xdebug.profiler_output_dir] " myfile.write(
"php_admin_value[xdebug.profiler_output_dir] "
"= /tmp/ \nphp_admin_value[xdebug.profiler_" "= /tmp/ \nphp_admin_value[xdebug.profiler_"
"output_name] = cachegrind.out.%p-%H-%R " "output_name] = cachegrind.out.%p-%H-%R "
"\nphp_admin_flag[xdebug.profiler_enable" "\nphp_admin_flag[xdebug.profiler_enable"
@@ -788,14 +789,13 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"profiler_enable] = off\n") "profiler_enable] = off\n")
# Disable xdebug # Disable xdebug
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'" if not WOShellExec.cmd_exec(
" /etc/php/7.3/mods-available" self, "grep -q \';zend_extension\'"
"/xdebug.ini"): " /etc/php/7.3/mods-available/xdebug.ini"):
WOFileUtils.searchreplace(self, "/etc/php/7.3/" WOFileUtils.searchreplace(
"mods-available/" self, "/etc/php/7.3/mods-available/"
"xdebug.ini", "xdebug.ini",
"zend_extension", "zend_extension", ";zend_extension")
";zend_extension")
# PHP and Debug pull configuration # PHP and Debug pull configuration
if not os.path.exists('{0}22222/htdocs/fpm/status/' if not os.path.exists('{0}22222/htdocs/fpm/status/'
@@ -892,18 +892,19 @@ def post_pref(self, apt_packages, packages, upgrade=False):
if not os.path.isfile("/etc/fail2ban/jail.d/custom.conf"): if not os.path.isfile("/etc/fail2ban/jail.d/custom.conf"):
Log.info(self, "Configuring Fail2Ban") Log.info(self, "Configuring Fail2Ban")
data = dict() data = dict()
WOTemplate.render(self, WOTemplate.render(
self,
'/etc/fail2ban/jail.d/custom.conf', '/etc/fail2ban/jail.d/custom.conf',
'fail2ban.mustache', 'fail2ban.mustache',
data, overwrite=False) data, overwrite=False)
WOTemplate.render(self, WOTemplate.render(
'/etc/fail2ban/filter.d/' self,
'wo-wordpress.conf', '/etc/fail2ban/filter.d/wo-wordpress.conf',
'fail2ban-wp.mustache', 'fail2ban-wp.mustache',
data, overwrite=False) data, overwrite=False)
WOTemplate.render(self, WOTemplate.render(
'/etc/fail2ban/filter.d/' self,
'nginx-forbidden.conf', '/etc/fail2ban/filter.d/nginx-forbidden.conf',
'fail2ban-forbidden.mustache', 'fail2ban-forbidden.mustache',
data, overwrite=False) data, overwrite=False)
@@ -916,21 +917,17 @@ def post_pref(self, apt_packages, packages, upgrade=False):
if os.path.isfile("/etc/proftpd/proftpd.conf"): if os.path.isfile("/etc/proftpd/proftpd.conf"):
Log.info(self, "Configuring ProFTPd") Log.info(self, "Configuring ProFTPd")
Log.debug(self, "Setting up Proftpd configuration") Log.debug(self, "Setting up Proftpd configuration")
WOFileUtils.searchreplace(self, "/etc/proftpd/" WOFileUtils.searchreplace(
"proftpd.conf", self, "/etc/proftpd/proftpd.conf",
"# DefaultRoot", "# DefaultRoot", "DefaultRoot")
"DefaultRoot") WOFileUtils.searchreplace(
WOFileUtils.searchreplace(self, "/etc/proftpd/" self, "/etc/proftpd/proftpd.conf",
"proftpd.conf", "# RequireValidShell", "RequireValidShell")
"# RequireValidShell", WOFileUtils.searchreplace(
"RequireValidShell") self, "/etc/proftpd/proftpd.conf",
WOFileUtils.searchreplace(self, "/etc/proftpd/"
"proftpd.conf",
"# PassivePorts " "# PassivePorts "
" "
"49152 65534", "49152 65534",
"PassivePorts " "PassivePorts "
" "
" 49000 50000") " 49000 50000")
# proftpd TLS configuration # proftpd TLS configuration
if not os.path.isdir("/etc/proftpd/ssl"): if not os.path.isdir("/etc/proftpd/ssl"):
@@ -1361,9 +1358,10 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db'
'/anemometer/install.sql' '/anemometer/install.sql'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
except CommandExecutionError as e: except Exception as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
raise SiteError("Unable to import Anemometer database") Log.error(self, "failed to configure Anemometer",
exit=False)
WOMysql.execute(self, 'grant select on' WOMysql.execute(self, 'grant select on'
' *.* to \'anemometer\'' ' *.* to \'anemometer\''