Move variable wo_wan and change variable distro

This commit is contained in:
VirtuBox
2019-07-30 14:32:23 +02:00
parent 23bc63364d
commit 05fc7ba161
4 changed files with 21 additions and 23 deletions

View File

@@ -97,7 +97,7 @@ class WOStackController(CementBaseController):
if set(WOVariables.wo_mysql).issubset(set(apt_packages)): if set(WOVariables.wo_mysql).issubset(set(apt_packages)):
# add mariadb repository excepted on raspbian and ubuntu 19.04 # add mariadb repository excepted on raspbian and ubuntu 19.04
if (not WOVariables.wo_platform_distro == 'raspbian'): if (not WOVariables.wo_distro == 'raspbian'):
Log.info(self, "Adding repository for MySQL, please wait...") Log.info(self, "Adding repository for MySQL, please wait...")
mysql_pref = ("Package: *\nPin: origin " mysql_pref = ("Package: *\nPin: origin "
"sfo1.mirrors.digitalocean.com" "sfo1.mirrors.digitalocean.com"
@@ -115,7 +115,7 @@ class WOStackController(CementBaseController):
# generate random 24 characters root password # generate random 24 characters root password
chars = ''.join(random.sample(string.ascii_letters, 24)) chars = ''.join(random.sample(string.ascii_letters, 24))
# configure MySQL non-interactive install # configure MySQL non-interactive install
if (not WOVariables.wo_platform_distro == 'raspbian'): if (not WOVariables.wo_distro == 'raspbian'):
Log.debug(self, "Pre-seeding MySQL") Log.debug(self, "Pre-seeding MySQL")
Log.debug(self, "echo \"mariadb-server-10.3 " Log.debug(self, "echo \"mariadb-server-10.3 "
"mysql-server/root_password " "mysql-server/root_password "
@@ -196,7 +196,7 @@ class WOStackController(CementBaseController):
# add nginx repository # add nginx repository
if set(WOVariables.wo_nginx).issubset(set(apt_packages)): if set(WOVariables.wo_nginx).issubset(set(apt_packages)):
if (WOVariables.wo_platform_distro == 'ubuntu'): if (WOVariables.wo_distro == 'ubuntu'):
Log.info(self, "Adding repository for NGINX, please wait...") Log.info(self, "Adding repository for NGINX, please wait...")
WORepo.add(self, ppa=WOVariables.wo_nginx_repo) WORepo.add(self, ppa=WOVariables.wo_nginx_repo)
Log.debug(self, 'Adding ppa for Nginx') Log.debug(self, 'Adding ppa for Nginx')
@@ -209,7 +209,7 @@ class WOStackController(CementBaseController):
# add php repository # add php repository
if (set(WOVariables.wo_php73).issubset(set(apt_packages)) or if (set(WOVariables.wo_php73).issubset(set(apt_packages)) or
set(WOVariables.wo_php).issubset(set(apt_packages))): set(WOVariables.wo_php).issubset(set(apt_packages))):
if (WOVariables.wo_platform_distro == 'ubuntu'): if (WOVariables.wo_distro == 'ubuntu'):
Log.info(self, "Adding repository for PHP, please wait...") Log.info(self, "Adding repository for PHP, please wait...")
Log.debug(self, 'Adding ppa for PHP') Log.debug(self, 'Adding ppa for PHP')
WORepo.add(self, ppa=WOVariables.wo_php_repo) WORepo.add(self, ppa=WOVariables.wo_php_repo)
@@ -230,7 +230,7 @@ class WOStackController(CementBaseController):
# add redis repository # add redis repository
if set(WOVariables.wo_redis).issubset(set(apt_packages)): if set(WOVariables.wo_redis).issubset(set(apt_packages)):
Log.info(self, "Adding repository for Redis, please wait...") Log.info(self, "Adding repository for Redis, please wait...")
if WOVariables.wo_platform_distro == 'ubuntu': if WOVariables.wo_distro == 'ubuntu':
Log.debug(self, 'Adding ppa for redis') Log.debug(self, 'Adding ppa for redis')
WORepo.add(self, ppa=WOVariables.wo_redis_repo) WORepo.add(self, ppa=WOVariables.wo_redis_repo)
else: else:
@@ -1234,12 +1234,17 @@ class WOStackController(CementBaseController):
'wo-dashboard.tar.gz', 'wo-dashboard.tar.gz',
'{0}22222/htdocs' '{0}22222/htdocs'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
wo_wan = os.popen("/sbin/ip -4 route get 8.8.8.8 | "
"grep -oP \"dev [^[:space:]]+ \" "
"| cut -d ' ' -f 2").read()
if wo_wan == '':
wo_wan = 'eth0'
if WOVariables.wo_wan != 'eth0': if WOVariables.wo_wan != 'eth0':
WOFileUtils.searchreplace(self, "{0}22222/htdocs/index.php" WOFileUtils.searchreplace(self,
"{0}22222/htdocs/index.php"
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
"eth0", "eth0",
"{0}".format(WOVariables.wo_wan)) "{0}".format(WOVariables.wo_wan))
Log.debug(self, "Setting Privileges to " Log.debug(self, "Setting Privileges to "
"{0}22222/htdocs" "{0}22222/htdocs"
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))

View File

@@ -49,7 +49,7 @@ class WOStackUpgradeController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def upgrade_php56(self): def upgrade_php56(self):
if WOVariables.wo_platform_distro == "ubuntu": if WOVariables.wo_distro == "ubuntu":
if os.path.isfile("/etc/apt/sources.list.d/ondrej-php5-5_6-{0}." if os.path.isfile("/etc/apt/sources.list.d/ondrej-php5-5_6-{0}."
"list".format(WOVariables.wo_platform_codename)): "list".format(WOVariables.wo_platform_codename)):
Log.error(self, "Unable to find PHP 5.5") Log.error(self, "Unable to find PHP 5.5")
@@ -68,7 +68,7 @@ class WOStackUpgradeController(CementBaseController):
if start_upgrade != "Y" and start_upgrade != "y": if start_upgrade != "Y" and start_upgrade != "y":
Log.error(self, "Not starting PHP package update") Log.error(self, "Not starting PHP package update")
if WOVariables.wo_platform_distro == "ubuntu": if WOVariables.wo_distro == "ubuntu":
WORepo.remove(self, ppa="ppa:ondrej/php5") WORepo.remove(self, ppa="ppa:ondrej/php5")
WORepo.add(self, ppa=WOVariables.wo_php_repo) WORepo.add(self, ppa=WOVariables.wo_php_repo)

View File

@@ -12,7 +12,7 @@ def check_fqdn(self, wo_host):
WOShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts" WOShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts"
.format(wo_host)) .format(wo_host))
if WOVariables.wo_platform_distro == 'debian': if WOVariables.wo_distro == 'debian':
WOShellExec.cmd_exec(self, "/etc/init.d/hostname.sh start") WOShellExec.cmd_exec(self, "/etc/init.d/hostname.sh start")
else: else:
WOShellExec.cmd_exec(self, "service hostname restart") WOShellExec.cmd_exec(self, "service hostname restart")

View File

@@ -20,18 +20,11 @@ class WOVariables():
# Get WPCLI path # Get WPCLI path
wo_wpcli_path = '/usr/local/bin/wp' wo_wpcli_path = '/usr/local/bin/wp'
# get wan network interface name
wo_wan = os.popen("/sbin/ip -4 route get 8.8.8.8 | "
"grep -oP \"dev [^[:space:]]+ \" "
"| cut -d ' ' -f 2").read()
if wo_wan == '':
wo_wan = 'eth0'
# Current date and time of System # Current date and time of System
wo_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') wo_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S')
# WordOps core variables # WordOps core variables
wo_platform_distro = os.popen("/usr/bin/lsb_release -si " wo_distro = os.popen("/usr/bin/lsb_release -si "
"| tr -d \'\\n\'").read().lower() "| tr -d \'\\n\'").read().lower()
wo_platform_version = platform.linux_distribution()[1] wo_platform_version = platform.linux_distribution()[1]
wo_platform_codename = os.popen( wo_platform_codename = os.popen(
@@ -91,14 +84,14 @@ class WOVariables():
# WordOps stack installation variables # WordOps stack installation variables
# Nginx repo and packages # Nginx repo and packages
if wo_platform_distro == 'ubuntu': if wo_distro == 'ubuntu':
if wo_platform_codename == 'trusty': if wo_platform_codename == 'trusty':
wo_nginx_repo = ("deb http://download.opensuse.org" wo_nginx_repo = ("deb http://download.opensuse.org"
"/repositories/home:" "/repositories/home:"
"/virtubox:/WordOps/xUbuntu_14.04/ /") "/virtubox:/WordOps/xUbuntu_14.04/ /")
else: else:
wo_nginx_repo = "ppa:wordops/nginx-wo" wo_nginx_repo = "ppa:wordops/nginx-wo"
elif wo_platform_distro == 'debian': elif wo_distro == 'debian':
if wo_platform_codename == 'jessie': if wo_platform_codename == 'jessie':
wo_nginx_repo = ("deb http://download.opensuse.org" wo_nginx_repo = ("deb http://download.opensuse.org"
"/repositories/home:" "/repositories/home:"
@@ -119,7 +112,7 @@ class WOVariables():
wo_nginx_key = '188C9FB063F0247A' wo_nginx_key = '188C9FB063F0247A'
# PHP repo and packages # PHP repo and packages
if wo_platform_distro == 'ubuntu': if wo_distro == 'ubuntu':
wo_php_repo = "ppa:ondrej/php" wo_php_repo = "ppa:ondrej/php"
wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap", wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap",
"php7.2-readline", "php7.2-common", "php7.2-recode", "php7.2-readline", "php7.2-common", "php7.2-recode",
@@ -155,7 +148,7 @@ class WOVariables():
wo_php_key = 'AC0E47584A7A714D' wo_php_key = 'AC0E47584A7A714D'
# MySQL repo and packages # MySQL repo and packages
if wo_platform_distro == 'ubuntu': if wo_distro == 'ubuntu':
wo_mysql_repo = ("deb [arch=amd64,ppc64el] " wo_mysql_repo = ("deb [arch=amd64,ppc64el] "
"http://sfo1.mirrors.digitalocean.com/mariadb/repo/" "http://sfo1.mirrors.digitalocean.com/mariadb/repo/"
"10.3/ubuntu {codename} main" "10.3/ubuntu {codename} main"
@@ -170,7 +163,7 @@ class WOVariables():
wo_fail2ban = ["fail2ban"] wo_fail2ban = ["fail2ban"]
# Redis repo details # Redis repo details
if wo_platform_distro == 'ubuntu': if wo_distro == 'ubuntu':
wo_redis_repo = ("ppa:chris-lea/redis-server") wo_redis_repo = ("ppa:chris-lea/redis-server")
else: else: