Merge pull request #132 from WordOps/updating-configuration

Updating configuration
This commit is contained in:
VirtuBox
2019-08-31 15:36:25 +02:00
committed by GitHub
8 changed files with 366 additions and 287 deletions

View File

@@ -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.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 ### v3.9.8.6 - 2019-08-30
#### Added #### Added

12
install
View File

@@ -811,11 +811,11 @@ if [ "$wo_purge" = "y" ]; then
else else
# 1 - WO already installed # 1 - WO already installed
if [ -x /usr/local/bin/wo ]; then if [ -x /usr/local/bin/wo ]; then
if { if [ -z "$wo_force_install" ]; then
wo -v 2>&1 | grep -q "$wo_version_new" if { wo -v 2>&1 | grep -q "$wo_version_new"; }; then
} && [ -z "$wo_force_install" ]; then wo_lib_error "You already have WordOps $wo_version_new"
wo_lib_error "You already have WordOps $wo_version_new" exit 1
exit 1 fi
fi fi
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | 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" wo_lib_echo_info "wo stack upgrade --nginx"
echo echo
wo_lib_echo "To update other packages use the command:" wo_lib_echo "To update other packages use the command:"
wo_lib_echo_info "wo stack maintenance" wo_lib_echo_info "wo maintenance"
else else
wo_lib_echo "WordOps (wo) installed successfully" wo_lib_echo "WordOps (wo) installed successfully"
echo echo

View File

