Refactor install

* remove all tweaking sections
* integrate them directly in wo
* add pip install from github repo
This commit is contained in:
VirtuBox
2019-10-23 12:24:30 +02:00
parent 3f259ca185
commit 5584d90a25
6 changed files with 38 additions and 102 deletions

View File

@@ -49,7 +49,7 @@ class WORepo():
Log.error(self, "Unable to add repo")
if ppa is not None:
if WOShellExec.cmd_exec(
self, "LC_ALL=C.UTF-8 add-apt-repository -yu '{ppa_name}'"
self, "LC_ALL=C.UTF-8 add-apt-repository -y '{ppa_name}'"
.format(ppa_name=ppa)):
return True
return False
@@ -70,7 +70,7 @@ class WORepo():
WOVar().wo_repo_file)
try:
repofile = open(repo_file_path, "w+")
repofile = open(repo_file_path, "w+", encoding='utf-8')
repofile.write(repofile.read().replace(repo_url, ""))
repofile.close()
except IOError as e:
@@ -96,19 +96,14 @@ class WORepo():
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to import repo key")
def add_keys(self, keyids, keyserver=None):
def download_key(self, key_url):
"""
This function adds imports repository keys from keyserver.
default keyserver is hkp://keyserver.ubuntu.com
user can provide other keyserver with keyserver="hkp://xyz"
This function download gpg keys and add import them with apt-key add"
"""
all_keys = ' '.join(keyids)
try:
WOShellExec.cmd_exec(
self, "apt-key adv --keyserver {serv}"
.format(serv=(keyserver or
"hkp://keyserver.ubuntu.com")) +
" --recv-keys {keys}".format(keys=all_keys))
self, "curl -sL {0} ".format(key_url) +
"| apt-key add -")
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to import repo keys")

View File

@@ -4,6 +4,7 @@ import os
from datetime import datetime
from re import match
from socket import getfqdn
from shutil import copy2
from distro import linux_distribution
from sh import git
@@ -28,16 +29,18 @@ class WOVar():
wo_date = datetime.now().strftime('%d%b%Y-%H-%M-%S')
# WordOps core variables
# linux distribution
wo_distro = linux_distribution(
full_distribution_name=False)[0].lower()
wo_platform_version = linux_distribution(
full_distribution_name=False)[1].lower()
# distro codename (bionic, xenial, stretch ...)
wo_platform_codename = linux_distribution(
full_distribution_name=False)[2].lower()
# Get timezone of system
if os.path.isfile('/etc/timezone'):
with open("/etc/timezone", "r") as tzfile:
with open("/etc/timezone", mode='r', encoding='utf-8') as tzfile:
wo_timezone = tzfile.read().replace('\n', '')
if wo_timezone == "Etc/UTC":
wo_timezone = "UTC"
@@ -59,7 +62,7 @@ class WOVar():
# PHP user
wo_php_user = 'www-data'
# Get git user name and EMail
# WordOps git configuration management
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.gitconfig')
try:
@@ -86,6 +89,9 @@ class WOVar():
git.config("--global", "user.name", "{0}".format(wo_user))
git.config("--global", "user.email", "{0}".format(wo_email))
if not os.path.isfile('/root/.gitconfig'):
copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig')
# MySQL hostname
wo_mysql_host = ""
config = configparser.RawConfigParser()