diff --git a/CHANGELOG.md b/CHANGELOG.md index 12876bf..99250b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### v3.9.x - [Unreleased] +### v3.9.8.7 - 2019-08-31 + +#### Changed + +- WordPress default permalinks structure from `/%year%/%monthnum%/%day%/%postname%/` -> `/%postname%/` + +#### Fixed + +- Error with `wo stack upgrade --nginx` +- Install/update script version check +- clamAV stack install + ### v3.9.8.6 - 2019-08-30 #### Added diff --git a/install b/install index f34f842..438411d 100755 --- a/install +++ b/install @@ -811,11 +811,11 @@ if [ "$wo_purge" = "y" ]; then else # 1 - WO already installed if [ -x /usr/local/bin/wo ]; then - if { - wo -v 2>&1 | grep -q "$wo_version_new" - } && [ -z "$wo_force_install" ]; then - wo_lib_error "You already have WordOps $wo_version_new" - exit 1 + if [ -z "$wo_force_install" ]; then + if { wo -v 2>&1 | grep -q "$wo_version_new"; }; then + wo_lib_error "You already have WordOps $wo_version_new" + exit 1 + fi fi wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log wo_install_dep | tee -ai $wo_install_log @@ -960,7 +960,7 @@ else wo_lib_echo_info "wo stack upgrade --nginx" echo wo_lib_echo "To update other packages use the command:" - wo_lib_echo_info "wo stack maintenance" + wo_lib_echo_info "wo maintenance" else wo_lib_echo "WordOps (wo) installed successfully" echo diff --git a/setup.py b/setup.py index 5f3cbd1..30aeadf 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ if not os.path.isfile('/root/.gitconfig'): shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig') setup(name='wo', - version='3.9.8.6', + version='3.9.8.7', description=long_description, long_description=long_description, classifiers=[], diff --git a/tests/travis.sh b/tests/travis.sh index 4e77573..74806d1 100644 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -3,43 +3,118 @@ # WordOps travis testing script # # +# Colors CSI='\033[' -CEND="${CSI}0m" +CRED="${CSI}1;31m" CGREEN="${CSI}1;32m" +CEND="${CSI}0m" exit_script() { tar -I pigz -cf wordops.tar.gz /var/log/wo - curl --progress-bar --upload-file wordops.tar.gz https://transfer.vtbox.net/$(basename "wordops.tar.gz") && echo "" | sudo tee -a $HOME/.transfer.log && echo "" + curl --progress-bar --upload-file wordops.tar.gz https://transfer.vtbox.net/"$(basename wordops.tar.gz)" && echo "" | sudo tee -a $HOME/.transfer.log && echo "" exit 1 } -if ! { - echo -e "${CGREEN}#############################################${CEND}" - echo -e ' stack install ' - echo -e "${CGREEN}#############################################${CEND}" - wo --help && wo stack install && wo stack install --proftpd -}; then - exit_script -fi -if ! { - echo -e "${CGREEN}#############################################${CEND}" - echo -e ' Simple site create ' - echo -e "${CGREEN}#############################################${CEND}" - wo site create html.net --html && wo site create php.com --php && wo site create mysql.com --mysql && wo site create proxy.com --proxy=127.0.0.1:3000 - wo site create wp1.com --wp && wo site create wpsc1.net --wpsc && wo site create wpfc1.com --wpfc - wo site create wpsc-php73.net --wpsc --php73 && wo site create wpfc-php73.net --wpfc --php73 - wo site create wprocket.net --wprocket && wo site create wprocket-php73.net --wprocket --php73 - wo site create wpce.net --wpce && wo site create wpce-php73.net --wpce --php73 - wo site create wpredis.net --wpredis && wo site create wpredis-php73.net --wpredis --php73 +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' stack install ' +echo -e "${CGREEN}#############################################${CEND}" +stack_list='nginx php php73 mysql redis fail2ban clamav proftpd admin' +for stack in $stack_list; do + echo -ne " Installing $stack [..]\r" + if { + wo stack install --${stack} + } >> /var/log/wo/test.log; then + echo -ne " Installing $stack [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' + else + echo -e " Installing $stack [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script + + fi +done + +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' Simple site create ' +echo -e "${CGREEN}#############################################${CEND}" +site_types='html php php73 mysql wp wpfc wpsc wpredis wpce wprocket wpsubdomain wpsubdir' +for site in $site_types; do + echo -ne " Creating $site [..]\r" + if { + wo site create ${site}.net --${site} + } >> /var/log/wo/test.log; then + echo -ne " Creating $site [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' + else + echo -e " Creating $site [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script + + fi +done +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' wo site update --php73 ' +echo -e "${CGREEN}#############################################${CEND}" +other_site_types='html mysql wp wpfc wpsc wpredis wpce wprocket wpsubdomain wpsubdir' +for site in $other_site_types; do + echo -ne " Updating site to $site php73 [..]\r" + if { + wo site update ${site}.net --php73 + } >> /var/log/wo/test.log; then + echo -ne " Updating site to $site php73 [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' + else + echo -e " Updating site to $site php73 [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script + + fi +done + +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' wo site update WP ' +echo -e "${CGREEN}#############################################${CEND}" + +wp_site_types='wpfc wpsc wpce wprocket wpredis' +wo site create wp.io --wp >> /dev/null 2>&1 +for site in $wp_site_types; do + echo -ne " Updating WP to $site [..]\r" + if { + wo site update wp.io --${site} + } >> /var/log/wo/test.log; then + echo -ne " Updating WP to $site [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' + else + echo -e " Updating WP to $site [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script + + fi +done + +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' wo stack upgrade ' +echo -e "${CGREEN}#############################################${CEND}" +stack_upgrade='nginx php mysql redis netdata dashboard phpmyadmin' +for stack in $stack_upgrade; do + echo -ne " Upgrading $stack [..]\r" + if { + wo stack upgrade --${stack} --force + } >> /var/log/wo/test.log; then + echo -ne " Upgrading $stack [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' + else + echo -e " Upgrading $stack [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script + + fi +done -}; then - exit_script -fi if ! { echo -e "${CGREEN}#############################################${CEND}" echo -e ' Multi-site create ' echo -e "${CGREEN}#############################################${CEND}" - wo site create wpsubdir1.com --wpsubdir && wo site create wpsubdir-php73.com --wpsubdir --php73 wo site create wpsubdirwpsc1.com --wpsubdir --wpsc && wo site create wpsubdirwpsc2.com --wpsubdir --wpfc && wo site create wpsubdirwpsc1-php73.com --wpsubdir --wpsc --php73 && wo site create wpsubdirwpsc2-php73.com --wpsubdir --wpfc --php73 wo site create wpsubdomain1.com --wpsubdomain && wo site create wpsubdomain1-php73.com --wpsubdomain --php73 && wo site create wpsubdomainwpsc.org --wpsubdomain --wpsc && wo site create wpsubdomainwpfc.org --wpsubdomain --wpfc && wo site create wpsubdomainwpfc2.in --wpfc --wpsubdomain echo -e "${CGREEN}#############################################${CEND}" @@ -51,19 +126,7 @@ if ! { }; then exit_script fi -if ! { - echo -e "${CGREEN}#############################################${CEND}" - echo -e ' wo stack upgrade ' - echo -e "${CGREEN}#############################################${CEND}" - wo stack upgrade --force - wo stack upgrade --php --force - wo stack upgrade --netdata --force - wo stack upgrade --phpmyadmin --force - wo stack upgrade --composer --force - wo stack upgrade --dashboard --force -}; then - exit_script -fi + echo -e "${CGREEN}#############################################${CEND}" echo -e ' various informations ' echo -e "${CGREEN}#############################################${CEND}" diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 1ecec76..201d37e 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -519,7 +519,7 @@ def setupwordpress(self, data, vhostonly=False): WOShellExec.cmd_exec(self, " {0} --allow-root " .format(WOVariables.wo_wpcli_path) + "rewrite structure " - "/%year%/%monthnum%/%day%/%postname%/") + "/%postname%/") except CommandExecutionError as e: Log.debug(self, str(e)) raise SiteError("Update wordpress permalinks failed") diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index c829708..17bd285 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -265,7 +265,7 @@ class WOStackController(CementBaseController): if pargs.clamav: Log.debug(self, "Setting apt_packages variable for ClamAV") if not WOAptGet.is_installed(self, 'clamav'): - apt_packages = apt_packages + ["clamav"] + apt_packages = apt_packages + WOVariables.wo_clamav else: Log.debug(self, "ClamAV already installed") Log.info(self, "ClamAV already installed") @@ -473,7 +473,7 @@ class WOStackController(CementBaseController): WOAptGet.install(self, apt_packages) post_pref(self, apt_packages, empty_packages) if (packages): - Log.debug(self, "Downloading following: {0}".format(packages)) + Log.info(self, "Downloading following: {0}".format(packages)) WODownload.download(self, packages) Log.debug(self, "Calling post_pref") post_pref(self, empty_packages, packages) @@ -587,7 +587,7 @@ class WOStackController(CementBaseController): if pargs.clamav: Log.debug(self, "Setting apt_packages variable for ClamAV") if WOAptGet.is_installed(self, 'clamav'): - apt_packages = apt_packages + ["clamav"] + apt_packages = apt_packages + WOVariables.wo_clamav # proftpd if pargs.proftpd: @@ -793,7 +793,7 @@ class WOStackController(CementBaseController): if pargs.clamav: Log.debug(self, "Setting apt_packages variable for ClamAV") if WOAptGet.is_installed(self, 'clamav'): - apt_packages = apt_packages + ["clamav"] + apt_packages = apt_packages + WOVariables.wo_clamav # proftpd if pargs.proftpd: diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index 9f5bc26..375c44d 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -330,16 +330,17 @@ def post_pref(self, apt_packages, packages, upgrade=False): "/redis.conf")): with open("/etc/nginx/conf.d/" "redis.conf", "a") as redis_file: - redis_file.write("# Log format Settings\n" - "log_format rt_cache_redis " - "'$remote_addr " - "$upstream_response_time " - "$srcache_fetch_status " - "[$time_local] '\n" - "'$http_host \"$request\" $status" - " $body_bytes_sent '\n" - "'\"$http_referer\" " - "\"$http_user_agent\"';\n") + redis_file.write( + "# Log format Settings\n" + "log_format rt_cache_redis " + "'$remote_addr " + "$upstream_response_time " + "$srcache_fetch_status " + "[$time_local] '\n" + "'$http_host \"$request\" $status" + " $body_bytes_sent '\n" + "'\"$http_referer\" " + "\"$http_user_agent\"';\n") # Nginx-Plus does not have nginx # package structure like this @@ -356,30 +357,34 @@ def post_pref(self, apt_packages, packages, upgrade=False): # 22222 port settings if not os.path.isfile('/etc/nginx/sites-available/22222'): - WOTemplate.render(self, - '/etc/nginx/sites-available/22222', - '22222.mustache', data, overwrite=False) + data = dict(webroot=ngxroot) + WOTemplate.render( + self, + '/etc/nginx/sites-available/22222', + '22222.mustache', data, overwrite=False) passwd = ''.join([random.choice (string.ascii_letters + string.digits) for n in range(24)]) try: - WOShellExec.cmd_exec(self, "printf \"WordOps:" - "$(openssl passwd -crypt " - "{password} 2> /dev/null)\n\"" - "> /etc/nginx/htpasswd-wo " - "2>/dev/null" - .format(password=passwd)) + WOShellExec.cmd_exec( + self, "printf \"WordOps:" + "$(openssl passwd -crypt " + "{password} 2> /dev/null)\n\"" + "> /etc/nginx/htpasswd-wo " + "2>/dev/null" + .format(password=passwd)) except CommandExecutionError as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Failed to save HTTP Auth") # Create Symbolic link for 22222 - WOFileUtils.create_symlink(self, ['/etc/nginx/' - 'sites-available/' - '22222', - '/etc/nginx/' - 'sites-enabled/' - '22222']) + WOFileUtils.create_symlink( + self, ['/etc/nginx/' + 'sites-available/' + '22222', + '/etc/nginx/' + 'sites-enabled/' + '22222']) # Create log and cert folder and softlinks if not os.path.exists('{0}22222/logs' .format(ngxroot)): @@ -405,51 +410,58 @@ def post_pref(self, apt_packages, packages, upgrade=False): os.makedirs('{0}22222/conf/nginx' .format(ngxroot)) - WOFileUtils.create_symlink(self, - ['/var/log/nginx/' - '22222.access.log', - '{0}22222/' - 'logs/access.log' - .format(ngxroot)] - ) + WOFileUtils.create_symlink( + self, + ['/var/log/nginx/' + '22222.access.log', + '{0}22222/' + 'logs/access.log' + .format(ngxroot)] + ) - WOFileUtils.create_symlink(self, - ['/var/log/nginx/' - '22222.error.log', - '{0}22222/' - 'logs/error.log' - .format(ngxroot)] - ) + WOFileUtils.create_symlink( + self, + ['/var/log/nginx/' + '22222.error.log', + '{0}22222/' + 'logs/error.log' + .format(ngxroot)] + ) try: - WOShellExec.cmd_exec(self, "openssl genrsa -out " - "{0}22222/cert/22222.key 2048" - .format(ngxroot)) - WOShellExec.cmd_exec(self, "openssl req -new -batch " - "-subj /commonName=localhost/ " - "-key {0}22222/cert/22222.key " - "-out {0}22222/cert/" - "22222.csr" - .format(ngxroot)) + WOShellExec.cmd_exec( + self, "openssl genrsa -out " + "{0}22222/cert/22222.key 2048" + .format(ngxroot)) + WOShellExec.cmd_exec( + self, "openssl req -new -batch " + "-subj /commonName=localhost/ " + "-key {0}22222/cert/22222.key " + "-out {0}22222/cert/" + "22222.csr" + .format(ngxroot)) - WOFileUtils.mvfile(self, "{0}22222/cert/22222.key" - .format(ngxroot), - "{0}22222/cert/" - "22222.key.org" - .format(ngxroot)) + WOFileUtils.mvfile( + self, "{0}22222/cert/22222.key" + .format(ngxroot), + "{0}22222/cert/" + "22222.key.org" + .format(ngxroot)) - WOShellExec.cmd_exec(self, "openssl rsa -in " - "{0}22222/cert/" - "22222.key.org -out " - "{0}22222/cert/22222.key" - .format(ngxroot)) + WOShellExec.cmd_exec( + self, "openssl rsa -in " + "{0}22222/cert/" + "22222.key.org -out " + "{0}22222/cert/22222.key" + .format(ngxroot)) - WOShellExec.cmd_exec(self, "openssl x509 -req -days " - "3652 -in {0}22222/cert/" - "22222.csr -signkey {0}" - "22222/cert/22222.key -out " - "{0}22222/cert/22222.crt" - .format(ngxroot)) + WOShellExec.cmd_exec( + self, "openssl x509 -req -days " + "3652 -in {0}22222/cert/" + "22222.csr -signkey {0}" + "22222/cert/22222.key -out " + "{0}22222/cert/22222.crt" + .format(ngxroot)) except CommandExecutionError as e: Log.debug(self, "{0}".format(e)) @@ -486,6 +498,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): WOVariables.wo_fqdn)]) if not os.path.isfile("/opt/cf-update.sh"): + data = dict() WOTemplate.render(self, '/opt/cf-update.sh', 'cf-update.mustache', data, overwrite=False) @@ -1079,100 +1092,102 @@ def post_pref(self, apt_packages, packages, upgrade=False): msg="Adding ProFTPd into Git") WOService.reload_service(self, 'proftpd') - # Redis configuration - if set(WOVariables.wo_redis).issubset(set(apt_packages)): - if os.path.isfile("/etc/nginx/conf.d/upstream.conf"): - if not WOFileUtils.grep(self, "/etc/nginx/conf.d/" - "upstream.conf", - "redis"): - with open("/etc/nginx/conf.d/upstream.conf", - "a") as redis_file: - redis_file.write("upstream redis {\n" - " server 127.0.0.1:6379;\n" - " keepalive 10;\n}\n") + # Redis configuration + if set(WOVariables.wo_redis).issubset(set(apt_packages)): + if os.path.isfile("/etc/nginx/conf.d/upstream.conf"): + if not WOFileUtils.grep(self, "/etc/nginx/conf.d/" + "upstream.conf", + "redis"): + with open("/etc/nginx/conf.d/upstream.conf", + "a") as redis_file: + redis_file.write("upstream redis {\n" + " server 127.0.0.1:6379;\n" + " keepalive 10;\n}\n") - if os.path.isfile("/etc/nginx/nginx.conf"): - if not os.path.isfile("/etc/nginx/conf.d/redis.conf"): - with open("/etc/nginx/conf.d/redis.conf", + if os.path.isfile("/etc/nginx/nginx.conf"): + if not os.path.isfile("/etc/nginx/conf.d/redis.conf"): + with open("/etc/nginx/conf.d/redis.conf", + "a") as redis_file: + redis_file.write("# Log format Settings\n" + "log_format rt_cache_redis " + "'$remote_addr " + "$upstream_response_time " + "$srcache_fetch_status " + "[$time_local]" + " '\n '$http_host" + " \"$request\" " + "$status $body_bytes_sent '\n" + "'\"$http_referer\" " + "\"$http_user_agent\"';\n") + # set redis.conf parameter + # set maxmemory 10% for ram below 512MB and 20% for others + # set maxmemory-policy allkeys-lru + # enable systemd service + Log.debug(self, "Enabling redis systemd service") + WOShellExec.cmd_exec(self, "systemctl enable redis-server") + if (os.path.isfile("/etc/redis/redis.conf") and + (not WOFileUtils.grep(self, "/etc/redis/redis.conf", + "WordOps"))): + Log.info(self, "Tuning Redis configuration") + with open("/etc/redis/redis.conf", "a") as redis_file: - redis_file.write("# Log format Settings\n" - "log_format rt_cache_redis " - "'$remote_addr " - "$upstream_response_time " - "$srcache_fetch_status " - "[$time_local]" - " '\n '$http_host" - " \"$request\" " - "$status $body_bytes_sent '\n" - "'\"$http_referer\" " - "\"$http_user_agent\"';\n") - # set redis.conf parameter - # set maxmemory 10% for ram below 512MB and 20% for others - # set maxmemory-policy allkeys-lru - # enable systemd service - Log.debug(self, "Enabling redis systemd service") - WOShellExec.cmd_exec(self, "systemctl enable redis-server") - if (os.path.isfile("/etc/redis/redis.conf") and - not WOFileUtils.grep(self, "/etc/redis/redis.conf", - "WordOps")): - Log.info(self, "Tuning Redis configuration") - with open("/etc/redis/redis.conf", - "a") as redis_file: - redis_file.write("\n# WordOps v3.9.8\n") - wo_ram = psutil.virtual_memory().total / (1024 * 1024) - if wo_ram < 1024: - Log.debug(self, "Setting maxmemory variable to " - "{0} in redis.conf" - .format(int(wo_ram*1024*1024*0.1))) + redis_file.write("\n# WordOps v3.9.8\n") + wo_ram = psutil.virtual_memory().total / (1024 * 1024) + if wo_ram < 1024: + Log.debug(self, "Setting maxmemory variable to " + "{0} in redis.conf" + .format(int(wo_ram*1024*1024*0.1))) + WOFileUtils.searchreplace(self, + "/etc/redis/redis.conf", + "# maxmemory ", + "maxmemory {0}" + .format + (int(wo_ram*1024*1024*0.1))) + + else: + Log.debug(self, "Setting maxmemory variable to {0} " + "in redis.conf" + .format(int(wo_ram*1024*1024*0.2))) + WOFileUtils.searchreplace(self, + "/etc/redis/redis.conf", + "# maxmemory ", + "maxmemory {0}" + .format + (int(wo_ram*1024*1024*0.2))) + + Log.debug( + self, "Setting maxmemory-policy variable to " + "allkeys-lru in redis.conf") WOFileUtils.searchreplace(self, "/etc/redis/redis.conf", - "# maxmemory ", - "maxmemory {0}" - .format - (int(wo_ram*1024*1024*0.1))) - - else: - Log.debug(self, "Setting maxmemory variable to {0} " - "in redis.conf" - .format(int(wo_ram*1024*1024*0.2))) + "# maxmemory-policy " + "noeviction", + "maxmemory-policy " + "allkeys-lru") + Log.debug( + self, "Setting tcp-backlog variable to " + "in redis.conf") WOFileUtils.searchreplace(self, "/etc/redis/redis.conf", - "# maxmemory ", - "maxmemory {0}" - .format - (int(wo_ram*1024*1024*0.2))) + "tcp-backlog 511", + "tcp-backlog 32768") + WOFileUtils.chown(self, '/etc/redis/redis.conf', + 'redis', 'redis', recursive=False) + WOService.restart_service(self, 'redis-server') - Log.debug( - self, "Setting maxmemory-policy variable to " - "allkeys-lru in redis.conf") - WOFileUtils.searchreplace(self, - "/etc/redis/redis.conf", - "# maxmemory-policy " - "noeviction", - "maxmemory-policy " - "allkeys-lru") - Log.debug( - self, "Setting tcp-backlog variable to " - "in redis.conf") - WOFileUtils.searchreplace(self, - "/etc/redis/redis.conf", - "tcp-backlog 511", - "tcp-backlog 32768") - WOFileUtils.chown(self, '/etc/redis/redis.conf', - 'redis', 'redis', recursive=False) - WOService.restart_service(self, 'redis-server') - - # Redis configuration - if set(["clamav"]).issubset(set(apt_packages)): - Log.debug("Setting up freshclam cronjob") - WOTemplate.render(self, '/opt/freshclam.sh', - 'freshclam.mustache', - data, overwrite=False) - WOFileUtils.chmod(self, "/opt/freshclam.sh", 0o775) - WOCron.setcron_weekly(self, '/opt/freshclam.sh ' - '> /dev/null 2>&1', - comment='ClamAV freshclam cronjob ' - 'added by WordOps') + # ClamAV configuration + if set(WOVariables.wo_clamav).issubset(set(apt_packages)): + Log.debug(self, "Setting up freshclam cronjob") + if not os.path.isfile("/opt/freshclam.sh"): + data = dict() + WOTemplate.render(self, '/opt/freshclam.sh', + 'freshclam.mustache', + data, overwrite=False) + WOFileUtils.chmod(self, "/opt/freshclam.sh", 0o775) + WOCron.setcron_weekly(self, '/opt/freshclam.sh ' + '> /dev/null 2>&1', + comment='ClamAV freshclam cronjob ' + 'added by WordOps') if (packages): # WP-CLI @@ -1253,16 +1268,33 @@ def post_pref(self, apt_packages, packages, upgrade=False): shutil.copyfile('/var/lib/wo/tmp/composer.phar', '/usr/local/bin/composer') WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) - Log.info(self, "Updating phpMyAdmin, please wait...") - WOShellExec.cmd_exec(self, "/usr/local/bin/composer update " - "--no-plugins --no-scripts " - "-n --no-dev -d " - "/var/www/22222/htdocs/db/pma/") - WOFileUtils.chown(self, '{0}22222/htdocs/db/pma' - .format(WOVariables.wo_webroot), - 'www-data', - 'www-data', - recursive=True) + if os.path.isdir("/var/www/22222/htdocs/db/pma"): + Log.info(self, "Updating phpMyAdmin, please wait...") + WOShellExec.cmd_exec( + self, "/usr/local/bin/composer update " + "--no-plugins --no-scripts " + "-n --no-dev -d " + "/var/www/22222/htdocs/db/pma/") + WOFileUtils.chown( + self, '{0}22222/htdocs/db/pma' + .format(WOVariables.wo_webroot), + 'www-data', + 'www-data', + recursive=True) + if not os.path.exists('{0}22222/htdocs/cache/' + 'redis/phpRedisAdmin' + .format(WOVariables.wo_webroot)): + Log.debug(self, "Creating new directory " + "{0}22222/htdocs/cache/redis" + .format(WOVariables.wo_webroot)) + os.makedirs('{0}22222/htdocs/cache/redis/phpRedisAdmin' + .format(WOVariables.wo_webroot)) + WOFileUtils.chown(self, '{0}22222/htdocs' + .format(WOVariables.wo_webroot), + 'www-data', + 'www-data', + recursive=True) + # MySQLtuner if any('/usr/bin/mysqltuner' == x[1] for x in packages): @@ -1283,34 +1315,33 @@ def post_pref(self, apt_packages, packages, upgrade=False): else: wo_netdata = "/opt/netdata/" # disable mail notifications - WOFileUtils.searchreplace(self, "{0}usr/" - "lib/netdata/conf.d/" - "health_alarm_notify.conf" - .format(wo_netdata), - 'SEND_EMAIL="YES"', - 'SEND_EMAIL="NO"') + WOFileUtils.searchreplace( + self, "{0}usr/" + "lib/netdata/conf.d/health_alarm_notify.conf" + .format(wo_netdata), + 'SEND_EMAIL="YES"', + 'SEND_EMAIL="NO"') # make changes persistant - WOFileUtils.copyfile(self, "{0}usr/" - "lib/netdata/conf.d/" - "health_alarm_notify.conf" - .format(wo_netdata), - "{0}etc/netdata/" - "health_alarm_notify.conf" - .format(wo_netdata)) + WOFileUtils.copyfile( + self, "{0}usr/lib/netdata/conf.d/" + "health_alarm_notify.conf" + .format(wo_netdata), + "{0}etc/netdata/health_alarm_notify.conf" + .format(wo_netdata)) # check if mysql credentials are available if os.path.isfile('/etc/mysql/conf.d/my.cnf'): try: - WOMysql.execute(self, - "create user " - "'netdata'@'localhost';", - log=False) - WOMysql.execute(self, - "grant usage on *.* to " - "'netdata'@'localhost';", - log=False) - WOMysql.execute(self, - "flush privileges;", - log=False) + WOMysql.execute( + self, + "create user 'netdata'@'localhost';", + log=False) + WOMysql.execute( + self, + "grant usage on *.* to 'netdata'@'localhost';", + log=False) + WOMysql.execute( + self, "flush privileges;", + log=False) except CommandExecutionError as e: Log.debug(self, "{0}".format(e)) Log.info( @@ -1396,20 +1427,23 @@ def post_pref(self, apt_packages, packages, upgrade=False): '{0}22222/htdocs/php/webgrind' .format(WOVariables.wo_webroot)) - WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" - "config.php" - .format(WOVariables.wo_webroot), - "/usr/local/bin/dot", "/usr/bin/dot") - WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" - "config.php" - .format(WOVariables.wo_webroot), - "Europe/Copenhagen", - WOVariables.wo_timezone) + WOFileUtils.searchreplace( + self, "{0}22222/htdocs/php/webgrind/" + "config.php" + .format(WOVariables.wo_webroot), + "/usr/local/bin/dot", "/usr/bin/dot") + WOFileUtils.searchreplace( + self, "{0}22222/htdocs/php/webgrind/" + "config.php" + .format(WOVariables.wo_webroot), + "Europe/Copenhagen", + WOVariables.wo_timezone) - WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" - "config.php" - .format(WOVariables.wo_webroot), - "90", "100") + WOFileUtils.searchreplace( + self, "{0}22222/htdocs/php/webgrind/" + "config.php" + .format(WOVariables.wo_webroot), + "90", "100") Log.debug(self, "Setting Privileges of webroot permission to " "{0}22222/htdocs/php/webgrind/ file " @@ -1456,13 +1490,14 @@ def post_pref(self, apt_packages, packages, upgrade=False): Log.debug(self, "grant all on slow-query-log.*" " to anemometer@root_user" " IDENTIFIED BY password ") - WOMysql.execute(self, 'grant all on slow_query_log.* to' - '\'anemometer\'@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get( - 'mysql', 'grant-host'), - chars), - errormsg="cannot grant priviledges", - log=False) + WOMysql.execute( + self, 'grant all on slow_query_log.* to' + '\'anemometer\'@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get( + 'mysql', 'grant-host'), + chars), + errormsg="cannot grant priviledges", + log=False) # Custom Anemometer configuration Log.debug(self, "configration Anemometer") @@ -1480,35 +1515,3 @@ def post_pref(self, apt_packages, packages, upgrade=False): if any('/usr/bin/pt-query-advisor' == x[1] for x in packages): WOFileUtils.chmod(self, "/usr/bin/pt-query-advisor", 0o775) - - # phpredisadmin - if any('/var/lib/wo/tmp/pra.tar.gz' == x[1] - for x in packages): - if not os.path.exists('{0}22222/htdocs/cache/' - 'redis/phpRedisAdmin' - .format(WOVariables.wo_webroot)): - Log.debug(self, "Creating new directory " - "{0}22222/htdocs/cache/redis" - .format(WOVariables.wo_webroot)) - os.makedirs('{0}22222/htdocs/cache/redis/phpRedisAdmin' - .format(WOVariables.wo_webroot)) - WOFileUtils.chown(self, '{0}22222/htdocs' - .format(WOVariables.wo_webroot), - 'www-data', - 'www-data', - recursive=True) - if os.path.isfile("/usr/local/bin/composer"): - WOShellExec.cmd_exec(self, "/usr/local/bin/composer" - "create-project --no-plugins " - "--no-scripts -n -s dev " - "erik-dubbelboer/php-redis-admin " - "/var/www/22222/htdocs/cache" - "/redis/phpRedisAdmin ") - Log.debug(self, 'Setting Privileges of webroot permission to ' - '{0}22222/htdocs/cache/redis' - .format(WOVariables.wo_webroot)) - WOFileUtils.chown(self, '{0}22222/htdocs' - .format(WOVariables.wo_webroot), - 'www-data', - 'www-data', - recursive=True) diff --git a/wo/core/variables.py b/wo/core/variables.py index fa97644..11547bb 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -10,7 +10,7 @@ class WOVariables(): """Intialization of core variables""" # WordOps version - wo_version = "3.9.8.6" + wo_version = "3.9.8.7" # WordOps packages versions wo_wp_cli = "2.2.0" wo_adminer = "4.7.2" @@ -160,6 +160,7 @@ class WOVariables(): wo_mysql_client = ["mariadb-client", "python3-mysql.connector"] wo_fail2ban = ["fail2ban"] + wo_clamav = ["clamav", "clamav-freshclam"] # Redis repo details if wo_distro == 'ubuntu':