Update main.py according to cement docs
This commit is contained in:
9
install
9
install
@@ -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"
|
||||||
|
|||||||
@@ -79,56 +79,55 @@ 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():
|
||||||
try:
|
with WOApp() as app:
|
||||||
global sys
|
try:
|
||||||
# Default our exit status to 0 (non-error)
|
global sys
|
||||||
code = 0
|
# Default our exit status to 0 (non-error)
|
||||||
|
code = 0
|
||||||
|
|
||||||
# if not root...kick out
|
# if not root...kick out
|
||||||
if not os.geteuid() == 0:
|
if not os.geteuid() == 0:
|
||||||
print("\nNon-privileged users cant use WordOps. "
|
print("\nNon-privileged users cant use WordOps. "
|
||||||
"Switch to root or invoke sudo.\n")
|
"Switch to root or invoke sudo.\n")
|
||||||
app.close(1)
|
app.close(1)
|
||||||
|
|
||||||
# Setup the application
|
# Setup the application
|
||||||
app.setup()
|
app.setup()
|
||||||
|
|
||||||
# Dump all arguments into wo log
|
# Dump all arguments into wo log
|
||||||
app.log.debug(sys.argv)
|
app.log.debug(sys.argv)
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
app.run()
|
app.run()
|
||||||
except exc.WOError as e:
|
except exc.WOError as e:
|
||||||
# Catch our application errors and exit 1 (error)
|
# Catch our application errors and exit 1 (error)
|
||||||
code = 1
|
code = 1
|
||||||
print(e)
|
print(e)
|
||||||
except FrameworkError as e:
|
except FrameworkError as e:
|
||||||
# Catch framework errors and exit 1 (error)
|
# Catch framework errors and exit 1 (error)
|
||||||
code = 1
|
code = 1
|
||||||
print(e)
|
print(e)
|
||||||
except CaughtSignal as e:
|
except CaughtSignal as e:
|
||||||
# Default Cement signals are SIGINT and SIGTERM, exit 0 (non-error)
|
# Default Cement signals are SIGINT and SIGTERM, exit 0 (non-error)
|
||||||
code = 0
|
code = 0
|
||||||
print(e)
|
print(e)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
code = 1
|
code = 1
|
||||||
print(e)
|
print(e)
|
||||||
finally:
|
finally:
|
||||||
# Print an exception (if it occurred) and --debug was passed
|
# Print an exception (if it occurred) and --debug was passed
|
||||||
if app.debug:
|
if app.debug:
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
if exc_traceback is not None:
|
if exc_traceback is not None:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
# # Close the application
|
# # Close the application
|
||||||
app.close(code)
|
app.close(code)
|
||||||
|
|
||||||
|
|
||||||
def get_test_app(**kw):
|
def get_test_app(**kw):
|
||||||
|
|||||||
@@ -780,22 +780,22 @@ 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(
|
||||||
"= /tmp/ \nphp_admin_value[xdebug.profiler_"
|
"php_admin_value[xdebug.profiler_output_dir] "
|
||||||
"output_name] = cachegrind.out.%p-%H-%R "
|
"= /tmp/ \nphp_admin_value[xdebug.profiler_"
|
||||||
"\nphp_admin_flag[xdebug.profiler_enable"
|
"output_name] = cachegrind.out.%p-%H-%R "
|
||||||
"_trigger] = on \nphp_admin_flag[xdebug."
|
"\nphp_admin_flag[xdebug.profiler_enable"
|
||||||
"profiler_enable] = off\n")
|
"_trigger] = on \nphp_admin_flag[xdebug."
|
||||||
|
"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,20 +892,21 @@ 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(
|
||||||
'/etc/fail2ban/jail.d/custom.conf',
|
self,
|
||||||
'fail2ban.mustache',
|
'/etc/fail2ban/jail.d/custom.conf',
|
||||||
data, overwrite=False)
|
'fail2ban.mustache',
|
||||||
WOTemplate.render(self,
|
data, overwrite=False)
|
||||||
'/etc/fail2ban/filter.d/'
|
WOTemplate.render(
|
||||||
'wo-wordpress.conf',
|
self,
|
||||||
'fail2ban-wp.mustache',
|
'/etc/fail2ban/filter.d/wo-wordpress.conf',
|
||||||
data, overwrite=False)
|
'fail2ban-wp.mustache',
|
||||||
WOTemplate.render(self,
|
data, overwrite=False)
|
||||||
'/etc/fail2ban/filter.d/'
|
WOTemplate.render(
|
||||||
'nginx-forbidden.conf',
|
self,
|
||||||
'fail2ban-forbidden.mustache',
|
'/etc/fail2ban/filter.d/nginx-forbidden.conf',
|
||||||
data, overwrite=False)
|
'fail2ban-forbidden.mustache',
|
||||||
|
data, overwrite=False)
|
||||||
|
|
||||||
WOGit.add(self, ["/etc/fail2ban"],
|
WOGit.add(self, ["/etc/fail2ban"],
|
||||||
msg="Adding Fail2ban into Git")
|
msg="Adding Fail2ban into Git")
|
||||||
@@ -916,22 +917,18 @@ 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/"
|
"# PassivePorts "
|
||||||
"proftpd.conf",
|
"49152 65534",
|
||||||
"# PassivePorts "
|
"PassivePorts "
|
||||||
" "
|
" 49000 50000")
|
||||||
"49152 65534",
|
|
||||||
"PassivePorts "
|
|
||||||
" "
|
|
||||||
" 49000 50000")
|
|
||||||
# proftpd TLS configuration
|
# proftpd TLS configuration
|
||||||
if not os.path.isdir("/etc/proftpd/ssl"):
|
if not os.path.isdir("/etc/proftpd/ssl"):
|
||||||
WOFileUtils.mkdir(self, "/etc/proftpd/ssl")
|
WOFileUtils.mkdir(self, "/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\''
|
||||||
|
|||||||
Reference in New Issue
Block a user