Refactor install
* remove all tweaking sections * integrate them directly in wo * add pip install from github repo
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import codecs
|
||||
import configparser
|
||||
import os
|
||||
import random
|
||||
@@ -7,11 +6,8 @@ import string
|
||||
|
||||
import psutil
|
||||
import requests
|
||||
from wo.cli.plugins.site_functions import *
|
||||
from wo.cli.plugins.stack_services import WOStackStatusController
|
||||
from wo.core.apt_repo import WORepo
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.checkfqdn import check_fqdn_ip
|
||||
from wo.core.cron import WOCron
|
||||
from wo.core.extract import WOExtract
|
||||
from wo.core.fileutils import WOFileUtils
|
||||
@@ -489,6 +485,16 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
"the cause of this issue", False)
|
||||
else:
|
||||
WOGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git")
|
||||
if not os.path.isdir('/etc/systemd/system/nginx.service.d'):
|
||||
WOFileUtils.mkdir('/etc/systemd/system/nginx.service.d')
|
||||
if not os.path.isdir(
|
||||
'/etc/systemd/system/nginx.service.d/limits.conf'):
|
||||
with open(
|
||||
'/etc/systemd/system/nginx.service.d/limits.conf',
|
||||
encoding='utf-8', mode='w') as ngx_limit:
|
||||
ngx_limit.write('[Service]\nLimitNOFILE=500000')
|
||||
WOShellExec.cmd_exec(self, 'systemctl daemon-reload')
|
||||
WOService.restart_service(self, 'nginx')
|
||||
|
||||
if set(WOVar.wo_php).issubset(set(apt_packages)):
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
@@ -1415,7 +1421,7 @@ def pre_stack(self):
|
||||
self, '/lib/systemd/system/wo-kernel.service',
|
||||
'wo-kernel-service.mustache', data)
|
||||
WOShellExec.cmd_exec(self, 'systemctl enable wo-kernel.service')
|
||||
WOShellExec.cmd_exec(self, 'systemctl start wo-kernel.service')
|
||||
WOService.start_service(self, 'wo-kernel')
|
||||
# open_files_limit tweak
|
||||
if not WOFileUtils.grepcheck(self, '/etc/security/limits.conf', '500000'):
|
||||
with open("/etc/security/limits.conf",
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user