Improve WordOps server ip check
This commit is contained in:
@@ -22,6 +22,7 @@ from wo.core.template import WOTemplate
|
|||||||
from wo.core.variables import WOVar
|
from wo.core.variables import WOVar
|
||||||
from wo.core.stackconf import WOConf
|
from wo.core.stackconf import WOConf
|
||||||
from wo.core.download import WODownload
|
from wo.core.download import WODownload
|
||||||
|
from wo.core.checkfqdn import WOFqdn
|
||||||
|
|
||||||
|
|
||||||
def pre_pref(self, apt_packages):
|
def pre_pref(self, apt_packages):
|
||||||
@@ -404,7 +405,9 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
"/var/www/22222/cert/22222.key;\n"
|
"/var/www/22222/cert/22222.key;\n"
|
||||||
"ssl_stapling off;\n")
|
"ssl_stapling off;\n")
|
||||||
|
|
||||||
server_ip = requests.get('http://v4.wordops.eu')
|
server_ip = WOFqdn.get_server_ip(self)
|
||||||
|
if server_ip is None:
|
||||||
|
server_ip = "0.0.0.0"
|
||||||
|
|
||||||
if set(["nginx"]).issubset(set(apt_packages)):
|
if set(["nginx"]).issubset(set(apt_packages)):
|
||||||
print("WordOps backend configuration was successful\n"
|
print("WordOps backend configuration was successful\n"
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ from wo.core.shellexec import WOShellExec
|
|||||||
from wo.core.variables import WOVar
|
from wo.core.variables import WOVar
|
||||||
|
|
||||||
|
|
||||||
|
class WOFqdn:
|
||||||
|
"""IP and FQDN tools for WordOps"""
|
||||||
|
|
||||||
def check_fqdn(self, wo_host):
|
def check_fqdn(self, wo_host):
|
||||||
"""FQDN check with WordOps, for mail server hostname must be FQDN"""
|
"""FQDN check with WordOps, for mail server hostname must be FQDN"""
|
||||||
# wo_host=os.popen("hostname -f | tr -d '\n'").read()
|
# wo_host=os.popen("hostname -f | tr -d '\n'").read()
|
||||||
@@ -21,11 +24,11 @@ def check_fqdn(self, wo_host):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
wo_host = input("Enter hostname [fqdn]:")
|
wo_host = input("Enter hostname [fqdn]:")
|
||||||
check_fqdn(self, wo_host)
|
WOFqdn.check_fqdn(self, wo_host)
|
||||||
|
|
||||||
|
|
||||||
def check_fqdn_ip(self):
|
def check_fqdn_ip(self):
|
||||||
"""Check if server hostname resolved server IP"""
|
"""Check if server hostname resolved server IP"""
|
||||||
|
try:
|
||||||
x = requests.get('http://v4.wordops.eu')
|
x = requests.get('http://v4.wordops.eu')
|
||||||
ip = (x.text).strip()
|
ip = (x.text).strip()
|
||||||
|
|
||||||
@@ -34,3 +37,17 @@ def check_fqdn_ip(self):
|
|||||||
ip_fqdn = (y.text).strip()
|
ip_fqdn = (y.text).strip()
|
||||||
|
|
||||||
return bool(ip == ip_fqdn)
|
return bool(ip == ip_fqdn)
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print("Error occurred during request:", e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_server_ip(self):
|
||||||
|
"""Get the server externet IP"""
|
||||||
|
try:
|
||||||
|
x = requests.get('http://v4.wordops.eu')
|
||||||
|
ip = (x.text).strip()
|
||||||
|
|
||||||
|
return ip
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print("Error occurred during request:", e)
|
||||||
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user