Add support for creating a fedora RPM package with maven
Note: This has been disabled by default and is therefore not included in a standard build. The main reason for this is, that you need to have a RPM binary and the rpm development packages installed, which is not the case on many systems. The package contains an init.d-script as well as systemd configurations. You can build your own RPM package simply by running 'maven rpm:rpm'
This commit is contained in:
parent
10a76ad5d8
commit
0a466352cd
180
pom.xml
180
pom.xml
|
@ -612,6 +612,186 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>rpm-maven-plugin</artifactId>
|
||||||
|
<version>2.1-alpha-2</version>
|
||||||
|
<configuration>
|
||||||
|
<copyright>2013, Elasticsearch</copyright>
|
||||||
|
<distribution>Elasticsearch</distribution>
|
||||||
|
<group>Application/Internet</group>
|
||||||
|
<packager>Elasticsearch</packager>
|
||||||
|
<prefix>/usr</prefix>
|
||||||
|
<changelogFile>src/changelog</changelogFile>
|
||||||
|
<defineStatements>
|
||||||
|
<defineStatement>_unpackaged_files_terminate_build 0</defineStatement>
|
||||||
|
<defineStatement>_binaries_in_noarch_packages_terminate_build 0</defineStatement>
|
||||||
|
</defineStatements>
|
||||||
|
<defaultFilemode>644</defaultFilemode>
|
||||||
|
<defaultDirmode>755</defaultDirmode>
|
||||||
|
<defaultUsername>root</defaultUsername>
|
||||||
|
<defaultGroupname>root</defaultGroupname>
|
||||||
|
<mappings>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/elasticsearch/</directory>
|
||||||
|
<configuration>true</configuration>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/elasticsearch/</directory>
|
||||||
|
<configuration>true</configuration>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>config/</location>
|
||||||
|
<includes>
|
||||||
|
<include>*.yml</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/sysconfig/</directory>
|
||||||
|
<configuration>true</configuration>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>src/rpm/sysconfig</location>
|
||||||
|
<includes>
|
||||||
|
<include>elasticsearch</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/rc.d/init.d/</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<configuration>true</configuration>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>src/rpm/init.d/elasticsearch</location>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/systemd/system/</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<configuration>true</configuration>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>src/rpm/systemd</location>
|
||||||
|
<includes>
|
||||||
|
<include>elasticsearch.service</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/tmpfiles.d/</directory>
|
||||||
|
<configuration>true</configuration>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>src/rpm/systemd/</location>
|
||||||
|
<includes>
|
||||||
|
<include>elasticsearch.conf</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/var/run/elasticsearch/</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<username>elasticsearch</username>
|
||||||
|
<groupname>elasticsearch</groupname>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/var/lib/elasticsearch/</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<username>elasticsearch</username>
|
||||||
|
<groupname>elasticsearch</groupname>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/var/log/elasticsearch/</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<username>elasticsearch</username>
|
||||||
|
<groupname>elasticsearch</groupname>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/usr/share/elasticsearch/bin/</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>target/bin</location>
|
||||||
|
<includes>
|
||||||
|
<include>elasticsearch</include>
|
||||||
|
<include>elasticsearch.in.sh</include>
|
||||||
|
<include>plugin</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/usr/share/elasticsearch/lib</directory>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>target/lib/</location>
|
||||||
|
<includes>
|
||||||
|
<include>lucene*</include>
|
||||||
|
<include>log4j*</include>
|
||||||
|
<include>jna*</include>
|
||||||
|
<include>spatial4j*</include>
|
||||||
|
<include>jts*</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
<source>
|
||||||
|
<location>${project.build.directory}/</location>
|
||||||
|
<includes>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/usr/share/elasticsearch/lib/sigar</directory>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>lib/sigar</location>
|
||||||
|
<includes>
|
||||||
|
<include>sigar*.jar</include>
|
||||||
|
<include>libsigar-*-linux.*</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/usr/share/elasticsearch/</directory>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>.</location>
|
||||||
|
<includes>
|
||||||
|
<include>LICENSE.txt</include>
|
||||||
|
<include>NOTICE.txt</include>
|
||||||
|
<include>README.textile</include>
|
||||||
|
</includes>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
</mappings>
|
||||||
|
<preinstallScriptlet>
|
||||||
|
<scriptFile>src/rpm/scripts/preinstall</scriptFile>
|
||||||
|
<fileEncoding>utf-8</fileEncoding>
|
||||||
|
</preinstallScriptlet>
|
||||||
|
<postinstallScriptlet>
|
||||||
|
<scriptFile>src/rpm/scripts/postinstall</scriptFile>
|
||||||
|
<fileEncoding>utf-8</fileEncoding>
|
||||||
|
</postinstallScriptlet>
|
||||||
|
<preremoveScriptlet>
|
||||||
|
<scriptFile>src/rpm/scripts/preremove</scriptFile>
|
||||||
|
<fileEncoding>utf-8</fileEncoding>
|
||||||
|
</preremoveScriptlet>
|
||||||
|
<postremoveScriptlet>
|
||||||
|
<scriptFile>src/rpm/scripts/postremove</scriptFile>
|
||||||
|
<fileEncoding>utf-8</fileEncoding>
|
||||||
|
</postremoveScriptlet>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# elasticsearch <summary>
|
||||||
|
#
|
||||||
|
# chkconfig: 2345 80 20
|
||||||
|
# description: Starts and stops a single elasticsearch instance on this system
|
||||||
|
#
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: Elasticsearch
|
||||||
|
# Required-Start: $network
|
||||||
|
# Required-Stop: $network
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: This service manages the elasticsearch daemon
|
||||||
|
# Description: Elasticsearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search.
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
#
|
||||||
|
# init.d / servicectl compatibility (openSUSE)
|
||||||
|
#
|
||||||
|
if [ -f /etc/rc.status ]; then
|
||||||
|
. /etc/rc.status
|
||||||
|
rc_reset
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source function library.
|
||||||
|
#
|
||||||
|
if [ -f /etc/rc.d/init.d/functions ]; then
|
||||||
|
. /etc/rc.d/init.d/functions
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec="/usr/share/elasticsearch/bin/elasticsearch"
|
||||||
|
prog="elasticsearch"
|
||||||
|
pidfile=/var/run/elasticsearch/${prog}.pid
|
||||||
|
|
||||||
|
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
|
||||||
|
|
||||||
|
export ES_HEAP_SIZE
|
||||||
|
export ES_HEAP_NEWSIZE
|
||||||
|
export ES_DIRECT_SIZE
|
||||||
|
export ES_JAVA_OPTS
|
||||||
|
|
||||||
|
lockfile=/var/lock/subsys/$prog
|
||||||
|
|
||||||
|
start() {
|
||||||
|
[ -x $exec ] || exit 5
|
||||||
|
[ -f $CONF_FILE ] || exit 6
|
||||||
|
if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then
|
||||||
|
echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"
|
||||||
|
return 7
|
||||||
|
fi
|
||||||
|
if [ -n "$MAX_OPEN_FILES" ]; then
|
||||||
|
ulimit -n $MAX_OPEN_FILES
|
||||||
|
fi
|
||||||
|
if [ -n "$MAX_LOCKED_MEMORY" ]; then
|
||||||
|
ulimit -l $MAX_LOCKED_MEMORY
|
||||||
|
fi
|
||||||
|
if [ -n "$WORK_DIR" ]; then
|
||||||
|
mkdir -p "$WORK_DIR"
|
||||||
|
chown "$ES_USER":"$ES_GROUP" "$WORK_DIR"
|
||||||
|
fi
|
||||||
|
echo -n $"Starting $prog: "
|
||||||
|
# if not running, start it up here, usually something like "daemon $exec"
|
||||||
|
daemon --user $USER --pidfile $pidfile $exec -p $pidfile -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR
|
||||||
|
retval=$?
|
||||||
|
echo
|
||||||
|
[ $retval -eq 0 ] && touch $lockfile
|
||||||
|
return $retval
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
echo -n $"Stopping $prog: "
|
||||||
|
# stop it here, often "killproc $prog"
|
||||||
|
killproc -p $pidfile $prog
|
||||||
|
retval=$?
|
||||||
|
echo
|
||||||
|
[ $retval -eq 0 ] && rm -f $lockfile
|
||||||
|
return $retval
|
||||||
|
}
|
||||||
|
|
||||||
|
restart() {
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
restart
|
||||||
|
}
|
||||||
|
|
||||||
|
force_reload() {
|
||||||
|
restart
|
||||||
|
}
|
||||||
|
|
||||||
|
rh_status() {
|
||||||
|
# run checks to determine if the service is running or use generic status
|
||||||
|
status -p $pidfile $prog
|
||||||
|
}
|
||||||
|
|
||||||
|
rh_status_q() {
|
||||||
|
rh_status >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
rh_status_q && exit 0
|
||||||
|
$1
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
rh_status_q || exit 0
|
||||||
|
$1
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
$1
|
||||||
|
;;
|
||||||
|
reload)
|
||||||
|
rh_status_q || exit 7
|
||||||
|
$1
|
||||||
|
;;
|
||||||
|
force-reload)
|
||||||
|
force_reload
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
rh_status
|
||||||
|
;;
|
||||||
|
condrestart|try-restart)
|
||||||
|
rh_status_q || exit 0
|
||||||
|
restart
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||||
|
exit 2
|
||||||
|
esac
|
||||||
|
exit $?
|
|
@ -0,0 +1,17 @@
|
||||||
|
hasBeenEnabledOnStart=false
|
||||||
|
|
||||||
|
if [ $1 -eq 1 ] ; then
|
||||||
|
# Initial installation
|
||||||
|
if [ -x /bin/systemctl ] ; then
|
||||||
|
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||||
|
/bin/systemctl enable elasticsearch.service
|
||||||
|
/bin/systemctl start elasticsearch.service
|
||||||
|
hasBeenEnabledOnStart=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x /sbin/chkconfig -a "$hasBeenEnabledOnStart" == "false" ] ; then
|
||||||
|
/sbin/chkconfig --add elasticsearch
|
||||||
|
/etc/init.d/elasticsearch start
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
|
@ -0,0 +1,13 @@
|
||||||
|
echo "Removing elasticsearch user and group if existing"
|
||||||
|
|
||||||
|
getent passwd elasticsearch > /dev/null
|
||||||
|
if [ "$?" == "1" ] ; then
|
||||||
|
userdel elasticsearch
|
||||||
|
fi
|
||||||
|
|
||||||
|
getent group elasticsearch >/dev/null
|
||||||
|
if [ "$?" == "1" ] ; then
|
||||||
|
groupdel elasticsearch
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit
|
|
@ -0,0 +1,4 @@
|
||||||
|
getent group elasticsearch >/dev/null || groupadd -r elasticsearch
|
||||||
|
getent passwd elasticsearch >/dev/null || \
|
||||||
|
useradd -r -g elasticsearch -d /usr/lib/elasticsearch -s /sbin/nologin \
|
||||||
|
-c "elasticsearch user" elasticsearch
|
|
@ -0,0 +1,16 @@
|
||||||
|
if [ $1 -eq 0 ] ; then
|
||||||
|
# Package removal, not upgrade
|
||||||
|
if [ -x /bin/systemctl ] ; then
|
||||||
|
/bin/systemctl --no-reload disable elasticsearch.service > /dev/null 2>&1 || :
|
||||||
|
/bin/systemctl stop elasticsearch.service > /dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x /sbin/chkconfig ] ; then
|
||||||
|
if [ -x /etc/init.d/elasticsearch ] ; then
|
||||||
|
/etc/init.d/elasticsearch stop
|
||||||
|
fi
|
||||||
|
/sbin/chkconfig --del elasticsearch 2> /dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Directory where the ElasticSearch binary distribution resides
|
||||||
|
ES_HOME=/usr/share/elasticsearch
|
||||||
|
|
||||||
|
# Heap Size (defaults to 256m min, 1g max)
|
||||||
|
#ES_HEAP_SIZE=2g
|
||||||
|
|
||||||
|
# Heap new generation
|
||||||
|
#ES_HEAP_NEWSIZE=
|
||||||
|
|
||||||
|
# max direct memory
|
||||||
|
#ES_DIRECT_SIZE=
|
||||||
|
|
||||||
|
# Additional Java OPTS
|
||||||
|
#ES_JAVA_OPTS=
|
||||||
|
|
||||||
|
# Maximum number of open files
|
||||||
|
MAX_OPEN_FILES=65535
|
||||||
|
|
||||||
|
# Maximum amount of locked memory
|
||||||
|
#MAX_LOCKED_MEMORY=
|
||||||
|
|
||||||
|
# ElasticSearch log directory
|
||||||
|
LOG_DIR=/var/log/elasticsearch
|
||||||
|
|
||||||
|
# ElasticSearch data directory
|
||||||
|
DATA_DIR=/var/lib/elasticsearch
|
||||||
|
|
||||||
|
# ElasticSearch work directory
|
||||||
|
WORK_DIR=/tmp/elasticsearch
|
||||||
|
|
||||||
|
# ElasticSearch conf directory
|
||||||
|
CONF_DIR=/etc/elasticsearch
|
||||||
|
|
||||||
|
# ElasticSearch configuration file (elasticsearch.yml)
|
||||||
|
CONF_FILE=/etc/elasticsearch/elasticsearch.yml
|
||||||
|
|
||||||
|
# User to run as, change this to a specific elasticsearch user if possible
|
||||||
|
# Also make sure, this user can write into the log directories in case you change them
|
||||||
|
# This setting only works for the init script, but has to be configured separately for systemd startup
|
||||||
|
USER=elasticsearch
|
|
@ -0,0 +1 @@
|
||||||
|
d /run/elasticsearch 0755 elasticsearch elasticsearch - -
|
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Starts and stops a single elasticsearch instance on this system
|
||||||
|
Documentation=http://www.elasticsearch.org
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
EnvironmentFile=/etc/sysconfig/elasticsearch
|
||||||
|
User=elasticsearch
|
||||||
|
Group=elasticsearch
|
||||||
|
PIDFile=/var/run/elasticsearch/elasticsearch.pid
|
||||||
|
ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p /var/run/elasticsearch/elasticsearch.pid -Des.default.config=$CONF_FILE -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue