Explorar o código

adding rpmbuild

Okynos %!s(int64=7) %!d(string=hai) anos
pai
achega
9bdebb760f

+ 1 - 0
rpmbuild/BUILD/RPMWazuh-1.0/README.md

@@ -0,0 +1 @@
+This repository store the QA test from Wazuh.

+ 89 - 0
rpmbuild/BUILD/RPMWazuh-1.0/configure_repo.py

@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# Created by Wazuh, Inc. <info@wazuh.com>.
+# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2
+
+import json
+import sys
+import argparse
+from datetime import date, datetime, timedelta
+import time
+from os.path import dirname, abspath
+import re
+
+try:
+    from elasticsearch import Elasticsearch
+except Exception as e:
+    print("No module 'elasticsearch' found.")
+    sys.exit()
+
+def read_elatic_config(auth_path):
+    return json.load(open(auth_path))
+
+
+def read_snapshots_conf(conf_path):
+    return json.load(open(conf_path))
+
+def log(msg):
+    now_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+    final_msg = "{0} wazuh-snapshot: {1}".format(now_date, msg)
+    print(final_msg)
+    if output_file:
+        foutput.write(final_msg + "\n")
+
+def create_repo(repo_config):
+    try:
+        if repo_config['repository_type'] == "local":
+            body_data = { "type": "fs", "settings": { "location": repo_config['repository'] } }
+
+        elif repo_config['repository_type'] == "s3":
+            body_data = { "type": repo_config['repository_type'], "settings": { "bucket": repo_config['bucket'], "region": repo_config['region'], "base_path": repo_config['base_path'] } }
+
+        es.snapshot.create_repository(repository=repo_config['repository'],body=body_data)
+
+    except Exception as e:
+        log("Error: {0}: {1}".format(repo_config['repository'], str(e)))
+        sys.exit()
+
+if __name__ == "__main__":
+    # Args
+    parser = argparse.ArgumentParser(description='Create snapshots repository Elastic')
+    parser.add_argument('-o', '--output_file', metavar='output_file', type=str, required = False, help='Output filename.')
+    args = parser.parse_args()
+
+    # Vars
+    current_path = dirname(abspath(__file__))
+    SLEEP_TIME = 10
+    LOG_ITERATIONS = 5
+    output_file = None
+    if args.output_file:
+        output_file = args.output_file
+        foutput = open(output_file, 'a')
+
+    # Config
+    config = read_snapshots_conf('{0}/snapshots_conf.json'.format(current_path))
+    es_conf = read_elatic_config(config['es_config_path'])
+    repo_type = config['repository_type']
+
+    if es_conf['settings']['elasticsearch']['auth'] == 'True':
+        http_auth_value=(es_conf['credentials']['elasticsearch']['user'], es_conf['credentials']['elasticsearch']['pass'])
+    else:
+        http_auth_value=False
+
+    # Elastic connectivity
+    es = Elasticsearch(
+        [es_conf['settings']['elasticsearch']['hostname']],
+        http_auth=http_auth_value,
+        port=es_conf['settings']['elasticsearch']['port'],
+        ca_certs=es_conf['settings']['elasticsearch']['ca_cert'],
+        use_ssl=es_conf['settings']['elasticsearch']['use_ssl'],
+    )
+
+    try:
+        create_repo(config)
+    except Exception as e:
+        print("  Elasticsearch error: {0}".format(str(e)))
+        sys.exit(1)
+
+    if output_file:
+        foutput.close()

+ 0 - 0
rpmbuild/BUILD/RPMWazuh-1.0/debugfiles.list


+ 0 - 0
rpmbuild/BUILD/RPMWazuh-1.0/debuglinks.list


+ 0 - 0
rpmbuild/BUILD/RPMWazuh-1.0/debugsources.list


+ 0 - 0
rpmbuild/BUILD/RPMWazuh-1.0/elfbins.list


+ 11 - 0
rpmbuild/BUILD/RPMWazuh-1.0/snapshots_conf.json

@@ -0,0 +1,11 @@
+{
+  "repository": "elastic_v6_wazuh_backup",
+  "repository_type": "local",
+  "bucket": false,
+  "region": false,
+  "base_path": false,
+  "es_config_path": "../.es-auth.json",
+  "snapshots": [
+    "wazuh-alerts-3.x"
+  ]
+}

BIN=BIN
rpmbuild/RPMS/x86_64/RPMWazuh-1.0-1.x86_64.rpm


BIN=BIN
rpmbuild/RPMS/x86_64/RPMWazuh-debuginfo-1.0-1.x86_64.rpm


BIN=BIN
rpmbuild/SOURCES/RPMWazuh-1.0.tar.gz


+ 1 - 0
rpmbuild/SOURCES/RPMWazuh-1.0/README.md

@@ -0,0 +1 @@
+This repository store the QA test from Wazuh.

+ 89 - 0
rpmbuild/SOURCES/RPMWazuh-1.0/configure_repo.py

