Skip to content

Commit

Permalink
Adding Debian packaging config files from Opensearch (#118)
Browse files Browse the repository at this point in the history
* Adding debian packaging config files from Opensearch

* Copy debian/ folder to the build dir for debmake to parse

* Remove redundant steps from debian/postinst

---------

Co-authored-by: Álex Ruiz <[email protected]>
  • Loading branch information
f-galland and AlexRuiz7 authored Jan 19, 2024
1 parent c4a2d86 commit b7034e7
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 1 deletion.
22 changes: 22 additions & 0 deletions distribution/packages/src/deb/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

Source: wazuh-indexer
Section: web
Priority: optional
Maintainer: Wazuh Indexer Team <[email protected]>
Build-Depends: debhelper-compat (= 12)
Standards-Version: 4.5.0
Homepage: https://www.wazuh.com/

Package: wazuh-indexer
Architecture: any
Description: Wazuh indexer is a near real-time full-text search and analytics engine that gathers security-related data into one platform.
This Wazuh central component indexes and stores alerts generated by the Wazuh server.
Wazuh indexer can be configured as a single-node or multi-node cluster, providing scalability and high availability.
Documentation can be found at https://documentation.wazuh.com/current/getting-started/components/wazuh-indexer.html

38 changes: 38 additions & 0 deletions distribution/packages/src/deb/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: wazuh-indexer
Upstream-Contact: [email protected]
Source: https://www.wazuh.com
Files: *
Copyright: OpenSearch Contributors
License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
http://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian systems, the complete text of the Apache License, Version 2
can be found in "/usr/share/common-licenses/Apache-2.0".

Files: debian/*
License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
http://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian systems, the complete text of the Apache License, Version 2
can be found in "/usr/share/common-licenses/Apache-2.0".
53 changes: 53 additions & 0 deletions distribution/packages/src/deb/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# Copyright Wazuh Indexer Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The Wazuh Indexer Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# deb wazuh-indexer postinst script

set -e

echo "Running Wazuh Indexer Post-Installation Script"

product_dir=/usr/share/wazuh-indexer
config_dir=/etc/wazuh-indexer
data_dir=/var/lib/wazuh-indexer
log_dir=/var/log/wazuh-indexer
pid_dir=/var/run/wazuh-indexer


# Set owner
chown -R wazuh-indexer.wazuh-indexer ${product_dir}
chown -R wazuh-indexer.wazuh-indexer ${config_dir}
chown -R wazuh-indexer.wazuh-indexer ${log_dir}
chown -R wazuh-indexer.wazuh-indexer ${data_dir}
chown -R wazuh-indexer.wazuh-indexer ${pid_dir}

# Reload systemctl daemon
if command -v systemctl > /dev/null; then
systemctl daemon-reload
fi

# Reload other configs
if command -v systemctl > /dev/null; then
systemctl restart systemd-sysctl.service || true
fi

if command -v systemd-tmpfiles > /dev/null; then
systemd-tmpfiles --create wazuh-indexer.conf
fi

# Messages
echo "### NOT starting on installation, please execute the following statements to configure wazuh-indexer service to start automatically using systemd"
echo " sudo systemctl daemon-reload"
echo " sudo systemctl enable wazuh-indexer.service"
echo "### You can start wazuh-indexer service by executing"
echo " sudo systemctl start wazuh-indexer.service"

exit 0


31 changes: 31 additions & 0 deletions distribution/packages/src/deb/debian/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# deb wazuh-indexer preinst script

set -e

echo "Running Wazuh Indexer Pre-Installation Script"

# Stop existing service
if command -v systemctl >/dev/null && systemctl is-active wazuh-indexer.service >/dev/null; then
echo "Stop existing wazuh-indexer.service"
systemctl --no-reload stop wazuh-indexer.service
fi
if command -v systemctl >/dev/null && systemctl is-active wazuh-indexer-performance-analyzer.service >/dev/null; then
echo "Stop existing wazuh-indexer-performance-analyzer.service"
systemctl --no-reload stop wazuh-indexer-performance-analyzer.service
fi

# Create user and group if they do not already exist.
getent group wazuh-indexer > /dev/null 2>&1 || groupadd -r wazuh-indexer
getent passwd wazuh-indexer > /dev/null 2>&1 || \
useradd -r -g wazuh-indexer -M -s /sbin/nologin \
-c "wazuh-indexer user/group" wazuh-indexer
exit 0
26 changes: 26 additions & 0 deletions distribution/packages/src/deb/debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# deb wazuh-indexer prerm script

set -e

echo "Running Wazuh Indexer Pre-Removal Script"

# Stop existing service
if command -v systemctl >/dev/null && systemctl is-active wazuh-indexer.service >/dev/null; then
echo "Stop existing wazuh-indexer.service"
systemctl --no-reload stop wazuh-indexer.service
fi
if command -v systemctl >/dev/null && systemctl is-active wazuh-indexer-performance-analyzer.service >/dev/null; then
echo "Stop existing wazuh-indexer-performance-analyzer.service"
systemctl --no-reload stop wazuh-indexer-performance-analyzer.service
fi

exit 0
29 changes: 29 additions & 0 deletions distribution/packages/src/deb/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/make -f

# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
dh $@

override_dh_builddeb:
dh_builddeb -- -Zgzip

override_dh_gencontrol:
dh_gencontrol -- -DLicense=Apache-2.0

#override_dh_auto_install:
# dh_auto_install -- prefix=/usr

#override_dh_install:
# dh_install --list-missing -X.pyc -X.pyo
9 changes: 8 additions & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ The script will:
|-- etc
|-- usr
|-- var
`-- wazuh-indexer-min_4.9.0_amd64.deb
|-- wazuh-indexer-min_4.9.0_amd64.deb
`-- debian/
| -- control
| -- copyright
| -- rules
| -- preinst
| -- prerm
| -- postinst
```

### Running in Act
Expand Down
1 change: 1 addition & 0 deletions scripts/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ function assemble_deb() {
# Copy spec
cp "distribution/packages/src/deb/Makefile" "${TMP_DIR}"
cp "distribution/packages/src/deb/debmake_install.sh" "${TMP_DIR}"
cp -r "distribution/packages/src/deb/debian" "${TMP_DIR}"
chmod a+x "${TMP_DIR}/debmake_install.sh"
# Copy performance analyzer service file
enable_performance_analyzer
Expand Down

0 comments on commit b7034e7

Please sign in to comment.