From 295b8420cfec70b0b2b4c72b56e1b25da73e2e53 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 26 Oct 2020 14:21:04 +0100 Subject: [PATCH] Fix virtualenv configuration --- CHANGELOG.md | 4 +++ install | 67 ++++++++++++++++++++++++++++++++---------- wo/cli/plugins/site.py | 5 +++- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f7b6a..94cc0ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### v3.9.x - [Unreleased] +#### Fixed + +- Python virtualenv configuration + #### v3.13.0 - 2020-10-25 #### Added diff --git a/install b/install index c5b8714..22b0352 100755 --- a/install +++ b/install @@ -209,13 +209,15 @@ wo_install_dep() { # install dependencies apt-get -option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \ build-essential curl gzip python3-pip python3-apt python3-venv gcc python3-dev sqlite3 git tar software-properties-common pigz \ - gnupg2 cron ccze rsync apt-transport-https tree haveged ufw unattended-upgrades tzdata ntp zstd idn >/dev/null 2>&1 + gnupg2 cron ccze rsync apt-transport-https tree haveged ufw unattended-upgrades tzdata ntp zstd idn \ + python3-distutils-extra libapt-pkg-dev >/dev/null 2>&1 curl -sL https://download.opensuse.org/repositories/home:/virtubox:/WordOps/xUbuntu_18.04/Release.key | apt-key add - else # install dependencies apt-get -option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \ build-essential curl gzip dirmngr sudo python3-pip python3-apt python3-venv gcc python3-dev ca-certificates sqlite3 git tar \ - software-properties-common pigz apt-transport-https gnupg2 cron ccze rsync tree haveged ufw unattended-upgrades tzdata ntp zstd idn >/dev/null 2>&1 + software-properties-common pigz apt-transport-https gnupg2 cron ccze rsync tree haveged ufw unattended-upgrades tzdata ntp zstd idn \ + python3-distutils-extra libapt-pkg-dev >/dev/null 2>&1 # add php repository gpg key [ -d /etc/apt/trusted.gpg.d ] && { wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg; } # add nginx repository gpg key @@ -427,22 +429,41 @@ wo_install_acme_sh() { wo_install() { local python_ver python_ver=$(python3 -c "import sys; print(sys.version_info[1])") + local wo_distro_codename + wo_distro_codename=$(lsb_release -sc) + local wo_linux_distro + wo_linux_distro=$(lsb_release -is) if [ -d /usr/local/lib/python3."$python_ver"/dist-packages ]; then cd /usr/local/lib/python3."$python_ver"/dist-packages || exit 1 fi python3 -m pip uninstall -yq wo wordops ee - if [ -d /opt/wo ]; then - cd /opt/wo || exit 1 - source bin/activate + if [ -d /opt/wo/lib/python3."$python_ver"/site-packages/apt ]; then + source /opt/wo/bin/activate + python3 -m pip install -U pip setuptools wheel else - mkdir -p /opt/wo - cd /opt || exit 1 - python3 -m venv --system-site-packages wo - source wo/bin/activate + rm -rf /opt/wo + python3 -m venv /opt/wo + source /opt/wo/bin/activate + python3 -m pip install -U pip setuptools wheel + if [ "$wo_linux_distro" = "Debian" ] || [ "$wo_linux_distro" = "Raspbian" ]; then + if [ "$wo_distro_codename" = "strech" ]; then + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.4.y#egg=python-apt + else + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.8.4.y#egg=python-apt + fi + else + if [ "$wo_distro_codename" = "focal" ]; then + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.0.0#egg=python-apt + elif [ "$wo_distro_codename" = "bionic" ]; then + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.6.y#egg=python-apt + else + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.1.y-xenial#egg=python-apt + fi + fi fi - python3 -m pip install -U pip setuptools wheel + if [ "$wo_branch" = "master" ]; then - python3 -m pip install -I wordops + python3 -m pip install -U wordops else python3 -m pip install -I "git+git://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops" fi @@ -462,14 +483,30 @@ wo_travis_install() { rm -rf dist fi if [ -f ./setup.py ]; then - if [ -d /opt/wo ]; then + if [ -d /opt/wo/lib/python3."$python_ver"/site-packages/apt ]; then source /opt/wo/bin/activate + python3 -m pip install -U pip setuptools wheel else - mkdir -p /opt/wo - python3 -m venv --system-site-packages /opt/wo + rm -rf /opt/wo + python3 -m venv /opt/wo source /opt/wo/bin/activate + python3 -m pip install -U pip setuptools wheel + if [ "$wo_linux_distro" = "Debian" ] || [ "$wo_linux_distro" = "Raspbian" ]; then + if [ "$wo_distro_codename" = "strech" ]; then + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.4.y#egg=python-apt + else + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.8.4.y#egg=python-apt + fi + else + if [ "$wo_distro_codename" = "focal" ]; then + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.0.0#egg=python-apt + elif [ "$wo_distro_codename" = "bionic" ]; then + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.6.y#egg=python-apt + else + python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.1.y-xenial#egg=python-apt + fi + fi fi - python3 -m pip install -U pip setuptools wheel python3 -m pip install -U . else python3 -m pip install -U "git+git://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops" diff --git a/wo/cli/plugins/site.py b/wo/cli/plugins/site.py index 34033e5..fec615c 100644 --- a/wo/cli/plugins/site.py +++ b/wo/cli/plugins/site.py @@ -444,7 +444,10 @@ class WOSiteDeleteController(CementBaseController): # TODO Delete nginx conf removeNginxConf(self, wo_domain) deleteSiteInfo(self, wo_domain) - WOAcme.removeconf(self, wo_domain) + # To improve + if not WOFileUtils.grepcheck( + self, '/var/www/22222/conf/nginx/ssl.conf', wo_domain): + WOAcme.removeconf(self, wo_domain) Log.info(self, "Deleted site {0}".format(wo_domain))