Merge pull request #567 from WordOps/updating-configuration

Various fixes
This commit is contained in:
VirtuBox
2023-08-27 13:29:14 +02:00
committed by GitHub
5 changed files with 316 additions and 49 deletions

View File

@@ -68,7 +68,41 @@ for site in $site_types; do
fi fi
done done
echo echo
echo
echo -e "${CGREEN}#############################################${CEND}" echo -e "${CGREEN}#############################################${CEND}"
echo -e ' Proxy site create '
echo -e "${CGREEN}#############################################${CEND}"
echo
if {
wo site create proxy.net --proxy=127.0.0.1:3000
} >>/var/log/wo/test.log; then
echo -ne " Creating proxy.net [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
echo -e " Creating proxy.net [${CRED}FAIL${CEND}]"
echo -ne '\n'
exit_script
fi
echo
echo
echo
echo -e "${CGREEN}#############################################${CEND}"
echo -e ' Alias site create '
echo -e "${CGREEN}#############################################${CEND}"
echo
if {
wo site create alias.net --alias anothersite.net
} >>/var/log/wo/test.log; then
echo -ne " Creating alias.net [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
echo -e " Creating alias.net [${CRED}FAIL${CEND}]"
echo -ne '\n'
exit_script
fi
echo
echo -e "${CGREEN}#############################################${CEND}"
echo
echo echo
wo site info php.net wo site info php.net
echo echo
@@ -300,18 +334,18 @@ echo -e "${CGREEN}#############################################${CEND}"
echo -e ' wo stack migrate --mariadb ' echo -e ' wo stack migrate --mariadb '
echo -e "${CGREEN}#############################################${CEND}" echo -e "${CGREEN}#############################################${CEND}"
echo -ne " Upgrading mariadb [..]\r" echo -ne " Upgrading mariadb [..]\r"
if { if {
wo stack migrate --mariadb --force --ci wo stack migrate --mariadb --force --ci
} >>/var/log/wo/test.log; then } >>/var/log/wo/test.log; then
echo -ne " Upgrading mariadb [${CGREEN}OK${CEND}]\\r" echo -ne " Upgrading mariadb [${CGREEN}OK${CEND}]\\r"
echo -ne '\n' echo -ne '\n'
else else
echo -e " Upgrading mariadb [${CRED}FAIL${CEND}]" echo -e " Upgrading mariadb [${CRED}FAIL${CEND}]"
echo -ne '\n' echo -ne '\n'
exit_script exit_script
fi fi
echo -e "${CGREEN}#############################################${CEND}" echo -e "${CGREEN}#############################################${CEND}"
echo -e ' wo clean ' echo -e ' wo clean '

View File

@@ -1076,39 +1076,268 @@ def detSitePar(opts):
2. raises RuntimeError when wrong combination is used like 2. raises RuntimeError when wrong combination is used like
"--wp --wpsubdir" or "--html --wp" "--wp --wpsubdir" or "--html --wp"
""" """
# Initialize sitetype and cachetype
sitetype, cachetype = '', '' sitetype, cachetype = '', ''
# Initialize type and cache lists
typelist = list() typelist = list()
cachelist = list() cachelist = list()
# Populate type and cache lists based on opts
for key, val in opts.items(): for key, val in opts.items():
if val and key in ['html', 'php', 'mysql', 'wp', if val and key in ['html', 'php', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain', 'wpsubdir', 'wpsubdomain', 'php72',
'php72', 'php73', 'php74', 'php73', 'php74', 'php80', 'php81', 'php82', ]:
'php80', 'php81', 'php82']:
typelist.append(key) typelist.append(key)
elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']: elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']:
cachelist.append(key) cachelist.append(key)
# Determine sitetype and cachetype
if len(typelist) > 1 or len(cachelist) > 1: if len(typelist) > 1 or len(cachelist) > 1:
raise RuntimeError( if len(cachelist) > 1:
"Could not determine site or cache type. " raise RuntimeError(
"Multiple types or caches entered.") "Could not determine cache type."
"Multiple cache parameter entered")
# If no type or cache specified, set to None elif False not in [x in ('php', 'mysql', 'html') for x in typelist]:
if not typelist and not cachelist: sitetype = 'mysql'
sitetype = None if not cachelist:
cachetype = None cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php72', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php73', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php74', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php80', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php81', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php82', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php72', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php73', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php74', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php80', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php81', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php82', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('html', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php', 'html') for x in typelist]:
sitetype = 'php'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'wpsubdir') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'wpsubdomain') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php72') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php73') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php74') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php80') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php81') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php82') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php72') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php73') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php74') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php80') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php81') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php82') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php72') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php73') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php74') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php80') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php81') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php82') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
else:
raise RuntimeError("could not determine site and cache type")
else: else:
# Use the first specified type or 'wp' if not specified if not typelist and not cachelist:
sitetype = typelist[0] if typelist else 'wp' sitetype = None
cachetype = None
# Use the first specified cache or 'basic' if not specified elif (not typelist or "php72" in typelist) and cachelist:
cachetype = cachelist[0] if cachelist else 'basic' sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php73" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php74" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php80" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php81" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php82" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif typelist and (not cachelist):
sitetype = typelist[0]
cachetype = 'basic'
else:
sitetype = typelist[0]
cachetype = cachelist[0]
return (sitetype, cachetype) return (sitetype, cachetype)

View File

