Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- *
- * This file is part of rasdaman community.
- *
- * Rasdaman community is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rasdaman community is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
- *
- * Copyright 2003 - 2016 Peter Baumann / rasdaman GmbH.
- *
- * For more information please see <http://www.rasdaman.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- """
- import json
- import os
- import sys
- import tempfile
- from abc import abstractmethod
- from time import sleep
- from config_manager import ConfigManager
- from helper.commands import chmod, make_backup, merge_properties, move, remove, copy, make_directory
- from helper.executor import UserInfo
- from helper.fileutil import replace_in_file, find_line_containing_token_in_file, get_all_filepaths, \
- append_to_file, read_file, write_to_file
- from helper.log import log
- from helper.stringutil import strip_whitespace
- from helper.sudo_commands import sudo_chown, sudo_chmod, sudo_remove, sudo_copy, sudo_move, sudo_mkdir
- from helper.distrowrapper import InitDTypes
- from services import executor, rasdaman_service, tomcat_service, rasdaman_system_service, linux_distro
- class Finalizer:
- def __init__(self):
- """
- Base class for finalizer classes that execute after the system is installed and running.
- Example of such classes are ones that provide functionality to insert demo data
- """
- pass
- @abstractmethod
- def finalize(self):
- """
- Called to finalize the installation
- """
- pass
- class FinalizerBasis(Finalizer):
- def __init__(self):
- """
- Class to be used as the basis of the decorator hierarchy
- """
- Finalizer.__init__(self)
- def finalize(self):
- pass
- class FinalizerDecorator(Finalizer):
- def __init__(self, finalizer):
- """
- Decorator class to be used by finalizer classes
- :param Finalizer finalizer: the finalizer to decorate around
- """
- Finalizer.__init__(self)
- self.finalizer = finalizer
- def finalize(self):
- self.finalizer.finalize()
- class RasdamanDemoDataFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, install_path):
- """
- Ingests the rasdaman demo data
- :param Finalizer finalizer: the finalizer to decorate
- :param str install_path: the install path of rasdaman
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.install_path = install_path
- def need_to_ingest_demo_data(self, bin_path):
- out, err, rc = executor.execute([bin_path + "/rasql", "--out", "string", "-q",
- "SELECT C FROM RAS_COLLECTIONNAMES AS C"],
- throw_on_error_code=False)
- if "mr2" in out or "rgb" in out or "mr" in out or rc != 0:
- # demo data already loaded or some problem executing rasql
- return False
- else:
- return True
- def finalize(self):
- FinalizerDecorator.finalize(self)
- rasdaman_service.start()
- bin_path = self.install_path + "/bin"
- if self.need_to_ingest_demo_data(bin_path):
- try:
- log.info("Installing rasdaman demo data...")
- images_path = self.install_path + "/share/rasdaman/examples/images"
- executor.execute([bin_path + "/rasdaman_insertdemo.sh", "localhost",
- "7001", images_path, "rasadmin", "rasadmin"],
- throw_on_error_code=False)
- finally:
- rasdaman_service.stop()
- log.info("Rasdaman demo data installed successfully.")
- class PetascopeDemoDataFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, install_path):
- """
- Ingests the petascope demo data
- :param Finalizer finalizer: the finalizer to decorate
- :param str install_path: the install path of rasdaman
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.install_path = install_path
- def need_to_ingest_demo_data(self, bin_path):
- out, err, rc = executor.execute([bin_path + "/rasql", "--out", "string", "-q",
- "SELECT C FROM RAS_COLLECTIONNAMES AS C"],
- throw_on_error_code=False)
- if "AverageTemperature" in out or "AverageChloro" in out or rc != 0:
- # demo data already loaded or some problem executing rasql
- return False
- else:
- return True
- def finalize(self):
- FinalizerDecorator.finalize(self)
- rasdaman_service.start()
- tomcat_service.restart()
- bin_path = self.install_path + "/bin"
- if self.need_to_ingest_demo_data(bin_path):
- try:
- log.info("Installing Petascope demo data...")
- executor.execute(["wget", "http://localhost:8080/def/crs/EPSG/0/4326",
- "-O", "/tmp/secore"], throw_on_error_code=False)
- executor.execute(["wget", "http://localhost:8080/rasdaman/ows?"
- "service=WCS&version=2.0.1&request=GetCapabilities",
- "-O", "/tmp/petascope"], throw_on_error_code=False)
- executor.execute([bin_path + "/petascope_insertdemo.sh"],
- no_wait=True, throw_on_error_code=False)
- sleep(20)
- finally:
- log.info("Petascope demo data installed successfully.")
- class MoveInstallerFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, main_path):
- """
- Moves the installer directory inside the rasdaman main path
- :param Finalizer finalizer: the finalizer to decorate
- :param str main_path: the main path to rasdaman
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.main_path = main_path
- def finalize(self):
- FinalizerDecorator.finalize(self)
- installer_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
- installer_new_path = self.main_path + "/installer"
- log.info("Copying install.sh to '{}'...".format(installer_new_path))
- make_directory(installer_new_path)
- # copy install.sh script to /opt/rasdaman/installer
- copy(installer_dir + "/install.sh", installer_new_path, False)
- sudo_chown(self.main_path, ConfigManager.default_user)
- sudo_chown(installer_new_path, ConfigManager.default_user)
- log.info("install.sh script file copied successfully.")
- class InstallerLogFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, source_path, profile_path, main_path, install_path):
- """
- Saves the installation profile in the rasdaman main path and adds any needed extra information, e.g. build hash
- :param Finalizer finalizer: the finalizer to decorate
- :param str source_path: path to the rasdaman source
- :param str profile_path: the path to the installation profile
- :param str main_path: the main path of rasdaman
- :param str install_path: the path to the installer
- :return:
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.profile_path = profile_path
- self.source_path = source_path
- self.main_path = main_path
- self.install_path = install_path
- def _generate_update_rasdaman(self, profile_path):
- update_rasdaman_contents = """
- #!/usr/bin/env bash
- {}/install.sh -j {}
- """.format(self.main_path + "/installer/", profile_path)
- # NOTE: the update_rasdaman.sh is generated in /opt/rasdaman/bin by default, it is not in installer folder
- updater_path = self.install_path + "/bin/update_rasdaman.sh"
- log.info("Installing update script at '{}'...".format(updater_path))
- write_to_file(updater_path, update_rasdaman_contents)
- sudo_chown(updater_path, ConfigManager.default_user)
- chmod(updater_path, "+x")
- log.info("Update script installed successfully.")
- def finalize(self):
- FinalizerDecorator.finalize(self)
- profile_resting_path = self.main_path + "/install_profile.json"
- log.info("Updating the installation profile file at '{}'...".format(profile_resting_path))
- jsprofile = json.load(open(self.profile_path))
- jsprofile['update'] = True
- out, _, _ = executor.execute(["git", "rev-parse", "HEAD"], self.source_path)
- jsprofile['version_hash'] = out.replace("\n", "")
- fp = open(profile_resting_path, "w")
- json.dump(jsprofile, fp, indent=4)
- fp.close()
- sudo_chown(profile_resting_path, ConfigManager.default_user)
- chmod(profile_resting_path, "755")
- log.info("Installation profile updated successfully.")
- self._generate_update_rasdaman(profile_resting_path)
- class ServiceInitDFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, install_path, user, profile, automatic_start=True):
- """
- Creates a init.d script to be used to stop and start rasdaman
- :param Finalizer finalizer: the finalizer to decorate
- :param str install_path: the installation path where the bin file can be found
- :param str user: the user that needs to execute rasdaman services
- :param Profile profile: the whole profile object
- :param bool automatic_start: set to false if rasdaman should not start at startup
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.install_path = install_path
- self.profile = profile
- self.user = user
- self.automatic_start = automatic_start
- def __initialize_sysv_script(self):
- contents = read_file(os.path.dirname(os.path.realpath(__file__)) + "/rasdaman.sh")
- contents = contents.replace("start_rasdaman.sh", self.install_path + "/bin/start_rasdaman.sh")
- contents = contents.replace("stop_rasdaman.sh", self.install_path + "/bin/stop_rasdaman.sh")
- contents = contents.replace("RUN_AS_USER", linux_distro.get_runuser(self.user))
- return contents
- def __install_sysv_script(self):
- contents = self.__initialize_sysv_script()
- initd_path = "/etc/init.d/rasdaman"
- write_to_file(initd_path, contents)
- sudo_chmod(initd_path, "755")
- def __install_systemd_script(self):
- if linux_distro.get_initd_type() == InitDTypes.SYSTEMD:
- service_contents = read_file(os.path.dirname(os.path.realpath(__file__)) + "/rasdaman.service")
- service_path = "/etc/systemd/system/rasdaman.service"
- write_to_file(service_path, service_contents)
- sudo_chmod(service_path, "644")
- if self.automatic_start:
- rasdaman_system_service.enable()
- def finalize(self):
- FinalizerDecorator.finalize(self)
- log.info("Creating service script...")
- self.__install_sysv_script()
- self.__install_systemd_script()
- log.info("Service script created successfully.")
- class CopyOldConfigFromPackagesFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, installation_path):
- """
- Copies configuration files from /etc that pertain to rasdaman from old installations that used
- / as rmanhome
- :param Finalizer finalizer: the finalizer to decorate
- :param str installation_path: the installation path
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.installation_path = installation_path
- def finalize(self):
- FinalizerDecorator.finalize(self)
- log.info("Looking for any existing configuration files from deprecated packages to migrate...")
- etc_path = self.installation_path + "/etc/"
- copied = False
- for path in ["rasmgr.conf", "rmankey"]:
- source = "/etc/rasdaman/" + path
- if os.path.exists(source):
- dest = etc_path + path
- sudo_copy(source, dest, throw_on_error_code=False)
- sudo_chown(dest, ConfigManager.default_user)
- copied = True
- if copied:
- log.info("All previous configuration files migrated successfully.")
- else:
- log.info("No previous configuration files found to migrate.")
- class EnsureExistingConfigPersistFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, installation_path):
- """
- Copies configuration files from /etc that pertain to rasdaman from old installations that used
- / as rmanhome
- :param Finalizer finalizer: the finalizer to decorate
- :param str installation_path: the installation path
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.installation_path = installation_path
- def finalize(self):
- FinalizerDecorator.finalize(self)
- log.info("Restoring configuration files...")
- etc_path = self.installation_path + "/etc/"
- copied = False
- for path in ["rasmgr.conf", "petascope.properties", "secore.properties", "wms_service.properties"]:
- source = "/tmp/rasdaman-backup/etc/" + path
- if os.path.exists(source):
- dest = etc_path + path
- if path == "petascope.properties":
- # Get the new properties file from package which is renamed as petascope.properties.rpmnew (in ***rpm*** package)
- # NOTE: if this file does not exist which means old petascope.properties also does not exist, then nothing to update
- new_petascope_properties_path = self.installation_path + "/etc/petascope.properties.rpmnew"
- if os.path.exists(new_petascope_properties_path):
- log.info("update petascope.properties configuration from " + source + " to " + new_petascope_properties_path + "...")
- # Run the update_properties.sh to update the changes between user's old file and source's new file
- # The output is a combined petascope.properties file which will be copied back to installation path
- executor.executeSudo([self.installation_path + "/bin/update_properties.sh", source, new_petascope_properties_path], throw_on_error_code=True)
- log.info("petascope.properties updated successfully.")
- # Get the new properties file from package which is renamed as petascope.properties.dkpg-dist (in ***deb*** package)
- # NOTE: if this file does not exist which means old petascope.properties also does not exist, then nothing to update
- new_petascope_properties_path = self.installation_path + "/etc/petascope.properties.dkpg-dist"
- if os.path.exists(new_petascope_properties_path):
- log.info("update petascope.properties configuration from " + source + " to " + new_petascope_properties_path + "...")
- # Run the update_properties.sh to update the changes between user's old file and source's new file
- # The output is a combined petascope.properties file which will be copied back to installation path
- executor.executeSudo([self.installation_path + "/bin/update_properties.sh", source, new_petascope_properties_path], throw_on_error_code=True)
- log.info("petascope.properties updated successfully.")
- executor.executeSudo(["cp", "-v", source, dest], throw_on_error_code=False)
- sudo_chown(dest, ConfigManager.default_user)
- copied = True
- log.info("Copied " + source + " to " + dest)
- if copied:
- log.info("All previous configuration files restored successfully.")
- else:
- log.info("No previous configuration files found to restore.")
- class PropertiesMigrationFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, install_path, osgeo=False):
- """
- Migrate properties, e.g. log4j.properties into petascope.properties
- :param Finalizer finalizer: the finalizer to decorate
- :param str install_path: the installation path of rasdaman
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.install_path = install_path
- self.osgeo = osgeo
- def migrate_log4j_properties(self):
- """
- Move log4j.properties to petascope.properties if needed.
- """
- log4j_properties = self.install_path + "/etc/log4j.properties"
- petascope_properties = self.install_path + "/etc/petascope.properties"
- if os.path.exists(log4j_properties) and os.path.exists(petascope_properties):
- line = find_line_containing_token_in_file(petascope_properties, "log4j")
- if line is None:
- log.info("Migrating '{}' to '{}'...".format(log4j_properties, petascope_properties))
- make_backup(petascope_properties)
- append_to_file(petascope_properties, """
- # ---------------------------------------------------------------------
- #
- # log4j configuration
- #
- """)
- merge_properties(petascope_properties, log4j_properties)
- if self.osgeo:
- sudo_move(log4j_properties, log4j_properties + ".unused")
- else:
- move(log4j_properties, log4j_properties + ".unused")
- tomcat_service.restart()
- log.info("Logging configuration migrated to petascope.properties.")
- def finalize(self):
- FinalizerDecorator.finalize(self)
- self.migrate_log4j_properties()
- class PermissionFixFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, install_path):
- """
- Make sure the install_path is owned by the rasdaman user
- :param Finalizer finalizer: the finalizer to decorate
- :param str install_path: the installation path of rasdaman
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.install_path = install_path
- def finalize(self):
- FinalizerDecorator.finalize(self)
- sudo_chown(self.install_path, ConfigManager.default_user)
- class DataSymlinkFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, data_directory, install_path):
- """
- Adds a symlink in the install path if the folder does not exist.
- :param Finalizer finalizer: the finalizer to decorate for
- :param str data_directory: the real data directory
- :param str install_path: the rasdaman installation path
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.data_directory = data_directory
- self.install_path = install_path
- def finalize(self):
- FinalizerDecorator.finalize(self)
- data_install_path = self.install_path + "/data/"
- if not os.path.exists(data_install_path):
- log.info("Creating a symlink for the data directory...")
- executor.execute(["ln", "-s", self.data_directory, "data"], self.install_path)
- log.info("Symlink created successfully.")
- class RasimportFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, peta_db_name, peta_user, peta_pass):
- """
- Sets up rasimport by configuring the rasconnect file
- :param Finalizer finalizer: the finalizer to decorate
- :param str peta_db_name: the petascope db name
- :param str peta_user: the petascope user
- :param str peta_pass: the password for peta user
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.peta_db_name = peta_db_name
- self.peta_user = peta_user
- self.peta_pass = peta_pass
- def finalize(self):
- FinalizerDecorator.finalize(self)
- log.info("Configuring rasimport...")
- home_dir = UserInfo(ConfigManager.default_user).user_home_dir
- rasconnect_file = strip_whitespace(home_dir) + "/.rasdaman/rasconnect"
- if os.path.isfile(rasconnect_file):
- replace_in_file(rasconnect_file, {
- "petadbname=petascopedb": "petadbname=" + self.peta_db_name.split("/")[-1],
- "petauser=petauser": "petauser=" + self.peta_user,
- "petapassword=petapasswd": "petapassword=" + self.peta_pass
- })
- # if the rasconnect was changed before, make sure the password is correct
- line = find_line_containing_token_in_file(rasconnect_file, "petapassword")
- if line is not None:
- replace_in_file(rasconnect_file, {
- line: "petapassword=" + self.peta_pass
- })
- log.info("rasimport configured successfully.")
- else:
- log.warn("Could not configure rasimport, config file could not be found at: " + rasconnect_file)
- class ServiceShutdownFinalizer(FinalizerDecorator):
- def __init__(self, finalizer):
- """
- Shuts down any existing services that might be used by the current user
- :param Finalizer finalizer: the finalizer to wrap around
- """
- FinalizerDecorator.__init__(self, finalizer)
- def finalize(self):
- FinalizerDecorator.finalize(self)
- tomcat_service.stop()
- rasdaman_service.stop()
- class OSGeoFinalizer(FinalizerDecorator):
- def __init__(self, finalizer, installation_path):
- """
- Creates certain customizations that are needed for OSGeo Live DVD
- :param Finalizer finalizer: the finalizer to decorate
- :param str installation_path: the installation path
- :return:
- """
- FinalizerDecorator.__init__(self, finalizer)
- self.installation_path = installation_path
- def create_demo_scripts(self):
- rasdaman_demo_contents = """#!/bin/sh
- if [ ! -f {rasdaman_demo_created_file} ]; then
- echo "Ingesting rasdaman data..."
- {rasdaman_insert_demo} localhost 7001 {install_path}/share/rasdaman/examples/images rasadmin rasadmin
- touch {rasdaman_demo_created_file}
- echo "Rasdaman data ingested successfully."
- fi
- """.format(rasdaman_demo_created_file=self.installation_path + "/rasdaman_demo_success",
- rasdaman_insert_demo=self.installation_path + "/bin/rasdaman_insertdemo.sh",
- install_path=self.installation_path)
- petascope_demo_contents = """#!/bin/sh
- if [ ! -f {petascope_demo_created_file} ]; then
- echo "Ingesting Petascope data..."
- {petascope_insert_demo}
- {wcst_import} {ingest_path}/NIR.json
- {wcst_import} {ingest_path}/NN3_1.json
- {wcst_import} {ingest_path}/lena.json
- touch {petascope_demo_created_file}
- echo "Petascope data ingested successfully."
- fi
- """.format(petascope_demo_created_file=self.installation_path + "/petascope_demo_success",
- petascope_insert_demo=self.installation_path + "/bin/petascope_insertdemo.sh",
- ingest_path=self.installation_path + "/ingest",
- wcst_import=self.installation_path + "/bin/wcst_import.sh")
- demo_scripts = {
- "rasdaman-osgeo-demo.sh": rasdaman_demo_contents,
- "petascope-osgeo-demo.sh": petascope_demo_contents
- }
- for filename, contents in demo_scripts.iteritems():
- full_path = self.installation_path + "/bin/" + filename
- write_to_file(full_path, contents)
- sudo_chown(full_path, ConfigManager.default_user)
- chmod(full_path, "775")
- def create_bin_starters(self):
- bin_starters = {
- "rasdaman-start.sh": """#!/bin/bash
- sudo service tomcat8 start
- sudo service rasdaman start
- echo "Preparing demo data..."
- {install_path}/bin/rasdaman-osgeo-demo.sh &> /dev/null
- {install_path}/bin/petascope-osgeo-demo.sh &> /dev/null
- echo "Demo data prepared successfully."
- zenity --info --text "Rasdaman started"
- echo -e "\033[0;32mRasdaman was started correctly. You can close this window now.\033[0m"
- """.format(install_path=self.installation_path),
- "rasdaman-stop.sh": """
- #!/bin/sh
- sudo service tomcat8 stop
- sudo service rasdaman stop
- zenity --info --text "Rasdaman stopped"
- """
- }
- bin_path = self.installation_path + "/bin/"
- for filename, contents in bin_starters.iteritems():
- complete_path = bin_path + filename
- write_to_file(complete_path, contents)
- sudo_chown(complete_path, ConfigManager.default_user)
- chmod(complete_path, "755")
- def create_desktop_applications(self):
- bin_path = self.installation_path + "/bin"
- desktop_files = {
- "start_rasdaman_server.desktop": """[Desktop Entry]
- Type=Application
- Encoding=UTF-8
- Name=Start Rasdaman Server
- Comment=Start Rasdaman Server
- Categories=Application;Education;Geography;
- Exec=gksudo bash {}/rasdaman-start.sh
- Icon=gnome-globe
- Terminal=true
- StartupNotify=false
- """.format(bin_path),
- "stop_rasdaman_server.desktop": """[Desktop Entry]
- Type=Application
- Encoding=UTF-8
- Name=Stop Rasdaman Server
- Comment=Stop Rasdaman Server
- Categories=Application;Education;Geography;
- Exec=gksudo bash {}/rasdaman-stop.sh
- Icon=gnome-globe
- Terminal=true
- StartupNotify=false
- """.format(bin_path),
- "rasdaman-earthlook-demo.desktop": """
- [Desktop Entry]
- Type=Application
- Encoding=UTF-8
- Name=Rasdaman-Earthlook Demo
- Comment=Rasdaman Demo and Tutorial
- Categories=Application;Education;Geography;
- Exec=firefox http://localhost/rasdaman-demo/
- Icon=gnome-globe
- Terminal=false
- StartupNotify=false
- """
- }
- desktop_paths = ["/usr/local/share/applications/", '/home/user/Desktop/']
- for path in desktop_paths:
- sudo_mkdir(path)
- for filename, contents in desktop_files.iteritems():
- complete_path = path + filename
- write_to_file(complete_path, contents)
- sudo_chown(complete_path, ConfigManager.default_user)
- chmod(complete_path, "755")
- def deploy_earthlook(self):
- tmp = tempfile.gettempdir() + "/earthlook"
- make_directory(tmp)
- executor.execute(["wget", "http://kahlua.eecs.jacobs-university.de/~earthlook/osgeo/earthlook.tar.gz", "-O",
- "earthlook.tar.gz"], tmp)
- executor.execute(["tar", "-xzvf", "earthlook.tar.gz"], tmp)
- rasdaman_demo_path = "/var/www/html/rasdaman-demo"
- sudo_remove(rasdaman_demo_path)
- sudo_move("public_html", rasdaman_demo_path, working_dir=tmp)
- sudo_chown(rasdaman_demo_path, ConfigManager.default_user)
- chmod(rasdaman_demo_path, "755")
- remove(tmp)
- def ingest_data(self):
- ingredients_template = """
- {
- "config": {
- "service_url": "http://localhost:8080/rasdaman/ows",
- "tmp_directory": "/tmp/",
- "crs_resolver": "http://localhost:8080/def/",
- "default_crs": "http://localhost:8080/def/OGC/0/Index2D",
- "mock": false,
- "automated": true,
- "subset_correction" : false
- },
- "input": {
- "coverage_id": "{coverage}"
- },
- "recipe": {
- "name": "wcs_extract",
- "options": {
- "coverage_id" : "{coverage}",
- "wcs_endpoint" : "http://ows.rasdaman.org/rasdaman/ows"
- }
- }
- }
- """
- tmp = self.installation_path + "/ingest/"
- make_directory(tmp)
- coverages = ["NIR", "NN3_1", "lena"]
- for coverage in coverages:
- ingest_tmp = tmp + coverage + ".json"
- write_to_file(ingest_tmp, ingredients_template.replace("{coverage}", coverage))
- def delete_not_needed_files(self):
- remove(self.installation_path + "/lib")
- remove(self.installation_path + "/include")
- strip_files = get_all_filepaths(self.installation_path + "/bin/")
- for sfile in strip_files:
- executor.execute(["strip", sfile], throw_on_error_code=False)
- def make_tomcat_auto_deploy(self):
- replace_in_file("/var/lib/tomcat8/conf/server.xml", {
- 'unpackWARs="false"': 'unpackWARs="true"',
- 'autoDeploy="false"': 'autoDeploy="true"'
- })
- tomcat_service.restart()
- def remove_dev_libs(self):
- executor.executeSudo(
- ['apt-get', '--yes', 'remove', 'libtool', 'bison', 'comerr-dev', 'doxygen', 'doxygen-latex', 'flex',
- 'krb5-multidev', 'libecpg-dev', 'libjpeg-dev', 'libedit-dev', 'libkrb5-dev', 'libncurses5-dev',
- 'libnetpbm10-dev', 'libpng12-dev', 'libpq-dev', 'libreadline-dev', 'libreadline6-dev', 'libtiff4-dev',
- 'luatex', 'libgssrpc4', 'libkdb5-7', 'libgdal-dev', 'libsigsegv-dev'], throw_on_error_code=False)
- def add_profile_to_bashrc(self):
- bashrc = UserInfo(ConfigManager.default_user).user_home_dir + "/.bashrc"
- with open(bashrc, "a") as bfile:
- bfile.write("source /etc/profile.d/rasdaman.sh\n")
- def make_root_owner_of_rasdaman(self):
- sudo_chown(self.installation_path, "root", "users")
- def finalize(self):
- FinalizerDecorator.finalize(self)
- log.info("Customizing rasdaman for OSGeo Live...")
- log.info("Creating starting scripts...")
- self.create_bin_starters()
- self.create_demo_scripts()
- log.info("Starting scripts successfully created.")
- log.info("Creating desktop icons...")
- self.create_desktop_applications()
- log.info("Desktop icons created successfully.")
- log.info("Striping binaries and removing unneeded files for OSGeo Live...")
- self.delete_not_needed_files()
- log.info("Binaries stripped successfully.")
- log.info("Deploying local earthlook...")
- self.deploy_earthlook()
- log.info("Local earthlook deployed successfully.")
- log.info("Ingesting demo data...")
- self.ingest_data()
- log.info("Demo data ingested successfully.")
- log.info("Add rasdaman profile to the user's bashrc...")
- self.add_profile_to_bashrc()
- log.info("Profile added successfully.")
- log.info("Cleaning dev packages...")
- self.remove_dev_libs()
- log.info("Dev packages cleaned successfully.")
- log.info("Making root owner of rasdaman installation.")
- self.make_root_owner_of_rasdaman()
- log.info("Root is now owner of rasdaman")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement