Skip to content

Commit

Permalink
Set ROCK image to use the upstream folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
phvalguima committed Oct 17, 2023
1 parent 353b573 commit 356128d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cd charmed-opensearch-rock
```
#### Installing Prerequisites
```bash
sudo snap install rockcraft --edge --classic --revision=687
sudo snap install rockcraft --edge --classic --revision
sudo snap install docker
sudo snap install lxd
sudo snap install skopeo --edge --devmode
Expand Down
31 changes: 21 additions & 10 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,29 @@ services:
summary: Start OpenSearch
command: "/bin/bash /bin/start.sh"
environment:
OPENSEARCH_HOME: /
OPENSEARCH_JAVA_HOME: /jdk
OPENSEARCH_PATH_CONF: /config
OPENSEARCH_TMPDIR: /tmp
OPENSEARCH_PLUGINS: /plugins
OPS_ROOT: /opt/opensearch

OPENSEARCH_HOME: /usr/share/opensearch
OPENSEARCH_JAVA_HOME: /usr/share/opensearch/jdk
OPENSEARCH_BIN: /usr/share/opensearch/bin
OPENSEARCH_LIB: /usr/share/opensearch/lib
OPENSEARCH_PLUGINS: /usr/share/opensearch/plugins
OPENSEARCH_MODULES: /usr/share/opensearch/modules

OPENSEARCH_PATH_CONF: /etc/opensearch
OPENSEARCH_PATH_CERTS: /etc/opensearch/certificates

OPENSEARCH_VARLIB: /var/lib/opensearch
OPENSEARCH_TMPDIR: /usr/share/tmp
OPENSEARCH_VARLOG: /var/log/opensearch

KNN_LIB_DIR: /usr/share/opensearch/plugins/opensearch-knn/lib

parts:
opensearch-snap:
plugin: nil
stage-snaps:
- opensearch/2/candidate
- opensearch/2/edge
stage-packages:
- curl
- python3
Expand Down Expand Up @@ -67,11 +79,10 @@ parts:
useradd -R ${CRAFT_OVERLAY} -M -r -g opensearch -u 1000 opensearch
override-prime: |
craftctl default
# Give permission ot the required folders
chown -R 1000:1000 data/ logs/ config/ jdk/ modules/ plugins/ extensions/ performance-analyzer-rca/
chown -R 1000:1000 lib/tools lib/*.jar
chown -R 1000:1000 bin/opensearch*
mkdir -p var/lib/opensearch usr/share/tmp var/log/opensearch
chown -R 1000:1000 etc/opensearch opt/opensearch usr/share/opensearch var/lib/opensearch usr/share/tmp var/log/opensearch
entry:
plugin: dump
Expand Down
7 changes: 4 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ fi

set_yaml_prop "${conf}" "network.host" "$(network_host)"
set_yaml_prop "${conf}" "discovery.seed_hosts" "$(seed_hosts)"
set_yaml_prop "${conf}" "path.data" "/data"
set_yaml_prop "${conf}" "path.logs" "/logs"
set_yaml_prop "${conf}" "path.data" "${OPENSEARCH_VARLIB}/data"
set_yaml_prop "${conf}" "path.logs" "${OPENSEARCH_VARLOG}/logs"
set_yaml_prop "${conf}" "plugins.security.disabled" "true"
sed -i "s@=logs/@=${OPENSEARCH_VARLOG}/@" "${OPENSEARCH_PATH_CONF}/jvm.options"

cat "${conf}"

exec /usr/bin/setpriv \
--clear-groups \
--reuid opensearch \
--regid opensearch \
-- /bin/opensearch
-- "${OPENSEARCH_BIN}"/opensearch

0 comments on commit 356128d

Please sign in to comment.