@@ -119,13 +119,6 @@ class WOStackController(CementBaseController):
pargs.admin = True pargs.admin = True
pargs.fail2ban = True pargs.fail2ban = True
if pargs.php:
if self.app.config.has_section('php'):
config_php_ver = self.app.config.get(
'php', 'version')
current_php = config_php_ver.replace(".", "")
setattr(self.app.pargs, 'php{0}'.format(current_php), True)
if pargs.mariadb: if pargs.mariadb:
pargs.mysql = True pargs.mysql = True
@@ -165,6 +158,13 @@ class WOStackController(CementBaseController):
pargs.clamav = True pargs.clamav = True
pargs.ngxblocker = True pargs.ngxblocker = True
if pargs.php:
if self.app.config.has_section('php'):
config_php_ver = self.app.config.get(
'php', 'version')
current_php = config_php_ver.replace(".", "")
setattr(self.app.pargs, 'php{0}'.format(current_php), True)
# Nginx # Nginx
if pargs.nginx: if pargs.nginx:
Log.debug(self, "Setting apt_packages variable for Nginx") Log.debug(self, "Setting apt_packages variable for Nginx")

View File

@@ -154,7 +154,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
if (apt_packages): if (apt_packages):
# Nginx configuration # Nginx configuration
if set(WOVar.wo_nginx).issubset(set(apt_packages)): if set(WOVar.wo_nginx).issubset(set(apt_packages)):
Log.info(self, "Applying Nginx configuration templates") Log.wait(self, "Configuring Nginx")
# Nginx main configuration # Nginx main configuration
ngxcnf = '/etc/nginx/conf.d' ngxcnf = '/etc/nginx/conf.d'
ngxcom = '/etc/nginx/common' ngxcom = '/etc/nginx/common'
@@ -458,6 +458,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"Use the command nginx -t to identify " "Use the command nginx -t to identify "
"the cause of this issue", False) "the cause of this issue", False)
else: else:
Log.valide(self, "Configuring Nginx")
WOGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") WOGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git")
if not os.path.isdir('/etc/systemd/system/nginx.service.d'): if not os.path.isdir('/etc/systemd/system/nginx.service.d'):
WOFileUtils.mkdir(self, WOFileUtils.mkdir(self,
@@ -474,13 +475,13 @@ def post_pref(self, apt_packages, packages, upgrade=False):
# php conf # php conf
php_list = [] php_list = []
for version in list(WOVar.wo_php_versions.values()): for version in list(WOVar.wo_php_versions.values()):
package_name = 'php' + version.replace('.', '') + '-fpm' package_name = 'php' + version + '-fpm'
if package_name in apt_packages: if package_name in apt_packages:
php_list.append([version]) php_list.append([version])
for php_version in php_list: for php_version in php_list:
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
Log.info(self, "Configuring php{0}-fpm".format(php_version[0])) Log.wait(self, "Configuring php{0}-fpm".format(php_version[0]))
ngxroot = '/var/www/' ngxroot = '/var/www/'
# Create log directories # Create log directories
@@ -653,6 +654,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
.format(php_version[0])): .format(php_version[0])):
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
else: else:
Log.valide(self, "Configuring php{0}-fpm".format(php_version[0]))
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
if os.path.exists('/etc/nginx/conf.d/upstream.conf'): if os.path.exists('/etc/nginx/conf.d/upstream.conf'):
@@ -791,7 +793,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
if os.path.exists('/etc/fail2ban'): if os.path.exists('/etc/fail2ban'):
WOGit.add(self, ["/etc/fail2ban"], WOGit.add(self, ["/etc/fail2ban"],
msg="Adding Fail2ban into Git") msg="Adding Fail2ban into Git")
Log.info(self, "Configuring Fail2Ban") Log.wait(self, "Configuring Fail2Ban")
nginxf2b = bool(os.path.exists('/var/log/nginx')) nginxf2b = bool(os.path.exists('/var/log/nginx'))
data = dict(release=WOVar.wo_version, nginx=nginxf2b) data = dict(release=WOVar.wo_version, nginx=nginxf2b)
WOTemplate.deploy( WOTemplate.deploy(
@@ -815,6 +817,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
self, ['/etc/fail2ban'], msg="Rollback f2b config") self, ['/etc/fail2ban'], msg="Rollback f2b config")
WOService.restart_service(self, 'fail2ban') WOService.restart_service(self, 'fail2ban')
else: else:
Log.valide(self, "Configuring Fail2Ban")
WOGit.add(self, ["/etc/fail2ban"], WOGit.add(self, ["/etc/fail2ban"],
msg="Adding Fail2ban into Git") msg="Adding Fail2ban into Git")
@@ -1175,10 +1178,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
'SEND_EMAIL="YES"', 'SEND_EMAIL="YES"',
'SEND_EMAIL="NO"') 'SEND_EMAIL="NO"')
WOFileUtils.searchreplace( if os.path.isdir('/etc/netdata/orig/health_alarm_notify.conf'):
self, "{0}etc/netdata/orig/health_alarm_notify.conf", WOFileUtils.searchreplace(
'SEND_EMAIL="YES"', self, "/etc/netdata/orig/health_alarm_notify.conf",
'SEND_EMAIL="NO"') 'SEND_EMAIL="YES"',
'SEND_EMAIL="NO"')
# check if mysql credentials are available # check if mysql credentials are available
if WOShellExec.cmd_exec(self, "mysqladmin ping"): if WOShellExec.cmd_exec(self, "mysqladmin ping"):
try: try:

View File

@@ -73,7 +73,7 @@ Group nogroup
# Umask 022 is a good standard umask to prevent new files and dirs # Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable. # (second parm) from being group and world writable.
Umask 022 022 Umask 002 002
# Normally, we want files to be overwriteable. # Normally, we want files to be overwriteable.
AllowOverwrite on AllowOverwrite on