diff --git a/initrd.solr b/initrd.solr new file mode 100644 index 0000000000000000000000000000000000000000..4ac41ffc9db8951e695cc87ad90f9688e1a0d738 --- /dev/null +++ b/initrd.solr @@ -0,0 +1,111 @@ +#!/bin/sh +# +# chkconfig: - 50 50 +# +# Copyright (c) 2015 SUSE Linux GmbH Nuernberg, Germany. +# +# Author: Lars Vogdt +# +# +# /etc/init.d/solr +# +# and symbolic its link +# +# /usr/sbin/rcsolr +# +# System startup script for nagios +# +### BEGIN INIT INFO +# Provides: solr +# Required-Start: $local_fs $remote_fs $syslog $network +# Required-Stop: $local_fs $remote_fs $syslog $network +# Should-Start: $time sendmail xntpd $named cron +# Should-Stop: sendmail +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: Apache Solr Search Platform +# Description: Starts and stops the Apache Solr Search +# Daemon. Please remember to adapt /etc/solr.conf to +# your needs before you start the daemon. +### END INIT INFO + +SOLR_BIN=__LIBDIR__/solr/solr.sh +CONFIG=/etc/solr.conf + +. /etc/rc.status + +test -x "$SOLR_BIN" || { echo "$SOLR_BIN not installed or not executable."; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +# Check for existence of needed config file +test -r "$CONFIG" || { echo "$CONFIG not existing or readable."; + if [ "$1" = "stop" ]; then exit 0; + else exit 6; fi; } + + +# Reset status of this service +rc_reset + +resolve_instances() { + if [ "$1" == "" ]; then + INSTANCES="" + for i in `cat $CONFIG`; do + INSTANCES="$INSTANCES ${i%%:*}" + done + else + INSTANCES=$1 + fi +} + +case "$1" in + start) + echo -n "Starting SOLR $2 " + resolve_instances $2 + if [ -n $INSTANCES ]; then + for INSTANCE in $INSTANCES; do + LINE=`grep "^$INSTANCE:" $CONFIG` + $SOLR_BIN start `echo $LINE | sed -e's/:/ /g'` + RETVAL=$? + echo + done + rc_failed $RETVAL + else + echo "Error: could not find any instance definition." >&2 + rc_failed + fi + rc_status -v + ;; + stop) + echo -n "Stopping SOLR $2 " + resolve_instances $2 + if [ -n $INSTANCES ]; then + for INSTANCE in $INSTANCES; do + LINE=`grep "^$INSTANCE:" $CONFIG` + $SOLR_BIN stop `echo $LINE | sed -e's/:/ /g'` + RETVAL=$? + done + else + echo "Error: could not find any instance definition." >&2 + rc_failed + fi + rc_status -v + ;; + restart|reload|force-reload) + $0 stop $2 + $0 start $2 + rc_status + ;; + status) + echo -n "Checking for SOLR " + checkproc $SOLR_BIN + rc_status -v + ;; + *) + echo $"Usage: $0 {start|stop|restart} [instance]" + exit 1 +esac + +rc_exit + + diff --git a/solr-8.7.0.tgz b/solr-8.7.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..4ef594d3ba2b06eb9f10e2fc7248da23a30c57f0 Binary files /dev/null and b/solr-8.7.0.tgz differ diff --git a/solr.service b/solr.service new file mode 100644 index 0000000000000000000000000000000000000000..9d997756520a7481ffd8a1e5fb1120254763ac1e --- /dev/null +++ b/solr.service @@ -0,0 +1,21 @@ +[Unit] +Description=Apache Solr Search Platform +After=network.target + +[Service] +Type=simple +User=solr +StartLimitInterval=5 +StartLimitBurst=10 +SuccessExitStatus=143 +Restart=always +RestartSec=120 +TimeoutStopSec=120 +TimeoutSec=30 +EnvironmentFile=-/etc/solr/solr.in.sh + +ExecStart=/usr/bin/solr start -Djetty.host=${SOLR_LISTEN_HOST} -f +ExecStatus=/usr/bin/solr status + +[Install] +WantedBy=multi-user.target diff --git a/solr.sh b/solr.sh new file mode 100644 index 0000000000000000000000000000000000000000..b99710909ebb498c557195e5203718c86dae3d55 --- /dev/null +++ b/solr.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +. /etc/init.d/functions + +INSTANCE=$2 +JETTY_PORT=$3 +STOP_PORT=$4 +DIR=$5 + +PIDFILE="$DIR/$INSTANCE.pid" +LOGFILE="/var/log/solr/$INSTANCE.log" + +RETVAL=0 +OPTIONS="-DSTOP.PORT=$STOP_PORT -Djetty.port=$JETTY_PORT -DSTOP.KEY=stopkey" +# -Xmx1024m +JAVA="/usr/bin/java" + +start() { + echo -n $"Starting solr ($INSTANCE)" + if [ ! -f $PIDFILE ]; then + echo "starting Solr" >> $LOGFILE + cd $DIR + find solr -type f -name write.lock -exec rm -f {} \; + java $OPTIONS -jar $DIR/start.jar 2>> $LOGFILE >> $LOGFILE < /dev/null & + echo $! > $PIDFILE + else + echo "Solr already running!" + fi + RETVAL=$? + echo + return $RETVAL +} + +stop() { + echo -n $"Stopping solr ($INSTANCE)" + if [ -f $PIDFILE ]; then + kill `cat $PIDFILE` + rm -f $PIDFILE + fi + RETVAL=$? + echo + return $RETVAL +} + +if [ `whoami` != "solr" ]; then + runuser solr $0 $* + exit $? +fi + +if [ -z "$INSTANCE" ]; then + echo $"Usage: $0 {start|stop} [] []" + exit 1 +fi + +case "$1" in + start) + if [ -z "$STOP_PORT" ]; then + echo $"Usage: $0 {start|stop} [] []" + exit 1 + fi + + start + ;; + stop) + stop + ;; + *) + echo $"Usage: $0 {start|stop} " + RETVAL=1 +esac + +exit $RETVAL diff --git a/solr.spec b/solr.spec new file mode 100644 index 0000000000000000000000000000000000000000..44b69c9dbe76a28cff08798406acb36e30fe0c09 --- /dev/null +++ b/solr.spec @@ -0,0 +1,138 @@ +%bcond_with systemd +Name: solr +Version: 8.7.0 +Release: 1 +License: Apache-2.0 +Summary: Apache Solr +Url: https://solr.apache.org/ +Group: System Environment/Daemons +Source0: %{name}-%{version}.tgz +Source1: initrd.solr +Source2: solr.sh +Source4: solr.tmpfile +Requires: java +Recommends: awk +Recommends: bash +Recommends: coreutils +Recommends: findutils +Recommends: grep +Recommends: lsof +Recommends: procps +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: fdupes +%if %{with systemd} +BuildRequires: systemd +Suggests: systemd +%{?systemd_requires} +Source3: solr.service +%endif + +%define solruser solr +%define solrgroup apache +%define _initddir %{_sysconfdir}/init.d +%define debug_package %{nil} +%description +Solr is the popular, blazing fast open source enterprise search platform from +the Apache Lucene project. Its major features include powerful full-text +search, hit highlighting, faceted search, dynamic clustering, database +integration, rich document (e.g., Word, PDF) handling, and geospatial search. +Solr is highly scalable, providing distributed search and index replication, +and it powers the search and navigation features of many of the world's largest +internet sites. + +%prep +%setup -q + +%build + +%install +install -D -m 0755 bin/solr %{buildroot}%{_bindir}/solr +install -D -m 0644 server/solr/solr.xml %{buildroot}%{_localstatedir}/lib/%{name}/%{name}.xml +mkdir -p %{buildroot}/%{_datadir}/%{name} %{buildroot}%{_sysconfdir}/%{name} %{buildroot}/%{_sbindir} +cp -a server %{buildroot}%{_datadir}/%{name} + +cat >> %{buildroot}%{_sysconfdir}/%{name}/%{name}.in.sh << EOF +LOG4J_PROPS=%{_sysconfdir}/%{name}/log4j.properties +SOLR_LOGS_DIR=%{_localstatedir}/log/%{name} +SOLR_SERVER_DIR=%{_datadir}/%{name} +SOLR_PID_DIR=/run/%{name}/ +SOLR_HOME=%{_localstatedir}/lib/%{name}/ +SOLR_LISTEN_HOST=localhost +EOF + +%if %{with systemd} +%{__install} -Dp -m0644 %{SOURCE3} %{buildroot}%{_prefix}/lib/systemd/system/%{name}.service +ln -s %{_prefix}/lib/systemd/system/solr.service %{buildroot}/%{_sbindir}/rc%{name} +install -D -m 0644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/%{name}.conf +%else +mkdir -p %{buildroot}%{_initddir} +install -D -m 755 %{SOURCE1} %{buildroot}%{_initddir}/%{name} +ln -s %{_initddir}/%{name} %{buildroot}/%{_sbindir}/rc%{name} +%endif + +mkdir -p %{buildroot}%{_libdir}/%{name} +install -D -m 755 %{SOURCE2} %{buildroot}%{_libdir}/%{name} +mkdir -p %{buildroot}%{_localstatedir}/log/%{name} + +%pre +if ! /usr/bin/getent group %{solrgroup} &>/dev/null; then + echo "Creating %{solrgroup} user" + /usr/sbin/groupadd -r %{solrgroup} +fi +if ! /usr/bin/getent passwd %{solruser} &>/dev/null; then + echo "Creating %solruser user" + /usr/sbin/useradd -r -g %{solrgroup} \ + -r %{solruser} +fi +%if %{with systemd} +%service_add_pre %{name}.service +%endif + +%post +%if %{with systemd} + %systemd_post solr.service +%else + /sbin/chkconfig --add %{name} +%endif + +%preun +%if %{with systemd} + %systemd_preun solr.service +%else + if [ "$1" = 0 ]; then + /sbin/service %{name} stop > /dev/null 2>&1 + /sbin/chkconfig --del %{name} + fi +%endif + +%postun +%if %{with systemd} + %systemd_postun_with_restart solr.service +%else + if [ "$1" -ge 1 ]; then + /sbin/service %{name} condrestart >/dev/null 2>&1 + fi +%endif + +%files +%defattr(-,root,root) +%config(noreplace) %{_sysconfdir}/%{name}/%{name}.in.sh +%config(noreplace) %attr(-,%{solruser},%{solrgroup}) %{_localstatedir}/lib/solr/solr.xml +%dir %{_sysconfdir}/%{name} +%{_datadir}/%{name} +%{_bindir}/%{name} +%if %{with systemd} +%{_prefix}/lib/systemd/system/%{name}.service +%{_tmpfilesdir}/%{name}.conf +%else +%config %{_initddir}/%{name} +%endif +%{_sbindir}/rc%{name} +%attr(750,%{solruser},%{solrgroup}) %dir %{_libdir}/%{name} +%attr(750,%{solruser},%{solrgroup}) %{_libdir}/%{name}/solr.sh +%attr(755,%{solruser},%{solrgroup}) %dir %{_localstatedir}/log/solr +%attr(755,%{solruser},%{solrgroup}) %dir %{_localstatedir}/lib/solr + +%changelog +* Fri Jul 30 2021 shenhongyi - 8.7.0-1 +- Package init diff --git a/solr.tmpfile b/solr.tmpfile new file mode 100644 index 0000000000000000000000000000000000000000..e90e0797ff21392209b25bd9ba09e0ea57ad6c38 --- /dev/null +++ b/solr.tmpfile @@ -0,0 +1 @@ +D /run/solr 0770 solr root -