From a96baa05f4310b59ed279636dd49d13e8afb4dda Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Tue, 5 Nov 2019 17:37:42 +0100 Subject: [PATCH] Update Nanorc --- tests/travis.sh | 2 +- wo/cli/plugins/stack.py | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/tests/travis.sh b/tests/travis.sh index f42efdf..d1ac05b 100644 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -28,7 +28,7 @@ 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 { diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 762e429..7efc2fb 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -674,7 +674,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: @@ -804,6 +811,16 @@ class WOStackController(CementBaseController): 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 ") @@ -811,6 +828,8 @@ class WOStackController(CementBaseController): WOAptGet.auto_remove(self) Log.valide(self, "Removing APT packages ") + + Log.info(self, "Successfully removed packages") @expose(help="Purge packages") @@ -937,7 +956,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: @@ -951,6 +970,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'): @@ -1080,11 +1106,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")