diff --git a/.travis.yml b/.travis.yml
index ebeaa10..de85d19 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,6 +23,7 @@ before_script:
after_script:
+ - sudo -E python3 setup.py sdist bdist_wheel
- sudo -E bash install --purge
@@ -31,7 +32,5 @@ script:
- sudo bash -c 'echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > /home/travis/.gitconfig'
- sudo echo "Travis Banch = $TRAVIS_BRANCH"
- sudo -E time bash install --travis -b "$TRAVIS_BRANCH"
- - sudo -E python3 -m pip install -U -r requirements.txt
- sudo -E time bash tests/travis.sh
- - sudo -E wo update --travis
- - sudo python3 setup.py sdist bdist_wheel
\ No newline at end of file
+ - sudo -E wo update --travis
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e17b9d2..db35dff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### v3.9.x - [Unreleased]
+### v3.10.2 - 2019-11-06
+
+#### Added
+
+- [STACK] nanorc syntax highlighting for nano editor : `--nanorc`
+
+#### Changed
+
+- `wo stack remove/purge` without argument print help instead of removing main stacks
+
+#### Fixed
+
+- Import rtCamp:EasyEngine GPG key to avoid issues with previous nginx repository
+- Unable to issue certificate for a domain if a subdomain certificate exist
+- Incorrect WP-CLI path site_url_https function
+- `wo stack upgrade --ngxblocker` not working properly
+
### v3.10.1 - 2019-10-30
#### Fixed
diff --git a/README.md b/README.md
index fd9d101..9b687ca 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@
-
+
diff --git a/install b/install
index 27f6969..3df23e6 100755
--- a/install
+++ b/install
@@ -9,7 +9,7 @@
# -------------------------------------------------------------------------
# wget -qO wo wops.cc && sudo bash wo
# -------------------------------------------------------------------------
-# Version 3.10.1 - 2019-10-30
+# Version 3.10.2 - 2019-11-06
# -------------------------------------------------------------------------
# CONTENTS
@@ -220,7 +220,6 @@ wo_install_dep() {
# add nginx repository gpg key
curl -sL https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_10/Release.key | apt-key add -
fi
-
locale-gen en
# enable unattended upgades
if [ ! -f /etc/apt/apt.conf.d/20auto-upgrades ]; then
@@ -631,6 +630,8 @@ wo_init() {
###
if [ -z "$wo_travis" ]; then
+ # import easyengine opensusebuildservice gpg key to avoid issues with packages update
+ apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys 3050ac3cd2ae6f03 > /dev/null 2>&1
if ! {
apt-get update --allow-releaseinfo-change -qq >/dev/null 2>&1
}; then
@@ -640,10 +641,10 @@ wo_init() {
apt-get -y install curl -qq >/dev/null 2>&1
fi
if ! command_exists lsb_release; then
- apt-get install lsb-release -qq > /dev/null 2>&1
+ apt-get install lsb-release -qq >/dev/null 2>&1
fi
if ! command_exists jq; then
- apt-get install jq -qq > /dev/null 2>&1
+ apt-get install jq -qq >/dev/null 2>&1
fi
fi
if [ "$wo_force_install" = "y" ]; then
@@ -652,7 +653,7 @@ wo_init() {
if [ -f ./setup.py ]; then
readonly wo_version_new=$(grep "version='" setup.py | awk -F "'" '{print $2}' 2>&1)
else
- readonly wo_version_new=$(curl -m 5 --retry 3 -sL https://api.github.com/repos/WordOps/WordOps/releases/latest 2>&1 | jq -r '.tag_name' )
+ readonly wo_version_new=$(curl -m 5 --retry 3 -sL https://api.github.com/repos/WordOps/WordOps/releases/latest 2>&1 | jq -r '.tag_name')
fi
echo ""
@@ -673,8 +674,11 @@ wo_init
wo_init_variables
# remove old repositories
_run wo_clean_repo
-# check distribution support
-wo_check_distro
+
+if [ -z "$wo_force_install" ]; then
+ # check distribution support
+ wo_check_distro
+fi
# wo uninstall script
if [ "$wo_purge" = "y" ]; then
diff --git a/setup.py b/setup.py
index 0a9a912..017b039 100644
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@ if os.geteuid() == 0:
os.makedirs('/var/lib/wo/tmp/')
setup(name='wordops',
- version='3.10.1',
+ version='3.10.2',
description='An essential toolset that eases server administration',
long_description=LONG,
long_description_content_type='text/markdown',
@@ -50,7 +50,7 @@ setup(name='wordops',
include_package_data=True,
zip_safe=False,
test_suite='nose.collector',
- python_requires='>=3.5',
+ python_requires='>=3.4',
install_requires=[
# Required to build documentation
# "Sphinx >= 1.0",
diff --git a/tests/travis.sh b/tests/travis.sh
index 6ebaa72..357a5b1 100644
--- a/tests/travis.sh
+++ b/tests/travis.sh
@@ -28,12 +28,12 @@ exit_script() {
echo -e "${CGREEN}#############################################${CEND}"
echo -e ' stack install '
echo -e "${CGREEN}#############################################${CEND}"
-stack_list='nginx php php73 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis phpredisadmin mysqltuner utils ufw ngxblocker cheat'
+stack_list='nginx php php73 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis phpredisadmin mysqltuner utils ufw ngxblocker cheat nanorc'
for stack in $stack_list; do
echo -ne " Installing $stack [..]\r"
if {
wo stack install --${stack}
- } >> /var/log/wo/test.log; then
+ } >>/var/log/wo/test.log; then
echo -ne " Installing $stack [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -52,7 +52,7 @@ for site in $site_types; do
echo -ne " Creating $site [..]\r"
if {
wo site create ${site}.net --${site}
- } >> /var/log/wo/test.log; then
+ } >>/var/log/wo/test.log; then
echo -ne " Creating $site [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -70,7 +70,7 @@ 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
+ } >>/var/log/wo/test.log; then
echo -ne " Updating site to $site php73 [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -86,12 +86,12 @@ 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
+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
+ } >>/var/log/wo/test.log; then
echo -ne " Updating WP to $site [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -111,7 +111,7 @@ for site in $wp_site_types; do
echo -ne " Creating wpsubdir $site [..]\r"
if {
wo site create wpsubdir"$site".io --wpsubdir --${site}
- } >> /var/log/wo/test.log; then
+ } >>/var/log/wo/test.log; then
echo -ne " Creating wpsubdir $site [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -131,7 +131,7 @@ for site in $wp_site_types; do
echo -ne " Creating wpsubdomain $site [..]\r"
if {
wo site create wpsubdomain"$site".io --wpsubdomain --${site}
- } >> /var/log/wo/test.log; then
+ } >>/var/log/wo/test.log; then
echo -ne " Creating wpsubdomain $site [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -150,7 +150,7 @@ if [ -z "$1" ]; then
echo -ne " Upgrading $stack [..]\r"
if {
wo stack upgrade --${stack} --force
- } >> /var/log/wo/test.log; then
+ } >>/var/log/wo/test.log; then
echo -ne " Upgrading $stack [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -169,7 +169,7 @@ for stack in $stack_clean; do
echo -ne " cleaning $stack cache [..]\r"
if {
wo clean --${stack}
- } >> /var/log/wo/test.log; then
+ } >>/var/log/wo/test.log; then
echo -ne " cleaning $stack cache [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -186,7 +186,7 @@ echo -e "${CGREEN}#############################################${CEND}"
echo -ne " wo secure --auth [..]\r"
if {
wo secure --auth wordops mypassword
-} >> /var/log/wo/test.log; then
+} >>/var/log/wo/test.log; then
echo -ne " wo secure --auth [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -198,7 +198,7 @@ fi
echo -ne " wo secure --sshport [..]\r"
if {
wo secure --sshport 2022
-} >> /var/log/wo/test.log; then
+} >>/var/log/wo/test.log; then
echo -ne " wo secure --sshport [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -210,7 +210,7 @@ fi
echo -ne " wo secure --ssh [..]\r"
if {
wo secure --ssh --force
-} >> /var/log/wo/test.log; then
+} >>/var/log/wo/test.log; then
echo -ne " wo secure --ssh [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
@@ -230,12 +230,12 @@ wo info
echo -e "${CGREEN}#############################################${CEND}"
echo -e ' wo stack purge '
echo -e "${CGREEN}#############################################${CEND}"
-stack_purge='nginx php php73 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis ufw ngxblocker cheat'
+stack_purge='nginx php php73 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis ufw ngxblocker cheat nanorc'
for stack in $stack_purge; do
echo -ne " purging $stack [..]\r"
if {
wo stack purge --${stack} --force
- } >> /var/log/wo/test.log; then
+ } >>/var/log/wo/test.log; then
echo -ne " purging $stack [${CGREEN}OK${CEND}]\\r"
echo -ne '\n'
else
diff --git a/wo/cli/main.py b/wo/cli/main.py
index fc80c05..06c247c 100644
--- a/wo/cli/main.py
+++ b/wo/cli/main.py
@@ -49,15 +49,12 @@ class WOApp(CementApp):
# All built-in application bootstrapping (always run)
bootstrap = 'wo.cli.bootstrap'
- # Optional plugin bootstrapping (only run if plugin is enabled)
+ # Internal plugins (ship with application code)
plugin_bootstrap = 'wo.cli.plugins'
# Internal templates (ship with application code)
template_module = 'wo.cli.templates'
- # Internal plugins (ship with application code)
- plugin_bootstrap = 'wo.cli.plugins'
-
extensions = ['mustache']
# default output handler
@@ -73,18 +70,23 @@ class WOApp(CementApp):
class WOTestApp(WOApp):
"""A test app that is better suited for testing."""
class Meta:
+ # default argv to empty (don't use sys.argv)
argv = []
+
+ # don't look for config files (could break tests)
config_files = []
- exit_on_close = True
+
+ # don't call sys.exit() when app.close() is called in tests
+ exit_on_close = False
# Define the applicaiton object outside of main, as some libraries might wish
# to import it as a global (rather than passing it into another class/func)
-# app = WOApp()
+app = WOApp()
def main():
- with WOApp() as app:
+ with app:
try:
global sys
@@ -99,7 +101,7 @@ def main():
app.exit_code = 1
except exc.WOError as e:
# Catch our application errors and exit 1 (error)
- print(e)
+ print('WOError > %s' % e)
app.exit_code = 1
except FrameworkError as e:
# Catch framework errors and exit 1 (error)
diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py
index b21257e..0efd01c 100644
--- a/wo/cli/plugins/stack.py
+++ b/wo/cli/plugins/stack.py
@@ -87,6 +87,9 @@ class WOStackController(CementBaseController):
action='store_true')),
(['--cheat'],
dict(help='Install cheat.sh', action='store_true')),
+ (['--nanorc'],
+ dict(help='Install nanorc syntax highlighting',
+ action='store_true')),
(['--force'],
dict(help='Force install/remove/purge without prompt',
action='store_true')),
@@ -118,7 +121,7 @@ class WOStackController(CementBaseController):
(not pargs.adminer) and (not pargs.utils) and
(not pargs.redis) and (not pargs.proftpd) and
(not pargs.extplorer) and (not pargs.clamav) and
- (not pargs.cheat) and
+ (not pargs.cheat) and (not pargs.nanorc) and
(not pargs.ufw) and (not pargs.ngxblocker) and
(not pargs.phpredisadmin) and (not pargs.sendmail) and
(not pargs.php73)):
@@ -306,7 +309,7 @@ class WOStackController(CementBaseController):
Log.debug(self, "phpMyAdmin already installed")
Log.info(self, "phpMyAdmin already installed")
- # PHPREDISADMIN
+ # PHPREDISADMIN
if pargs.phpredisadmin:
pargs.composer = True
if not os.path.isdir('/var/www/22222/htdocs/'
@@ -325,8 +328,7 @@ class WOStackController(CementBaseController):
# Composer
if pargs.composer:
- if ((not WOAptGet.is_installed(self, 'php7.2-fpm')) and
- (not WOAptGet.is_installed(self, 'php7.3-fpm'))):
+ if not WOShellExec.cmd_exec(self, 'php -v'):
pargs.php = True
if not os.path.isfile('/usr/local/bin/composer'):
Log.debug(self, "Setting packages variable for Composer ")
@@ -459,6 +461,11 @@ class WOStackController(CementBaseController):
"/etc/bash_completion.d/cht.sh",
"bash_completion"]]
+ if pargs.nanorc:
+ if not os.path.exists('/usr/share/nano-syntax-highlighting'):
+ Log.debug(self, "Setting packages variable for nanorc")
+ apt_packages = apt_packages + ['nano']
+
# UTILS
if pargs.utils:
Log.debug(self, "Setting packages variable for utils")
@@ -466,26 +473,22 @@ class WOStackController(CementBaseController):
"https://raw.githubusercontent.com"
"/rtCamp/eeadmin/master/cache/nginx/"
"clean.php",
- "{0}22222/htdocs/cache/"
- "nginx/clean.php"
+ "{0}22222/htdocs/cache/nginx/clean.php"
.format(WOVar.wo_webroot),
"clean.php"],
["https://raw.github.com/rlerdorf/"
"opcache-status/master/opcache.php",
- "{0}22222/htdocs/cache/"
- "opcache/opcache.php"
+ "{0}22222/htdocs/cache/opcache/opcache.php"
.format(WOVar.wo_webroot),
"opcache.php"],
["https://raw.github.com/amnuts/"
"opcache-gui/master/index.php",
- "{0}22222/htdocs/"
- "cache/opcache/opgui.php"
+ "{0}22222/htdocs/cache/opcache/opgui.php"
.format(WOVar.wo_webroot),
"Opgui"],
["https://raw.githubusercontent.com/"
"mlazarov/ocp/master/ocp.php",
- "{0}22222/htdocs/cache/"
- "opcache/ocp.php"
+ "{0}22222/htdocs/cache/opcache/ocp.php"
.format(WOVar.wo_webroot),
"OCP.php"],
["https://github.com/jokkedk/webgrind/"
@@ -557,12 +560,11 @@ class WOStackController(CementBaseController):
(not pargs.adminer) and (not pargs.utils) and
(not pargs.redis) and (not pargs.proftpd) and
(not pargs.extplorer) and (not pargs.clamav) and
- (not pargs.cheat) and
+ (not pargs.cheat) and (not pargs.nanorc) and
(not pargs.ufw) and (not pargs.ngxblocker) and
(not pargs.phpredisadmin) and (not pargs.sendmail) and
(not pargs.php73)):
- pargs.web = True
- pargs.admin = True
+ self.app.args.print_help()
if pargs.all:
pargs.web = True
@@ -573,6 +575,7 @@ class WOStackController(CementBaseController):
pargs.utils = True
pargs.redis = True
pargs.security = True
+ pargs.nanorc = True
packages = packages + ['/var/www/22222/htdocs']
if pargs.web:
@@ -670,7 +673,14 @@ class WOStackController(CementBaseController):
if pargs.ufw:
if WOAptGet.is_installed(self, 'ufw'):
Log.debug(self, "Remove apt_packages variable for UFW")
- apt_packages = apt_packages + ["ufw"]
+ WOShellExec.cmd_exec(self, 'ufw disable && ufw --force reset')
+
+ # nanorc
+ if pargs.nanorc:
+ if os.path.exists('/usr/share/nano-syntax-highlighting'):
+ Log.debug(self, "Add nano to apt_packages list")
+ packages = packages + \
+ ["/usr/share/nano-syntax-highlighting"]
# WPCLI
if pargs.wpcli:
@@ -787,18 +797,29 @@ class WOStackController(CementBaseController):
WOShellExec.cmd_exec(
self, "bash /usr/"
"libexec/netdata/"
- "netdata-uninstaller.sh -y -f")
+ "netdata-uninstaller.sh -y -f",
+ errormsg='', log=False)
else:
WOShellExec.cmd_exec(
self, "bash /opt/netdata/usr/"
"libexec/netdata/"
- "netdata-uninstaller.sh - y - f",
+ "netdata-uninstaller.sh -y -f",
errormsg='', log=False)
if (packages):
Log.wait(self, "Removing packages ")
WOFileUtils.remove(self, packages)
Log.valide(self, "Removing packages ")
+
+ if '/usr/share/nano-syntax-highlighting' in packages:
+ # removing include line from nanorc
+ WOShellExec.cmd_exec(
+ self, 'grep -v "nano-syntax-highlighting" '
+ '/etc/nanorc > /etc/nanorc.new')
+ WOFileUtils.rm(self, '/etc/nanorc')
+ WOFileUtils.mvfile(
+ self, '/etc/nanorc.new', '/etc/nanorc')
+
if (apt_packages):
Log.debug(self, "Removing apt_packages")
Log.wait(self, "Removing APT packages ")
@@ -825,13 +846,11 @@ class WOStackController(CementBaseController):
(not pargs.adminer) and (not pargs.utils) and
(not pargs.redis) and (not pargs.proftpd) and
(not pargs.extplorer) and (not pargs.clamav) and
- (not pargs.cheat) and
+ (not pargs.cheat) and (not pargs.nanorc) and
(not pargs.ufw) and (not pargs.ngxblocker) and
(not pargs.phpredisadmin) and (not pargs.sendmail) and
(not pargs.php73)):
- pargs.web = True
- pargs.admin = True
- pargs.security = True
+ self.app.args.print_help()
if pargs.all:
pargs.web = True
@@ -932,7 +951,7 @@ class WOStackController(CementBaseController):
if pargs.ufw:
if WOAptGet.is_installed(self, 'ufw'):
Log.debug(self, "Add UFW to apt_packages list")
- apt_packages = apt_packages + ["ufw"]
+ WOShellExec.cmd_exec(self, 'ufw disable && ufw --force reset')
# sendmail
if pargs.sendmail:
@@ -946,6 +965,13 @@ class WOStackController(CementBaseController):
Log.debug(self, "Add Proftpd to apt_packages list")
apt_packages = apt_packages + ["proftpd-basic"]
+ # nanorc
+ if pargs.nanorc:
+ if os.path.exists('/usr/share/nano-syntax-highlighting'):
+ Log.debug(self, "Add nano to apt_packages list")
+ packages = packages + \
+ ["/usr/share/nano-syntax-highlighting"]
+
# WP-CLI
if pargs.wpcli:
if os.path.isfile('/usr/local/bin/wp'):
@@ -1075,11 +1101,20 @@ class WOStackController(CementBaseController):
WOAptGet.remove(self, apt_packages, purge=True)
WOAptGet.auto_remove(self)
Log.valide(self, "Purging APT Packages ")
-
if (packages):
Log.wait(self, "Purging Packages ")
WOFileUtils.remove(self, packages)
Log.valide(self, "Purging Packages ")
+
+ if '/usr/share/nano-syntax-highlighting' in packages:
+ # removing include line from nanorc
+ WOShellExec.cmd_exec(
+ self, 'grep -v "nano-syntax-highlighting" '
+ '/etc/nanorc > /etc/nanorc.new')
+ WOFileUtils.rm(self, '/etc/nanorc')
+ WOFileUtils.mvfile(
+ self, '/etc/nanorc.new', '/etc/nanorc')
+
Log.info(self, "Successfully purged packages")
diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py
index 50001fd..c1bf59b 100644
--- a/wo/cli/plugins/stack_pref.py
+++ b/wo/cli/plugins/stack_pref.py
@@ -44,25 +44,18 @@ def pre_pref(self, apt_packages):
# generate random 24 characters root password
chars = ''.join(random.sample(string.ascii_letters, 24))
- # configure MySQL non-interactive install
- if ((WOVar.wo_distro == 'raspbian') and
- (WOVar.wo_platform_codename == 'stretch')):
- mariadb_ver = '10.1'
- else:
- mariadb_ver = '10.3'
-
Log.debug(self, "Pre-seeding MySQL")
Log.debug(self, "echo \"mariadb-server-{0} "
"mysql-server/root_password "
"password \" | "
"debconf-set-selections"
- .format(mariadb_ver))
+ .format(WOVar.mariadb_ver))
try:
WOShellExec.cmd_exec(self, "echo \"mariadb-server-{0} "
"mysql-server/root_password "
"password {chars}\" | "
"debconf-set-selections"
- .format(mariadb_ver, chars=chars),
+ .format(WOVar.mariadb_ver, chars=chars),
log=False)
except CommandExecutionError as e:
Log.debug(self, "{0}".format(e))
@@ -72,13 +65,13 @@ def pre_pref(self, apt_packages):
"mysql-server/root_password_again "
"password \" | "
"debconf-set-selections"
- .format(mariadb_ver))
+ .format(WOVar.mariadb_ver))
try:
WOShellExec.cmd_exec(self, "echo \"mariadb-server-{0} "
"mysql-server/root_password_again "
"password {chars}\" | "
"debconf-set-selections"
- .format(mariadb_ver, chars=chars),
+ .format(WOVar.mariadb_ver, chars=chars),
log=False)
except CommandExecutionError as e:
Log.debug(self, "{0}".format(e))
@@ -112,7 +105,7 @@ def pre_pref(self, apt_packages):
else:
if not WOFileUtils.grepcheck(
self, '/etc/apt/sources.list/wo-repo.list',
- 'download.opensuse.org'):
+ 'WordOps'):
Log.info(self, "Adding repository for NGINX, please wait...")
Log.debug(self, 'Adding repository for Nginx')
WORepo.add(self, repo_url=WOVar.wo_nginx_repo)
@@ -160,11 +153,23 @@ def pre_pref(self, apt_packages):
else:
if not WOFileUtils.grepcheck(
self, '/etc/apt/sources.list/wo-repo.list',
- 'download.opensuse.org'):
+ 'WordOps'):
Log.info(self, "Adding repository for Redis, please wait...")
- WORepo.add(self, repo_url=WOVar.wo_php_repo)
+ WORepo.add(self, repo_url=WOVar.wo_nginx_repo)
WORepo.add_key(self, WOVar.wo_nginx_key)
+ # nano
+ if 'nano' in apt_packages:
+ if WOVar.wo_distro == 'ubuntu':
+ if (WOVar.wo_platform_codename == 'bionic' or
+ WOVar.wo_platform_codename == 'xenial'):
+ if not os.path.exists(
+ '/etc/apt/sources.list.d/'
+ 'jonathonf-ubuntu-backports-{0}.list'
+ .format(WOVar.wo_platform_codename)):
+ Log.debug(self, 'Adding ppa for nano')
+ WORepo.add(self, ppa=WOVar.wo_ubuntu_backports)
+
def post_pref(self, apt_packages, packages, upgrade=False):
"""Post activity after installation of packages"""
@@ -1072,6 +1077,20 @@ def post_pref(self, apt_packages, packages, upgrade=False):
comment='ClamAV freshclam cronjob '
'added by WordOps')
+ # nanorc
+ if 'nano' in apt_packages:
+ Log.debug(self, 'Setting up nanorc')
+ WOGit.clone(self, 'https://github.com/scopatz/nanorc.git',
+ '/usr/share/nano-syntax-highlighting')
+ if os.path.exists('/etc/nanorc'):
+ Log.debug(
+ self, 'including nano syntax highlighting to /etc/nanorc')
+ if not WOFileUtils.grepcheck(self, '/etc/nanorc',
+ 'nano-syntax-highlighting'):
+ WOFileUtils.textappend(
+ self, '/etc/nanorc', 'include /usr/share/'
+ 'nano-syntax-highlighting/*.nanorc')
+
if (packages):
# WP-CLI
if any('/usr/local/bin/wp' == x[1] for x in packages):
diff --git a/wo/cli/plugins/stack_upgrade.py b/wo/cli/plugins/stack_upgrade.py
index 64e75e1..c25a0e7 100644
--- a/wo/cli/plugins/stack_upgrade.py
+++ b/wo/cli/plugins/stack_upgrade.py
@@ -200,7 +200,7 @@ class WOStackUpgradeController(CementBaseController):
# ngxblocker
if pargs.ngxblocker:
- if os.path.exists('/usr/local/sbin/update-ngxblocker'):
+ if os.path.exists('/usr/local/sbin/install-ngxblocker'):
packages = packages + [[
'https://raw.githubusercontent.com/mitchellkrogza/'
'nginx-ultimate-bad-bot-blocker/master/update-ngxblocker',
diff --git a/wo/cli/plugins/update.py b/wo/cli/plugins/update.py
index 013d1d6..879ec56 100644
--- a/wo/cli/plugins/update.py
+++ b/wo/cli/plugins/update.py
@@ -62,7 +62,7 @@ class WOUpdateController(CementBaseController):
if ((not pargs.force) and (not pargs.travis) and
(not pargs.mainline) and (not pargs.beta) and
(not pargs.branch)):
- wo_current = WOVar.wo_version
+ wo_current = ("v{0}".format(WOVar.wo_version))
wo_latest = WODownload.latest_release(self, "WordOps/WordOps")
if wo_current == wo_latest:
Log.error(
diff --git a/wo/cli/templates/wo-update.mustache b/wo/cli/templates/wo-update.mustache
index 6ad2c01..f1ab266 100644
--- a/wo/cli/templates/wo-update.mustache
+++ b/wo/cli/templates/wo-update.mustache
@@ -33,5 +33,8 @@ if [ -n "$CURRENT_RELEASE" ] && [ -n "$LATEST_RELEASE" ]; then
safe_print "$NEWS"
# Try to update the cache
safe_print "$NEWS" 2> /dev/null > $CACHE || true
- fi
+ else
+ # clean news
+ echo '' > "$NEWS" 2> "$ERR"
+ safe_print "$NEWS" 2> /dev/null > $CACHE || true
fi
diff --git a/wo/core/acme.py b/wo/core/acme.py
index 8196238..883559b 100644
--- a/wo/core/acme.py
+++ b/wo/core/acme.py
@@ -172,7 +172,7 @@ class WOAcme:
reader = csv.reader(certfile, 'acmeconf')
for row in reader:
# check if domain exist
- if wo_domain_name in row[0]:
+ if wo_domain_name == row[0]:
# check if cert expiration exist
if not row[3] == '':
return True
diff --git a/wo/core/fileutils.py b/wo/core/fileutils.py
index 7b70f5c..d1f1410 100644
--- a/wo/core/fileutils.py
+++ b/wo/core/fileutils.py
@@ -368,4 +368,4 @@ class WOFileUtils():
final_file.write('{0}'.format(content))
except IOError as e:
Log.debug(self, "{0}".format(e))
- Log.error(self, "Unable to write content in {0}".format(path))
+ Log.error(self, "Unable to append content in {0}".format(path))
diff --git a/wo/core/git.py b/wo/core/git.py
index 5bf903f..fc36c0f 100644
--- a/wo/core/git.py
+++ b/wo/core/git.py
@@ -83,3 +83,20 @@ class WOGit:
.format(path))
else:
Log.debug(self, "WOGit: Path {0} not present".format(path))
+
+ def clone(self, repo, path, branch='master'):
+ """Equivalent to git clone """
+ if not os.path.exists('{0}'.format(path)):
+ global git
+ try:
+ git.clone(
+ '{0}'.format(repo),
+ '{0}'.format(path),
+ '--branch={0}'.format(branch),
+ '--depth=1')
+ except ErrorReturnCode as e:
+ Log.debug(self, "{0}".format(e))
+ Log.error(self, "Unable to git clone at {0} "
+ .format(path))
+ else:
+ Log.debug(self, "WOGit: Path {0} already exist".format(path))
diff --git a/wo/core/shellexec.py b/wo/core/shellexec.py
index 3fb638c..38eeb42 100644
--- a/wo/core/shellexec.py
+++ b/wo/core/shellexec.py
@@ -37,6 +37,27 @@ class WOShellExec():
Log.debug(self, str(e))
raise CommandExecutionError
+ def cmd_exist(self, command):
+ """Check if a command exist with command -v"""
+ try:
+ Log.debug(self, "Testing command: {0}".format(command))
+ testing_command = ("command -v {0}".format(command))
+ with subprocess.Popen([testing_command], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, shell=True) as proc:
+ (cmd_stdout_bytes, cmd_stderr_bytes) = proc.communicate()
+ (cmd_stdout, cmd_stderr) = (
+ cmd_stdout_bytes.decode('utf-8', "replace"),
+ cmd_stderr_bytes.decode('utf-8', "replace"))
+ Log.debug(self, "Command Output: {0}, \nCommand Error: {1}"
+ .format(cmd_stdout, cmd_stderr))
+ return bool(proc.returncode == 0)
+ except OSError as e:
+ Log.debug(self, str(e))
+ raise CommandExecutionError
+ except Exception as e:
+ Log.debug(self, str(e))
+ raise CommandExecutionError
+
def invoke_editor(self, filepath, errormsg=''):
"""
Open files using sensible editor
diff --git a/wo/core/sslutils.py b/wo/core/sslutils.py
index 1202c18..a63f975 100644
--- a/wo/core/sslutils.py
+++ b/wo/core/sslutils.py
@@ -63,7 +63,7 @@ class SSL:
self, '{0}/htdocs/'.format(wo_site_webroot))
if WOShellExec.cmd_exec(
self, "{0} --allow-root core is-installed"
- .format(WOVar.wo_wp_cli)):
+ .format(WOVar.wo_wpcli_path)):
wo_siteurl = (
WOShellExec.cmd_exec_stdout(
self, "{0} option get siteurl "
@@ -75,17 +75,17 @@ class SSL:
try:
WOShellExec.cmd_exec(
self, "{0} option update siteurl "
- "\'https://{1}\' --allow-root".format(
- WOVar.wo_wpcli_path, domain))
+ "\'https://{1}\' --allow-root"
+ .format(WOVar.wo_wpcli_path, domain))
WOShellExec.cmd_exec(
self, "{0} option update home "
- "\'https://{1}\' --allow-root".format(
- WOVar.wo_wpcli_path, domain))
+ "\'https://{1}\' --allow-root"
+ .format(WOVar.wo_wpcli_path, domain))
WOShellExec.cmd_exec(
- self, "{0} search-replace \'http://{0}\'"
- "\'https://{0}\' --skip-columns=guid "
+ self, "{0} search-replace \'http://{1}\'"
+ "\'https://{1}\' --skip-columns=guid "
"--skip-tables=wp_users"
- .format(domain))
+ .format(WOVar.wo_wpcli_path, domain))
except Exception as e:
Log.debug(self, str(e))
Log.failed(self, "Updating site url with https")
diff --git a/wo/core/variables.py b/wo/core/variables.py
index 9cdc430..437caec 100644
--- a/wo/core/variables.py
+++ b/wo/core/variables.py
@@ -14,7 +14,7 @@ class WOVar():
"""Intialization of core variables"""
# WordOps version
- wo_version = "3.10.1"
+ wo_version = "3.10.2"
# WordOps packages versions
wo_wp_cli = "2.3.0"
wo_adminer = "4.7.3"
@@ -149,7 +149,12 @@ class WOVar():
wo_mysql = ["mariadb-server", "percona-toolkit"]
if wo_distro == 'raspbian':
wo_mysql = wo_mysql + ["python3-mysqldb"]
+ if wo_platform_codename == 'stretch':
+ mariadb_ver = '10.1'
+ else:
+ mariadb_ver = '10.3'
else:
+ mariadb_ver = '10.3'
if wo_platform_codename == 'jessie':
wo_mysql = wo_mysql + ["python3-mysql.connector"]
else:
@@ -163,6 +168,7 @@ class WOVar():
wo_fail2ban = ["fail2ban"]
wo_clamav = ["clamav", "clamav-freshclam"]
+ wo_ubuntu_backports = 'ppa:jonathonf/backports'
# Redis repo details
if wo_distro == 'ubuntu':
diff --git a/wo/utils/test.py b/wo/utils/test.py
index d737fdd..920fd62 100644
--- a/wo/utils/test.py
+++ b/wo/utils/test.py
@@ -1,5 +1,5 @@
"""Testing utilities for WordOps"""
-from cement.utils.test import CementTestCase
+from cement.utils.test import *
from wo.cli.main import WOTestApp