Skip to content

Commit 168238d

Browse files
committed
Add properties files to configure startup and installation scripts
Many scripts are used to start/stop and install/uninstall elasticsearch. These scripts share a lot of configuration properties like directory paths, max value for a setting, default user etc. Most of the values are identical but some of them are different depending of the platform (Debian-based or Redhat-based OS), depending of the way elasticsearch is started (shell script, systemd, sysv-init...) or the way it is installed (zip, rpm, deb...). Today the values are duplicated in multiple places, making it difficult to maintain the scripts or to update a value. This pull request make this more uniform: values used in scripts must be defined in a common packaging.properties file. Each value can be overridden in another specific packaging.properties file for Debian or Redhat. All startup and installation scripts are filtered with the common then the custom packaging.properties files before being packaged as a zip/tar.gz/rpm/dpkf archive.
1 parent e8a42c6 commit 168238d

26 files changed

+227
-48
lines changed

bin/elasticsearch.in.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ for %%I in ("%SCRIPT_DIR%..") do set ES_HOME=%%~dpfI
1414
REM ***** JAVA options *****
1515

1616
if "%ES_MIN_MEM%" == "" (
17-
set ES_MIN_MEM=256m
17+
set ES_MIN_MEM=${packaging.elasticsearch.heap.min}
1818
)
1919

2020
if "%ES_MAX_MEM%" == "" (
21-
set ES_MAX_MEM=1g
21+
set ES_MAX_MEM=${packaging.elasticsearch.heap.max}
2222
)
2323

2424
if NOT "%ES_HEAP_SIZE%" == "" (

bin/elasticsearch.in.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/lib/${project.build.finalName}.jar:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*"
44

55
if [ "x$ES_MIN_MEM" = "x" ]; then
6-
ES_MIN_MEM=256m
6+
ES_MIN_MEM=${packaging.elasticsearch.heap.min}
77
fi
88
if [ "x$ES_MAX_MEM" = "x" ]; then
9-
ES_MAX_MEM=1g
9+
ES_MAX_MEM=${packaging.elasticsearch.heap.max}
1010
fi
1111
if [ "x$ES_HEAP_SIZE" != "x" ]; then
1212
ES_MIN_MEM=$ES_HEAP_SIZE

bin/service.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ goto:eof
118118
)
119119

120120
:foundJVM
121-
if "%ES_MIN_MEM%" == "" set ES_MIN_MEM=256m
122-
if "%ES_MAX_MEM%" == "" set ES_MAX_MEM=1g
121+
if "%ES_MIN_MEM%" == "" set ES_MIN_MEM=${packaging.elasticsearch.heap.min}
122+
if "%ES_MAX_MEM%" == "" set ES_MAX_MEM=${packaging.elasticsearch.heap.max}
123123

124124
if NOT "%ES_HEAP_SIZE%" == "" set ES_MIN_MEM=%ES_HEAP_SIZE%
125125
if NOT "%ES_HEAP_SIZE%" == "" set ES_MAX_MEM=%ES_HEAP_SIZE%

pom.xml

Lines changed: 197 additions & 41 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Common properties for building ZIP,GZ,RPM and DEB packages
2+
#
3+
# Properties defined here can be overridden with specific settings,
4+
# like in rpm/packaging.properties and deb/packaging.properties.
5+
6+
# Default values for min/max heap memory allocated to elasticsearch java process
7+
packaging.elasticsearch.heap.min=256m
8+
packaging.elasticsearch.heap.max=1g
9+
10+
# Simple marker to check that properties are correctly overridden
11+
packaging.type=tar.gz,gzip
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/deb/control/postrm renamed to src/packaging/deb/control/postrm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ case "$1" in
1515
rm -rf /usr/share/elasticsearch/plugins
1616

1717
# Remove **only** empty data dir
18-
rmdir --ignore-fail-on-non-empty /var/lib/elasticsearch
18+
if [ -d /var/lib/elasticsearch ]; then
19+
rmdir --ignore-fail-on-non-empty /var/lib/elasticsearch
20+
fi
1921
;;
2022

2123
purge)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Properties used to build to the DEB package
2+
#
3+
4+
# Simple marker to check that properties are correctly overridden
5+
packaging.type=deb
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Properties used to build to the RPM package
2+
#
3+
4+
# Simple marker to check that properties are correctly overridden
5+
packaging.type=rpm
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)