@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# Created by Wazuh, Inc. <info@wazuh.com>.
+# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2
+
+import json
+import sys
+import argparse
+from datetime import date, datetime, timedelta
+import time
+from os.path import dirname, abspath
+import re
+
+try:
+    from elasticsearch import Elasticsearch
+except Exception as e:
+    print("No module 'elasticsearch' found.")
+    sys.exit()
+
+def read_elatic_config(auth_path):
+    return json.load(open(auth_path))
+
+
+def read_snapshots_conf(conf_path):
+    return json.load(open(conf_path))
+
+def log(msg):
+    now_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+    final_msg = "{0} wazuh-snapshot: {1}".format(now_date, msg)
+    print(final_msg)
+    if output_file:
+        foutput.write(final_msg + "\n")
+
+def create_repo(repo_config):
+    try:
+        if repo_config['repository_type'] == "local":
+            body_data = { "type": "fs", "settings": { "location": repo_config['repository'] } }
+
+        elif repo_config['repository_type'] == "s3":
+            body_data = { "type": repo_config['repository_type'], "settings": { "bucket": repo_config['bucket'], "region": repo_config['region'], "base_path": repo_config['base_path'] } }
+
+        es.snapshot.create_repository(repository=repo_config['repository'],body=body_data)
+
+    except Exception as e:
+        log("Error: {0}: {1}".format(repo_config['repository'], str(e)))
+        sys.exit()
+
+if __name__ == "__main__":
+    # Args
+    parser = argparse.ArgumentParser(description='Create snapshots repository Elastic')
+    parser.add_argument('-o', '--output_file', metavar='output_file', type=str, required = False, help='Output filename.')
+    args = parser.parse_args()
+
+    # Vars
+    current_path = dirname(abspath(__file__))
+    SLEEP_TIME = 10
+    LOG_ITERATIONS = 5
+    output_file = None
+    if args.output_file:
+        output_file = args.output_file
+        foutput = open(output_file, 'a')
+
+    # Config
+    config = read_snapshots_conf('{0}/snapshots_conf.json'.format(current_path))
+    es_conf = read_elatic_config(config['es_config_path'])
+    repo_type = config['repository_type']
+
+    if es_conf['settings']['elasticsearch']['auth'] == 'True':
+        http_auth_value=(es_conf['credentials']['elasticsearch']['user'], es_conf['credentials']['elasticsearch']['pass'])
+    else:
+        http_auth_value=False
+
+    # Elastic connectivity
+    es = Elasticsearch(
+        [es_conf['settings']['elasticsearch']['hostname']],
+        http_auth=http_auth_value,
+        port=es_conf['settings']['elasticsearch']['port'],
+        ca_certs=es_conf['settings']['elasticsearch']['ca_cert'],
+        use_ssl=es_conf['settings']['elasticsearch']['use_ssl'],
+    )
+
+    try:
+        create_repo(config)
+    except Exception as e:
+        print("  Elasticsearch error: {0}".format(str(e)))
+        sys.exit(1)
+
+    if output_file:
+        foutput.close()

+ 11 - 0
rpmbuild/SOURCES/RPMWazuh-1.0/snapshots_conf.json

@@ -0,0 +1,11 @@
+{
+  "repository": "elastic_v6_wazuh_backup",
+  "repository_type": "local",
+  "bucket": false,
+  "region": false,
+  "base_path": false,
+  "es_config_path": "../.es-auth.json",
+  "snapshots": [
+    "wazuh-alerts-3.x"
+  ]
+}

+ 40 - 0
rpmbuild/SPECS/RPMWazuh.spec

@@ -0,0 +1,40 @@
+Name:           RPMWazuh
+Version:        1.0
+Release:        1
+Summary:        RPM package for wazuh QA Test
+
+Group:          Wazuh
+BuildArch:      x86_64
+License:        GPLv2
+URL:            https://gogs.makefile.es/okynos/RPM-Wazuh
+Source0:        %{name}-%{version}.tar.gz
+Requires:	python
+
+%description
+This package install two scripts that work with python
+
+%prep
+%setup -q
+%build
+%clean
+rm -rf %{buildroot}
+%install
+rm -rf %{buildroot}
+%{__install} -d %{buildroot}%{_sbindir}
+install -d -m 0755 %{buildroot}/usr/share/myapp
+install -d -m 0755 %{buildroot}/etc/myapp 
+install -m 0755 configure_repo.py %{buildroot}/usr/share/myapp
+install -m 0644 snapshots_conf.json %{buildroot}/etc/myapp
+install -m 0644 README.md %{buildroot}/usr/share/myapp
+
+%files
+%defattr(-,root,root,-)
+/usr/share/myapp/configure_repo.py
+/usr/share/myapp/configure_repo.pyc
+/usr/share/myapp/configure_repo.pyo
+/etc/myapp/snapshots_conf.json
+/usr/share/myapp/README.md
+
+%changelog
+* Wed Jun 13 2018 José Fernández  1.0.0
+  - Initial rpm release

BIN=BIN
rpmbuild/SRPMS/RPMWazuh-1.0-1.src.rpm