@@ -57,7 +57,7 @@ if not os.path.isfile('/root/.gitconfig'):
shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig') shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig')
setup(name='wo', setup(name='wo',
version='3.9.8.6', version='3.9.8.7',
description=long_description, description=long_description,
long_description=long_description, long_description=long_description,
classifiers=[], classifiers=[],

View File

@@ -3,43 +3,118 @@
# WordOps travis testing script # WordOps travis testing script
# #
# #
# Colors
CSI='\033[' CSI='\033['
CEND="${CSI}0m" CRED="${CSI}1;31m"
CGREEN="${CSI}1;32m" CGREEN="${CSI}1;32m"
CEND="${CSI}0m"
exit_script() { exit_script() {
tar -I pigz -cf wordops.tar.gz /var/log/wo 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 exit 1
} }
if ! { echo -e "${CGREEN}#############################################${CEND}"
echo -e "${CGREEN}#############################################${CEND}" echo -e ' stack install '
echo -e ' stack install ' echo -e "${CGREEN}#############################################${CEND}"
echo -e "${CGREEN}#############################################${CEND}" stack_list='nginx php php73 mysql redis fail2ban clamav proftpd admin'
wo --help && wo stack install && wo stack install --proftpd for stack in $stack_list; do
}; then echo -ne " Installing $stack [..]\r"
exit_script if {
fi wo stack install --${stack}
if ! { } >> /var/log/wo/test.log; then
echo -e "${CGREEN}#############################################${CEND}" echo -ne " Installing $stack [${CGREEN}OK${CEND}]\\r"
echo -e ' Simple site create ' echo -ne '\n'
echo -e "${CGREEN}#############################################${CEND}" else
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 echo -e " Installing $stack [${CRED}FAIL${CEND}]"
wo site create wp1.com --wp && wo site create wpsc1.net --wpsc && wo site create wpfc1.com --wpfc echo -ne '\n'
wo site create wpsc-php73.net --wpsc --php73 && wo site create wpfc-php73.net --wpfc --php73 exit_script
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 fi
wo site create wpredis.net --wpredis && wo site create wpredis-php73.net --wpredis --php73 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 ! { if ! {
echo -e "${CGREEN}#############################################${CEND}" echo -e "${CGREEN}#############################################${CEND}"
echo -e ' Multi-site create ' echo -e ' Multi-site create '
echo -e "${CGREEN}#############################################${CEND}" 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 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 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}" echo -e "${CGREEN}#############################################${CEND}"
@@ -51,19 +126,7 @@ if ! {
}; then }; then
exit_script exit_script
fi 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 "${CGREEN}#############################################${CEND}"
echo -e ' various informations ' echo -e ' various informations '
echo -e "${CGREEN}#############################################${CEND}" echo -e "${CGREEN}#############################################${CEND}"

View File

@@ -519,7 +519,7 @@ def setupwordpress(self, data, vhostonly=False):
WOShellExec.cmd_exec(self, " {0} --allow-root " WOShellExec.cmd_exec(self, " {0} --allow-root "
.format(WOVariables.wo_wpcli_path) + .format(WOVariables.wo_wpcli_path) +
"rewrite structure " "rewrite structure "
"/%year%/%monthnum%/%day%/%postname%/") "/%postname%/")
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
raise SiteError("Update wordpress permalinks failed") raise SiteError("Update wordpress permalinks failed")

View File

@@ -265,7 +265,7 @@ class WOStackController(CementBaseController):
if pargs.clamav: if pargs.clamav:
Log.debug(self, "Setting apt_packages variable for ClamAV") Log.debug(self, "Setting apt_packages variable for ClamAV")
if not WOAptGet.is_installed(self, 'clamav'): if not WOAptGet.is_installed(self, 'clamav'):
apt_packages = apt_packages + ["clamav"] apt_packages = apt_packages + WOVariables.wo_clamav
else: else:
Log.debug(self, "ClamAV already installed") Log.debug(self, "ClamAV already installed")
Log.info(self, "ClamAV already installed") Log.info(self, "ClamAV already installed")
@@ -473,7 +473,7 @@ class WOStackController(CementBaseController):
WOAptGet.install(self, apt_packages) WOAptGet.install(self, apt_packages)
post_pref(self, apt_packages, empty_packages) post_pref(self, apt_packages, empty_packages)
if (packages): if (packages):
Log.debug(self, "Downloading following: {0}".format(packages)) Log.info(self, "Downloading following: {0}".format(packages))
WODownload.download(self, packages) WODownload.download(self, packages)
Log.debug(self, "Calling post_pref") Log.debug(self, "Calling post_pref")
post_pref(self, empty_packages, packages) post_pref(self, empty_packages, packages)
@@ -587,7 +587,7 @@ class WOStackController(CementBaseController):
if pargs.clamav: if pargs.clamav:
Log.debug(self, "Setting apt_packages variable for ClamAV") Log.debug(self, "Setting apt_packages variable for ClamAV")
if WOAptGet.is_installed(self, 'clamav'): if WOAptGet.is_installed(self, 'clamav'):
apt_packages = apt_packages + ["clamav"] apt_packages = apt_packages + WOVariables.wo_clamav
# proftpd # proftpd
if pargs.proftpd: if pargs.proftpd:
@@ -793,7 +793,7 @@ class WOStackController(CementBaseController):
if pargs.clamav: if pargs.clamav:
Log.debug(self, "Setting apt_packages variable for ClamAV") Log.debug(self, "Setting apt_packages variable for ClamAV")
if WOAptGet.is_installed(self, 'clamav'): if WOAptGet.is_installed(self, 'clamav'):
apt_packages = apt_packages + ["clamav"] apt_packages = apt_packages + WOVariables.wo_clamav
# proftpd # proftpd
if pargs.proftpd: if pargs.proftpd:

View File

@@ -330,16 +330,17 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"/redis.conf")): "/redis.conf")):
with open("/etc/nginx/conf.d/" with open("/etc/nginx/conf.d/"
"redis.conf", "a") as redis_file: "redis.conf", "a") as redis_file:
redis_file.write("# Log format Settings\n" redis_file.write(
"log_format rt_cache_redis " "# Log format Settings\n"
"'$remote_addr " "log_format rt_cache_redis "
"$upstream_response_time " "'$remote_addr "
"$srcache_fetch_status " "$upstream_response_time "
"[$time_local] '\n" "$srcache_fetch_status "
"'$http_host \"$request\" $status" "[$time_local] '\n"
" $body_bytes_sent '\n" "'$http_host \"$request\" $status"
"'\"$http_referer\" " " $body_bytes_sent '\n"
"\"$http_user_agent\"';\n") "'\"$http_referer\" "
"\"$http_user_agent\"';\n")
# Nginx-Plus does not have nginx # Nginx-Plus does not have nginx
# package structure like this # package structure like this
@@ -356,30 +357,34 @@ def post_pref(self, apt_packages, packages, upgrade=False):
# 22222 port settings # 22222 port settings
if not os.path.isfile('/etc/nginx/sites-available/22222'): if not os.path.isfile('/etc/nginx/sites-available/22222'):
WOTemplate.render(self, data = dict(webroot=ngxroot)
'/etc/nginx/sites-available/22222', WOTemplate.render(
'22222.mustache', data, overwrite=False) self,
'/etc/nginx/sites-available/22222',
'22222.mustache', data, overwrite=False)
passwd = ''.join([random.choice passwd = ''.join([random.choice
(string.ascii_letters + string.digits) (string.ascii_letters + string.digits)
for n in range(24)]) for n in range(24)])
try: try:
WOShellExec.cmd_exec(self, "printf \"WordOps:" WOShellExec.cmd_exec(
"$(openssl passwd -crypt " self, "printf \"WordOps:"
"{password} 2> /dev/null)\n\"" "$(openssl passwd -crypt "
"> /etc/nginx/htpasswd-wo " "{password} 2> /dev/null)\n\""
"2>/dev/null" "> /etc/nginx/htpasswd-wo "
.format(password=passwd)) "2>/dev/null"
.format(password=passwd))
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.error(self, "Failed to save HTTP Auth") Log.error(self, "Failed to save HTTP Auth")
# Create Symbolic link for 22222 # Create Symbolic link for 22222
WOFileUtils.create_symlink(self, ['/etc/nginx/' WOFileUtils.create_symlink(
'sites-available/' self, ['/etc/nginx/'
'22222', 'sites-available/'
'/etc/nginx/' '22222',
'sites-enabled/' '/etc/nginx/'
'22222']) 'sites-enabled/'
'22222'])
# Create log and cert folder and softlinks # Create log and cert folder and softlinks
if not os.path.exists('{0}22222/logs' if not os.path.exists('{0}22222/logs'
.format(ngxroot)): .format(ngxroot)):
@@ -405,51 +410,58 @@ def post_pref(self, apt_packages, packages, upgrade=False):
os.makedirs('{0}22222/conf/nginx' os.makedirs('{0}22222/conf/nginx'
.format(ngxroot)) .format(ngxroot))
WOFileUtils.create_symlink(self, WOFileUtils.create_symlink(
['/var/log/nginx/' self,
'22222.access.log', ['/var/log/nginx/'
'{0}22222/' '22222.access.log',
'logs/access.log' '{0}22222/'
.format(ngxroot)] 'logs/access.log'
) .format(ngxroot)]
)
WOFileUtils.create_symlink(self, WOFileUtils.create_symlink(
['/var/log/nginx/' self,
'22222.error.log', ['/var/log/nginx/'
'{0}22222/' '22222.error.log',
'logs/error.log' '{0}22222/'
.format(ngxroot)] 'logs/error.log'
) .format(ngxroot)]
)
try: try:
WOShellExec.cmd_exec(self, "openssl genrsa -out " WOShellExec.cmd_exec(
"{0}22222/cert/22222.key 2048" self, "openssl genrsa -out "
.format(ngxroot)) "{0}22222/cert/22222.key 2048"
WOShellExec.cmd_exec(self, "openssl req -new -batch " .format(ngxroot))
"-subj /commonName=localhost/ " WOShellExec.cmd_exec(
"-key {0}22222/cert/22222.key " self, "openssl req -new -batch "
"-out {0}22222/cert/" "-subj /commonName=localhost/ "
"22222.csr" "-key {0}22222/cert/22222.key "
.format(ngxroot)) "-out {0}22222/cert/"
"22222.csr"
.format(ngxroot))
WOFileUtils.mvfile(self, "{0}22222/cert/22222.key" WOFileUtils.mvfile(
.format(ngxroot), self, "{0}22222/cert/22222.key"
"{0}22222/cert/" .format(ngxroot),
"22222.key.org" "{0}22222/cert/"
.format(ngxroot)) "22222.key.org"
.format(ngxroot))
WOShellExec.cmd_exec(self, "openssl rsa -in " WOShellExec.cmd_exec(
"{0}22222/cert/" self, "openssl rsa -in "
"22222.key.org -out " "{0}22222/cert/"
"{0}22222/cert/22222.key" "22222.key.org -out "
.format(ngxroot)) "{0}22222/cert/22222.key"
.format(ngxroot))
WOShellExec.cmd_exec(self, "openssl x509 -req -days " WOShellExec.cmd_exec(
"3652 -in {0}22222/cert/" self, "openssl x509 -req -days "
"22222.csr -signkey {0}" "3652 -in {0}22222/cert/"
"22222/cert/22222.key -out " "22222.csr -signkey {0}"
"{0}22222/cert/22222.crt" "22222/cert/22222.key -out "
.format(ngxroot)) "{0}22222/cert/22222.crt"
.format(ngxroot))
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
@@ -486,6 +498,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOVariables.wo_fqdn)]) WOVariables.wo_fqdn)])
if not os.path.isfile("/opt/cf-update.sh"): if not os.path.isfile("/opt/cf-update.sh"):
data = dict()
WOTemplate.render(self, '/opt/cf-update.sh', WOTemplate.render(self, '/opt/cf-update.sh',
'cf-update.mustache', 'cf-update.mustache',
data, overwrite=False) data, overwrite=False)
@@ -1079,100 +1092,102 @@ def post_pref(self, apt_packages, packages, upgrade=False):
msg="Adding ProFTPd into Git") msg="Adding ProFTPd into Git")
WOService.reload_service(self, 'proftpd') WOService.reload_service(self, 'proftpd')
# Redis configuration # Redis configuration
if set(WOVariables.wo_redis).issubset(set(apt_packages)): if set(WOVariables.wo_redis).issubset(set(apt_packages)):
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"): if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not WOFileUtils.grep(self, "/etc/nginx/conf.d/" if not WOFileUtils.grep(self, "/etc/nginx/conf.d/"
"upstream.conf", "upstream.conf",
"redis"): "redis"):
with open("/etc/nginx/conf.d/upstream.conf", with open("/etc/nginx/conf.d/upstream.conf",
"a") as redis_file: "a") as redis_file:
redis_file.write("upstream redis {\n" redis_file.write("upstream redis {\n"
" server 127.0.0.1:6379;\n" " server 127.0.0.1:6379;\n"
" keepalive 10;\n}\n") " keepalive 10;\n}\n")
if os.path.isfile("/etc/nginx/nginx.conf"): if os.path.isfile("/etc/nginx/nginx.conf"):
if not os.path.isfile("/etc/nginx/conf.d/redis.conf"): if not os.path.isfile("/etc/nginx/conf.d/redis.conf"):
with open("/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: "a") as redis_file:
redis_file.write("# Log format Settings\n" redis_file.write("\n# WordOps v3.9.8\n")
"log_format rt_cache_redis " wo_ram = psutil.virtual_memory().total / (1024 * 1024)
"'$remote_addr " if wo_ram < 1024:
"$upstream_response_time " Log.debug(self, "Setting maxmemory variable to "
"$srcache_fetch_status " "{0} in redis.conf"
"[$time_local]" .format(int(wo_ram*1024*1024*0.1)))
" '\n '$http_host" WOFileUtils.searchreplace(self,
" \"$request\" " "/etc/redis/redis.conf",
"$status $body_bytes_sent '\n" "# maxmemory <bytes>",
"'\"$http_referer\" " "maxmemory {0}"
"\"$http_user_agent\"';\n") .format
# set redis.conf parameter (int(wo_ram*1024*1024*0.1)))
# set maxmemory 10% for ram below 512MB and 20% for others
# set maxmemory-policy allkeys-lru else:
# enable systemd service Log.debug(self, "Setting maxmemory variable to {0} "
Log.debug(self, "Enabling redis systemd service") "in redis.conf"
WOShellExec.cmd_exec(self, "systemctl enable redis-server") .format(int(wo_ram*1024*1024*0.2)))
if (os.path.isfile("/etc/redis/redis.conf") and WOFileUtils.searchreplace(self,
not WOFileUtils.grep(self, "/etc/redis/redis.conf", "/etc/redis/redis.conf",
"WordOps")): "# maxmemory <bytes>",
Log.info(self, "Tuning Redis configuration") "maxmemory {0}"
with open("/etc/redis/redis.conf", .format
"a") as redis_file: (int(wo_ram*1024*1024*0.2)))
redis_file.write("\n# WordOps v3.9.8\n")
wo_ram = psutil.virtual_memory().total / (1024 * 1024) Log.debug(
if wo_ram < 1024: self, "Setting maxmemory-policy variable to "
Log.debug(self, "Setting maxmemory variable to " "allkeys-lru in redis.conf")
"{0} in redis.conf"
.format(int(wo_ram*1024*1024*0.1)))
WOFileUtils.searchreplace(self, WOFileUtils.searchreplace(self,
"/etc/redis/redis.conf", "/etc/redis/redis.conf",
"# maxmemory <bytes>", "# maxmemory-policy "
"maxmemory {0}" "noeviction",
.format "maxmemory-policy "
(int(wo_ram*1024*1024*0.1))) "allkeys-lru")
Log.debug(
else: self, "Setting tcp-backlog variable to "
Log.debug(self, "Setting maxmemory variable to {0} " "in redis.conf")
"in redis.conf"
.format(int(wo_ram*1024*1024*0.2)))
WOFileUtils.searchreplace(self, WOFileUtils.searchreplace(self,
"/etc/redis/redis.conf", "/etc/redis/redis.conf",
"# maxmemory <bytes>", "tcp-backlog 511",
"maxmemory {0}" "tcp-backlog 32768")
.format WOFileUtils.chown(self, '/etc/redis/redis.conf',
(int(wo_ram*1024*1024*0.2))) 'redis', 'redis', recursive=False)
WOService.restart_service(self, 'redis-server')
Log.debug( # ClamAV configuration
self, "Setting maxmemory-policy variable to " if set(WOVariables.wo_clamav).issubset(set(apt_packages)):
"allkeys-lru in redis.conf") Log.debug(self, "Setting up freshclam cronjob")
WOFileUtils.searchreplace(self, if not os.path.isfile("/opt/freshclam.sh"):
"/etc/redis/redis.conf", data = dict()
"# maxmemory-policy " WOTemplate.render(self, '/opt/freshclam.sh',
"noeviction", 'freshclam.mustache',
"maxmemory-policy " data, overwrite=False)
"allkeys-lru") WOFileUtils.chmod(self, "/opt/freshclam.sh", 0o775)
Log.debug( WOCron.setcron_weekly(self, '/opt/freshclam.sh '
self, "Setting tcp-backlog variable to " '> /dev/null 2>&1',
"in redis.conf") comment='ClamAV freshclam cronjob '
WOFileUtils.searchreplace(self, 'added by WordOps')
"/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')
if (packages): if (packages):
# WP-CLI # WP-CLI
@@ -1253,16 +1268,33 @@ def post_pref(self, apt_packages, packages, upgrade=False):
shutil.copyfile('/var/lib/wo/tmp/composer.phar', shutil.copyfile('/var/lib/wo/tmp/composer.phar',
'/usr/local/bin/composer') '/usr/local/bin/composer')
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
Log.info(self, "Updating phpMyAdmin, please wait...") if os.path.isdir("/var/www/22222/htdocs/db/pma"):
WOShellExec.cmd_exec(self, "/usr/local/bin/composer update " Log.info(self, "Updating phpMyAdmin, please wait...")
"--no-plugins --no-scripts " WOShellExec.cmd_exec(
"-n --no-dev -d " self, "/usr/local/bin/composer update "
"/var/www/22222/htdocs/db/pma/") "--no-plugins --no-scripts "
WOFileUtils.chown(self, '{0}22222/htdocs/db/pma' "-n --no-dev -d "
.format(WOVariables.wo_webroot), "/var/www/22222/htdocs/db/pma/")
'www-data', WOFileUtils.chown(
'www-data', self, '{0}22222/htdocs/db/pma'
recursive=True) .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 # MySQLtuner
if any('/usr/bin/mysqltuner' == x[1] if any('/usr/bin/mysqltuner' == x[1]
for x in packages): for x in packages):
@@ -1283,34 +1315,33 @@ def post_pref(self, apt_packages, packages, upgrade=False):
else: else:
wo_netdata = "/opt/netdata/" wo_netdata = "/opt/netdata/"
# disable mail notifications # disable mail notifications
WOFileUtils.searchreplace(self, "{0}usr/" WOFileUtils.searchreplace(
"lib/netdata/conf.d/" self, "{0}usr/"
"health_alarm_notify.conf" "lib/netdata/conf.d/health_alarm_notify.conf"
.format(wo_netdata), .format(wo_netdata),
'SEND_EMAIL="YES"', 'SEND_EMAIL="YES"',
'SEND_EMAIL="NO"') 'SEND_EMAIL="NO"')
# make changes persistant # make changes persistant
WOFileUtils.copyfile(self, "{0}usr/" WOFileUtils.copyfile(
"lib/netdata/conf.d/" self, "{0}usr/lib/netdata/conf.d/"
"health_alarm_notify.conf" "health_alarm_notify.conf"
.format(wo_netdata), .format(wo_netdata),
"{0}etc/netdata/" "{0}etc/netdata/health_alarm_notify.conf"
"health_alarm_notify.conf" .format(wo_netdata))
.format(wo_netdata))
# check if mysql credentials are available # check if mysql credentials are available
if os.path.isfile('/etc/mysql/conf.d/my.cnf'): if os.path.isfile('/etc/mysql/conf.d/my.cnf'):
try: try:
WOMysql.execute(self, WOMysql.execute(
"create user " self,
"'netdata'@'localhost';", "create user 'netdata'@'localhost';",
log=False) log=False)
WOMysql.execute(self, WOMysql.execute(
"grant usage on *.* to " self,
"'netdata'@'localhost';", "grant usage on *.* to 'netdata'@'localhost';",
log=False) log=False)
WOMysql.execute(self, WOMysql.execute(
"flush privileges;", self, "flush privileges;",
log=False) log=False)
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.info( Log.info(
@@ -1396,20 +1427,23 @@ def post_pref(self, apt_packages, packages, upgrade=False):
'{0}22222/htdocs/php/webgrind' '{0}22222/htdocs/php/webgrind'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" WOFileUtils.searchreplace(
"config.php" self, "{0}22222/htdocs/php/webgrind/"
.format(WOVariables.wo_webroot), "config.php"
"/usr/local/bin/dot", "/usr/bin/dot") .format(WOVariables.wo_webroot),
WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" "/usr/local/bin/dot", "/usr/bin/dot")
"config.php" WOFileUtils.searchreplace(
.format(WOVariables.wo_webroot), self, "{0}22222/htdocs/php/webgrind/"
"Europe/Copenhagen", "config.php"
WOVariables.wo_timezone) .format(WOVariables.wo_webroot),
"Europe/Copenhagen",
WOVariables.wo_timezone)
WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" WOFileUtils.searchreplace(
"config.php" self, "{0}22222/htdocs/php/webgrind/"
.format(WOVariables.wo_webroot), "config.php"
"90", "100") .format(WOVariables.wo_webroot),
"90", "100")
Log.debug(self, "Setting Privileges of webroot permission to " Log.debug(self, "Setting Privileges of webroot permission to "
"{0}22222/htdocs/php/webgrind/ file " "{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.*" Log.debug(self, "grant all on slow-query-log.*"
" to anemometer@root_user" " to anemometer@root_user"
" IDENTIFIED BY password ") " IDENTIFIED BY password ")
WOMysql.execute(self, 'grant all on slow_query_log.* to' WOMysql.execute(
'\'anemometer\'@\'{0}\' IDENTIFIED' self, 'grant all on slow_query_log.* to'
' BY \'{1}\''.format(self.app.config.get( '\'anemometer\'@\'{0}\' IDENTIFIED'
'mysql', 'grant-host'), ' BY \'{1}\''.format(self.app.config.get(
chars), 'mysql', 'grant-host'),
errormsg="cannot grant priviledges", chars),
log=False) errormsg="cannot grant priviledges",
log=False)
# Custom Anemometer configuration # Custom Anemometer configuration
Log.debug(self, "configration Anemometer") 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] if any('/usr/bin/pt-query-advisor' == x[1]
for x in packages): for x in packages):
WOFileUtils.chmod(self, "/usr/bin/pt-query-advisor", 0o775) 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)

View File

@@ -10,7 +10,7 @@ class WOVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# WordOps version # WordOps version
wo_version = "3.9.8.6" wo_version = "3.9.8.7"
# WordOps packages versions # WordOps packages versions
wo_wp_cli = "2.2.0" wo_wp_cli = "2.2.0"
wo_adminer = "4.7.2" wo_adminer = "4.7.2"
@@ -160,6 +160,7 @@ class WOVariables():
wo_mysql_client = ["mariadb-client", "python3-mysql.connector"] wo_mysql_client = ["mariadb-client", "python3-mysql.connector"]
wo_fail2ban = ["fail2ban"] wo_fail2ban = ["fail2ban"]
wo_clamav = ["clamav", "clamav-freshclam"]
# Redis repo details # Redis repo details
if wo_distro == 'ubuntu': if wo_distro == 'ubuntu':