diff --git a/tests/travis.sh b/tests/travis.sh index 24155f9..99902f5 100644 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -68,7 +68,41 @@ for site in $site_types; do fi done echo +echo 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 wo site info php.net echo @@ -300,18 +334,18 @@ echo -e "${CGREEN}#############################################${CEND}" echo -e ' wo stack migrate --mariadb ' echo -e "${CGREEN}#############################################${CEND}" - echo -ne " Upgrading mariadb [..]\r" - if { - wo stack migrate --mariadb --force --ci - } >>/var/log/wo/test.log; then - echo -ne " Upgrading mariadb [${CGREEN}OK${CEND}]\\r" - echo -ne '\n' - else - echo -e " Upgrading mariadb [${CRED}FAIL${CEND}]" - echo -ne '\n' - exit_script +echo -ne " Upgrading mariadb [..]\r" +if { + wo stack migrate --mariadb --force --ci +} >>/var/log/wo/test.log; then + echo -ne " Upgrading mariadb [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' +else + echo -e " Upgrading mariadb [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script - fi +fi echo -e "${CGREEN}#############################################${CEND}" echo -e ' wo clean ' diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 893f776..7af1f50 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -1076,39 +1076,268 @@ def detSitePar(opts): 2. raises RuntimeError when wrong combination is used like "--wp --wpsubdir" or "--html --wp" """ - # Initialize sitetype and cachetype sitetype, cachetype = '', '' - - # Initialize type and cache lists typelist = list() cachelist = list() - - # Populate type and cache lists based on opts for key, val in opts.items(): if val and key in ['html', 'php', 'mysql', 'wp', - 'wpsubdir', 'wpsubdomain', - 'php72', 'php73', 'php74', - 'php80', 'php81', 'php82']: + 'wpsubdir', 'wpsubdomain', 'php72', + 'php73', 'php74', 'php80', 'php81', 'php82', ]: typelist.append(key) elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']: cachelist.append(key) - # Determine sitetype and cachetype if len(typelist) > 1 or len(cachelist) > 1: - raise RuntimeError( - "Could not determine site or cache type. " - "Multiple types or caches entered.") - - # If no type or cache specified, set to None - if not typelist and not cachelist: - sitetype = None - cachetype = None + if len(cachelist) > 1: + raise RuntimeError( + "Could not determine cache type." + "Multiple cache parameter entered") + elif False not in [x in ('php', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + 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: - # Use the first specified type or 'wp' if not specified - sitetype = typelist[0] if typelist else 'wp' - - # Use the first specified cache or 'basic' if not specified - cachetype = cachelist[0] if cachelist else 'basic' + if not typelist and not cachelist: + sitetype = None + cachetype = None + elif (not typelist or "php72" in typelist) and cachelist: + 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) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 77fe1d3..6fd38b1 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -119,13 +119,6 @@ class WOStackController(CementBaseController): pargs.admin = 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: pargs.mysql = True @@ -165,6 +158,13 @@ class WOStackController(CementBaseController): pargs.clamav = 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 if pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index b49b3fe..531770f 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -154,7 +154,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): if (apt_packages): # Nginx configuration if set(WOVar.wo_nginx).issubset(set(apt_packages)): - Log.info(self, "Applying Nginx configuration templates") + Log.wait(self, "Configuring Nginx") # Nginx main configuration ngxcnf = '/etc/nginx/conf.d' ngxcom = '/etc/nginx/common' @@ -458,6 +458,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): "Use the command nginx -t to identify " "the cause of this issue", False) else: + Log.valide(self, "Configuring Nginx") WOGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") if not os.path.isdir('/etc/systemd/system/nginx.service.d'): WOFileUtils.mkdir(self, @@ -474,13 +475,13 @@ def post_pref(self, apt_packages, packages, upgrade=False): # php conf php_list = [] 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: php_list.append([version]) for php_version in php_list: 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/' # Create log directories @@ -653,6 +654,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): .format(php_version[0])): WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") else: + Log.valide(self, "Configuring php{0}-fpm".format(php_version[0])) WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") 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'): WOGit.add(self, ["/etc/fail2ban"], msg="Adding Fail2ban into Git") - Log.info(self, "Configuring Fail2Ban") + Log.wait(self, "Configuring Fail2Ban") nginxf2b = bool(os.path.exists('/var/log/nginx')) data = dict(release=WOVar.wo_version, nginx=nginxf2b) WOTemplate.deploy( @@ -815,6 +817,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): self, ['/etc/fail2ban'], msg="Rollback f2b config") WOService.restart_service(self, 'fail2ban') else: + Log.valide(self, "Configuring Fail2Ban") WOGit.add(self, ["/etc/fail2ban"], msg="Adding Fail2ban into Git") @@ -1175,10 +1178,11 @@ def post_pref(self, apt_packages, packages, upgrade=False): 'SEND_EMAIL="YES"', 'SEND_EMAIL="NO"') - WOFileUtils.searchreplace( - self, "{0}etc/netdata/orig/health_alarm_notify.conf", - 'SEND_EMAIL="YES"', - 'SEND_EMAIL="NO"') + if os.path.isdir('/etc/netdata/orig/health_alarm_notify.conf'): + WOFileUtils.searchreplace( + self, "/etc/netdata/orig/health_alarm_notify.conf", + 'SEND_EMAIL="YES"', + 'SEND_EMAIL="NO"') # check if mysql credentials are available if WOShellExec.cmd_exec(self, "mysqladmin ping"): try: diff --git a/wo/cli/templates/proftpd.mustache b/wo/cli/templates/proftpd.mustache index d708a69..7c36b8b 100644 --- a/wo/cli/templates/proftpd.mustache +++ b/wo/cli/templates/proftpd.mustache @@ -73,7 +73,7 @@ Group nogroup # Umask 022 is a good standard umask to prevent new files and dirs # (second parm) from being group and world writable. -Umask 022 022 +Umask 002 002 # Normally, we want files to be overwriteable. AllowOverwrite on