Several new features
- cht.sh stack : linux online cheatsheet. Usage : `cheat <command>`. Example for tar : `cheat tar` - ClamAV anti-virus with weekly cronjob to update signatures database - Internal function to add daily cronjobs - Additional comment to detect previous configuration tuning (MariaDB & Redis) - Domain/Subdomain detection based on public domain suffixes list - Increase Nginx & MariaDB systemd open_files limits - Cronjob to update Cloudflare IPs list
This commit is contained in:
@@ -21,6 +21,20 @@ class WOCron():
|
||||
"\\\"; } | crontab -\"")
|
||||
Log.debug(self, "Cron set")
|
||||
|
||||
def setcron_daily(self, cmd, comment='Cron set by WordOps', user='root',
|
||||
min=0, hour=12):
|
||||
if not WOShellExec.cmd_exec(self, "crontab -l "
|
||||
"| grep -q \'{0}\'".format(cmd)):
|
||||
|
||||
WOShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
|
||||
"2> /dev/null | {{ cat; echo -e"
|
||||
" \\\""
|
||||
"\\n@daily"
|
||||
"{0}".format(cmd) +
|
||||
" # {0}".format(comment) +
|
||||
"\\\"; } | crontab -\"")
|
||||
Log.debug(self, "Cron set")
|
||||
|
||||
def remove_cron(self, cmd):
|
||||
if WOShellExec.cmd_exec(self, "crontab -l "
|
||||
"| grep -q \'{0}\'".format(cmd)):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""WordOps domain validation module."""
|
||||
from urllib.parse import urlparse
|
||||
import os
|
||||
|
||||
|
||||
def ValidateDomain(url):
|
||||
@@ -22,3 +23,29 @@ def ValidateDomain(url):
|
||||
final_domain = domain_name
|
||||
|
||||
return (final_domain, domain_name)
|
||||
|
||||
|
||||
def GetDomainlevel(domain):
|
||||
"""
|
||||
This function returns the domain type : domain, subdomain,
|
||||
"""
|
||||
domain_name = domain.split('.')
|
||||
if domain_name[0] == 'www':
|
||||
domain_name = domain_name[1:]
|
||||
if os.path.isfile("/var/lib/wo/public_suffix_list.dat"):
|
||||
# Read mode opens a file for reading only.
|
||||
Suffix_file = open(
|
||||
"/var/lib/wo/public_suffix_list.dat", "r")
|
||||
# Read all the lines into a list.
|
||||
for domain_suffix in Suffix_file:
|
||||
if (str(domain_suffix).strip()) == ('.'.join(testing_domain[1:])):
|
||||
domain_type = 'domain'
|
||||
break
|
||||
elif (str(domain_suffix).strip()) == ('.'.join(testing_domain[2:]):
|
||||
domain_type='subdomain'
|
||||
break
|
||||
else:
|
||||
domain_type='other'
|
||||
Suffix_file.close()
|
||||
|
||||
return (domain_type)
|
||||
|
||||
@@ -17,8 +17,12 @@ class WOService():
|
||||
"""
|
||||
try:
|
||||
if service_name in ['nginx', 'php5-fpm']:
|
||||
service_cmd = ('{0} -t && service {0} start'
|
||||
.format(service_name))
|
||||
# Check Nginx configuration before executing command
|
||||
sub = subprocess.Popen('nginx -t', stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output, error_output = sub.communicate()
|
||||
if 'emerg' not in str(error_output):
|
||||
service_cmd = ('service {0} start'.format(service_name))
|
||||
else:
|
||||
service_cmd = ('service {0} start'.format(service_name))
|
||||
|
||||
@@ -64,8 +68,12 @@ class WOService():
|
||||
"""
|
||||
try:
|
||||
if service_name in ['nginx', 'php5-fpm']:
|
||||
service_cmd = ('{0} -t && service {0} restart'
|
||||
.format(service_name))
|
||||
# Check Nginx configuration before executing command
|
||||
sub = subprocess.Popen('nginx -t', stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output, error_output = sub.communicate()
|
||||
if 'emerg' not in str(error_output):
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
else:
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
|
||||
@@ -90,8 +98,12 @@ class WOService():
|
||||
"""
|
||||
try:
|
||||
if service_name in ['nginx', 'php5-fpm']:
|
||||
service_cmd = ('{0} -t && service {0} reload'
|
||||
.format(service_name))
|
||||
# Check Nginx configuration before executing command
|
||||
sub = subprocess.Popen('nginx -t', stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output, error_output = sub.communicate()
|
||||
if 'emerg' not in str(error_output):
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
else:
|
||||
service_cmd = ('service {0} reload'.format(service_name))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user