From 0c59efd90ff053ad7d3c53592119ca6132d8658d Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 2 Nov 2019 19:37:52 +0100 Subject: [PATCH] Fix nanorc --- wo/cli/plugins/stack.py | 5 ----- wo/cli/plugins/stack_pref.py | 29 +++++++++++++++-------------- wo/core/git.py | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 4f5dab5..b3ec745 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -465,11 +465,6 @@ class WOStackController(CementBaseController): if not os.path.exists('/usr/share/nano-syntax-highlighting'): Log.debug(self, "Setting packages variable for nanorc") apt_packages = apt_packages + ['nano'] - packages = [ - ['https://github.com/scopatz/' - 'nanorc/archive/master.tar.gz', - '/var/lib/wo/tmp/nanorc.tar.gz', - 'nanorc']] # UTILS if pargs.utils: diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index 376ca29..b03f225 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -175,7 +175,7 @@ def pre_pref(self, apt_packages): 'jonathonf-ubuntu-backports-{0}.list' .format(WOVar.wo_platform_codename)): Log.debug(self, 'Adding ppa for nano') - WORepo.add(self, repo_url=WOVar.wo_ubuntu_backports) + WORepo.add(self, ppa=WOVar.wo_ubuntu_backports) def post_pref(self, apt_packages, packages, upgrade=False): @@ -1084,6 +1084,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): @@ -1437,19 +1451,6 @@ def post_pref(self, apt_packages, packages, upgrade=False): WOFileUtils.chmod( self, "/usr/local/sbin/update-ngxblocker", 0o700) - if any('/var/lib/wo/tmp/nanorc.tar.gz' == x[1] - for x in packages): - WOExtract.extract(self, '/var/lib/wo/tmp/nanorc.tar.gz', - '/var/lib/wo/tmp/') - WOFileUtils.mvfile(self, '/var/lib/wo/tmp/nanorc-master', - '/usr/share/nano-syntax-highlighting') - if os.path.exists('/etc/nanorc'): - Log.debug( - self, 'including nano syntax highlighting to /etc/nanorc') - WOFileUtils.textappend( - self, '/etc/nanorc', 'include /usr/share/' - 'nano-syntax-highlighting/*.nanorc') - def pre_stack(self): """Inital server configuration and tweak""" 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))