2022-01-10 20:52:29 +01:00
|
|
|
#!/usr/bin/env python3
|
2016-05-19 16:27:41 +02:00
|
|
|
# Script to install the Pandora FMS Console.
|
|
|
|
import os
|
2022-02-02 12:12:41 +01:00
|
|
|
import sys
|
2016-05-19 16:27:41 +02:00
|
|
|
from pyvirtualdisplay import Display
|
|
|
|
from selenium import webdriver
|
2022-02-02 10:48:40 +01:00
|
|
|
from selenium.common.exceptions import NoSuchElementException
|
2016-05-19 16:27:41 +02:00
|
|
|
|
|
|
|
# Are we running headless?
|
|
|
|
if ('DISPLAY' not in os.environ):
|
2016-09-21 09:12:10 +02:00
|
|
|
display = Display(visible=0, size=(1920, 1080))
|
2016-05-19 16:27:41 +02:00
|
|
|
display.start()
|
|
|
|
|
2022-02-02 10:37:57 +01:00
|
|
|
browser = webdriver.Firefox(timeout=15)
|
|
|
|
|
2022-02-02 10:19:24 +01:00
|
|
|
try:
|
|
|
|
# Go to the installation page.
|
|
|
|
browser.implicitly_wait(5)
|
|
|
|
browser.get('http://localhost/pandora_console/install.php')
|
|
|
|
assert("Pandora FMS - Installation Wizard" in browser.title)
|
2016-05-19 16:27:41 +02:00
|
|
|
|
2022-02-02 10:19:24 +01:00
|
|
|
# Accept the license agreement.
|
|
|
|
browser.find_element_by_xpath("//*[@id='step11']").click()
|
|
|
|
browser.find_element_by_xpath("//*[@id='btn_accept']").click()
|
2016-05-19 16:27:41 +02:00
|
|
|
|
2022-02-02 10:19:24 +01:00
|
|
|
# Fill-in the configuration form.
|
|
|
|
browser.find_element_by_xpath("//*[@id='step3']").click()
|
|
|
|
browser.find_element_by_name("pass").send_keys("pandora")
|
|
|
|
browser.find_element_by_xpath("//*[@id='step4']").click()
|
|
|
|
|
|
|
|
# Complete the installation.
|
2022-02-02 10:48:40 +01:00
|
|
|
browser.implicitly_wait(900) # The installation is going to take a long time.
|
2022-02-02 10:19:24 +01:00
|
|
|
browser.find_element_by_xpath("//*[@id='step5']").click()
|
|
|
|
browser.implicitly_wait(5)
|
|
|
|
assert("Installation complete" in browser.page_source)
|
|
|
|
browser.find_element_by_name("rn_file").click()
|
2022-02-02 10:37:57 +01:00
|
|
|
except AssertionError as error:
|
|
|
|
print("Error " + str(error) + ":\n" + browser.page_source)
|
2022-02-02 12:12:41 +01:00
|
|
|
sys.exit(1)
|
2022-02-02 10:48:40 +01:00
|
|
|
except NoSuchElementException as error:
|
|
|
|
print("Error " + str(error) + ":\n" + browser.page_source)
|
2022-02-02 12:12:41 +01:00
|
|
|
sys.exit(1)
|
2016-05-19 16:27:41 +02:00
|
|
|
|
|
|
|
# Clean-up
|
|
|
|
browser.quit()
|
|
|
|
if ('DISPLAY' not in os.environ):
|
|
|
|
display.stop()
|