diff --git a/distribution/rpm/.gitignore b/distribution/rpm/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0f630157f4bf530f9697788f383cabaab83dc2e8 --- /dev/null +++ b/distribution/rpm/.gitignore @@ -0,0 +1,2 @@ +/target/ +/bin/ diff --git a/pom.xml b/pom.xml index c1d906b60463fbe29a1f47873e9e57f54e34bcba..4c74411a40ded0be91861644899a9eb4959fb290 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.codelibs.fess</groupId> <artifactId>fess</artifactId> @@ -69,6 +70,22 @@ <!-- Tomcat --> <tomcat.boot.version>0.4.0-RC2</tomcat.boot.version> + + <!-- TODO: RPM build --> + <packaging.fess.home.dir>/opt/fess</packaging.fess.home.dir> + <packaging.fess.app.dir>${packaging.fess.home.dir}/app</packaging.fess.app.dir> + <packaging.fess.bin.dir>${packaging.fess.home.dir}/bin</packaging.fess.bin.dir> + <packaging.fess.es.dir>${packaging.fess.home.dir}/es</packaging.fess.es.dir> + <packaging.fess.lib.dir>${packaging.fess.home.dir}/es</packaging.fess.lib.dir> + <packaging.fess.logs.dir>${packaging.fess.home.dir}/es</packaging.fess.logs.dir> + <packaging.fess.temp.dir>${packaging.fess.home.dir}/es</packaging.fess.temp.dir> + <packaging.fess.user>fess</packaging.fess.user> + <packaging.fess.group>fess</packaging.fess.group> + <packaging.fess.pid.dir>/var/run/fess</packaging.fess.pid.dir> + <packaging.fess.systemd.dir>/usr/lib/systemd/system</packaging.fess.systemd.dir> + <packaging.fess.systemd.sysctl.dir>/usr/lib/sysctl.d</packaging.fess.systemd.sysctl.dir> + <packaging.fess.tmpfilesd.dir>/usr/lib/tmpfiles.d</packaging.fess.tmpfilesd.dir> + </properties> <build> <finalName>fess</finalName> @@ -169,27 +186,6 @@ <charset>UTF-8</charset> </configuration> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.6</version> - <configuration> - <finalName>${project.artifactId}-${project.version}</finalName> - <appendAssemblyId>false</appendAssemblyId> - <outputDirectory>${project.build.directory}/releases/</outputDirectory> - <descriptors> - <descriptor>${basedir}/src/main/assemblies/package.xml</descriptor> - </descriptors> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId> @@ -283,6 +279,322 @@ <goal>run</goal> </goals> </plugin> + + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>copy-resources-rpm</id> + <phase>prepare-package</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/generated-packaging/rpm/</outputDirectory> + <filters> + <filter>${project.basedir}/src/packaging/common/packaging.properties</filter> + <filter>${project.basedir}/src/packaging/rpm/packaging.properties</filter> + </filters> + <resources> + <resource> + <directory>src/packaging/common/</directory> + <filtering>true</filtering> + <includes> + <include>**/*</include> + </includes> + <excludes> + <exclude>packaging.properties</exclude> + </excludes> + </resource> + <resource> + <directory>src/packaging/rpm/</directory> + <filtering>true</filtering> + <includes> + <include>**/*</include> + </includes> + <excludes> + <exclude>packaging.properties</exclude> + </excludes> + </resource> + <resource> + <directory>${project.basedir}</directory> + <filtering>true</filtering> + <includes> + <include>bin/fess</include> + <include>bin/fess.in.sh</include> + </includes> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + + <!-- zip --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.6</version> + <configuration> + <finalName>${project.artifactId}-${project.version}</finalName> + <appendAssemblyId>false</appendAssemblyId> + <outputDirectory>${project.build.directory}/releases/</outputDirectory> + <descriptors> + <descriptor>${basedir}/src/main/assemblies/package.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + + <!-- rpm --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>rpm-maven-plugin</artifactId> + <version>2.1.4</version> + <executions> + <execution> + <id>generate-rpm</id> + <phase>package</phase> + <goals> + <goal>rpm</goal> + </goals> + </execution> + </executions> + <configuration> + <distribution>Fess</distribution> + <group>Application/Internet</group> + <packager>Fess</packager> + <prefix>/opt</prefix> + <needarch>noarch</needarch> + <targetOS>linux</targetOS> + <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>${packaging.fess.user}</defaultUsername> + <defaultGroupname>${packaging.fess.group}</defaultGroupname> + <!-- + <keyname>${gpg.key}</keyname> + <keypath>${gpg.keyring}</keypath> + <keyPassphrase> + <passphrase>${gpg.passphrase}</passphrase> + </keyPassphrase> + --> + <mappings> + <!-- fess home --> + <mapping> + <directory>${packaging.fess.home.dir}</directory> + <directoryIncluded>true</directoryIncluded> + <recurseDirectories>true</recurseDirectories> + </mapping> + <!-- app --> + <mapping> + <directory>${packaging.fess.home.dir}/app</directory> + <filemode>755</filemode> + <sources> + <source> + <location>${project.build.directory}/fess</location> + </source> + </sources> + </mapping> + <!-- lib --> + <mapping> + <directory>${packaging.fess.home.dir}/lib/classes</directory> + <sources> + <source> + <location>${project.build.directory}/tomcat-lib</location> + </source> + </sources> + </mapping> + <mapping> + <directory>${packaging.fess.home.dir}/lib/classes/org/codelibs/fess</directory> + <sources> + <source> + <location>${project.build.directory}/fess/WEB-INF/classes/org/codelibs/fess</location> + <includes> + <include>FessBoot**</include> + </includes> + </source> + </sources> + </mapping> + <mapping> + <directory>${packaging.fess.home.dir}/lib/classes</directory> + <sources> + <source> + <location>${project.basedir}/src/main/assemblies/files</location> + <includes> + <include>logging.properties</include> + <include>tomcat_config.properties</include> + </includes> + </source> + </sources> + </mapping> + <!-- bin --> + <mapping> + <directory>${packaging.fess.home.dir}/bin</directory> + <filemode>755</filemode> + <sources> + <source> + <location>${project.basedir}/src/main/assemblies/files</location> + <includes> + <include>fess</include> + <include>fess.in.sh</include> + </includes> + </source> + </sources> + </mapping> + <!-- logs (empty) --> + <mapping> + <directory>${packaging.fess.home.dir}/logs</directory> + </mapping> + <!-- temp (empty) --> + <mapping> + <directory>${packaging.fess.home.dir}/temp</directory> + </mapping> + <!-- es/plugins --> + <mapping> + <directory>${packaging.fess.home.dir}/es/plugins</directory> + <sources> + <source> + <location>${project.basedir}/plugins</location> + </source> + </sources> + </mapping> + <!-- es/data (empty) --> + <mapping> + <directory>${packaging.fess.home.dir}/es/data</directory> + </mapping> + <!-- Add environment vars file --> + <mapping> + <directory>/etc/sysconfig/</directory> + <directoryIncluded>false</directoryIncluded> + <username>root</username> + <groupname>root</groupname> + <configuration>noreplace</configuration> + <sources> + <source> + <location>${project.build.directory}/generated-packaging/rpm/env/</location> + <includes> + <include>fess</include> + </includes> + </source> + </sources> + </mapping> + <!-- Add init.d files --> + <mapping> + <directory>/etc/init.d</directory> + <directoryIncluded>false</directoryIncluded> + <filemode>755</filemode> + <username>root</username> + <groupname>root</groupname> + <configuration>true</configuration> + <sources> + <source> + <location>${project.build.directory}/generated-packaging/rpm/init.d</location> + <includes> + <include>fess</include> + </includes> + </source> + </sources> + </mapping> + <!-- Adds systemd file --> + <mapping> + <directory>${packaging.fess.systemd.dir}</directory> + <directoryIncluded>false</directoryIncluded> + <username>root</username> + <groupname>root</groupname> + <configuration>true</configuration> + <sources> + <source> + <location>${project.build.directory}/generated-packaging/rpm/systemd</location> + <includes> + <include>fess.service</include> + </includes> + </source> + </sources> + </mapping> + <!-- Adds systemd/sysctl.d configuration file --> + <mapping> + <directory>${packaging.fess.systemd.sysctl.dir}</directory> + <directoryIncluded>false</directoryIncluded> + <username>root</username> + <groupname>root</groupname> + <configuration>true</configuration> + <sources> + <source> + <location>${project.build.directory}/generated-packaging/rpm/systemd/sysctl</location> + <includes> + <include>fess.conf</include> + </includes> + </source> + </sources> + </mapping> + <!-- Adds systemd/tmpfiles.d configuration file --> + <mapping> + <directory>${packaging.fess.tmpfilesd.dir}</directory> + <directoryIncluded>false</directoryIncluded> + <username>root</username> + <groupname>root</groupname> + <configuration>true</configuration> + <sources> + <source> + <location>${project.build.directory}/generated-packaging/rpm/systemd/</location> + <includes> + <include>fess.conf</include> + </includes> + </source> + </sources> + </mapping> + <!-- Add readme files --> + <mapping> + <directory>${packaging.fess.home.dir}</directory> + <sources> + <source> + <location>.</location> + <includes> + <include>LICENSE</include> + <include>README.md</include> + </includes> + </source> + </sources> + </mapping> + <!-- Add and sets permission on default directories --> + <mapping> + <directory>${packaging.fess.pid.dir}</directory> + <filemode>755</filemode> + <username>${packaging.fess.user}</username> + <groupname>${packaging.fess.group}</groupname> + </mapping> + </mappings> + <preinstallScriptlet> + <scriptFile>${project.build.directory}/generated-packaging/rpm/scripts/preinst</scriptFile> + <fileEncoding>utf-8</fileEncoding> + </preinstallScriptlet> + <postinstallScriptlet> + <scriptFile>${project.build.directory}/generated-packaging/rpm/scripts/postinst</scriptFile> + <fileEncoding>utf-8</fileEncoding> + </postinstallScriptlet> + <preremoveScriptlet> + <scriptFile>${project.build.directory}/generated-packaging/rpm/scripts/prerm</scriptFile> + <fileEncoding>utf-8</fileEncoding> + </preremoveScriptlet> + <postremoveScriptlet> + <scriptFile>${project.build.directory}/generated-packaging/rpm/scripts/postrm</scriptFile> + <fileEncoding>utf-8</fileEncoding> + </postremoveScriptlet> + </configuration> + </plugin> </plugins> </build> <pluginRepositories> diff --git a/src/main/assemblies/files/fess b/src/main/assemblies/files/fess index 876a8f902c7b7e8a5f79a64263f24095924410bf..78a949c03f70a25595154532a9aecd88a84aefd0 100644 --- a/src/main/assemblies/files/fess +++ b/src/main/assemblies/files/fess @@ -29,7 +29,7 @@ done # determine fess home FESS_HOME=`dirname "$SCRIPT"`/.. -# make ELASTICSEARCH_HOME absolute +# make FESS_HOME absolute FESS_HOME=`cd "$FESS_HOME"; pwd` @@ -94,6 +94,8 @@ launch_service() export HOSTNAME=`hostname -s` + cd "$FESS_HOME" + if [ "x$daemonized" = "x" ]; then fess_parms="$fess_parms -Dfess.foreground=yes" exec "$JAVA" $JAVA_OPTS $FESS_JAVA_OPTS $fess_parms -Dfess.es.dir="$ES_HOME" -cp "$FESS_CLASSPATH" $props \ diff --git a/src/packaging/common/env/fess b/src/packaging/common/env/fess new file mode 100644 index 0000000000000000000000000000000000000000..dddefce37aed53f2377b01b4941387f255392e43 --- /dev/null +++ b/src/packaging/common/env/fess @@ -0,0 +1,3 @@ +################################ +# Fess +################################ diff --git a/src/packaging/common/packaging.properties b/src/packaging/common/packaging.properties new file mode 100644 index 0000000000000000000000000000000000000000..22ff6c96ba689bb135d9b6ce093c0aaea8744fe5 --- /dev/null +++ b/src/packaging/common/packaging.properties @@ -0,0 +1,26 @@ +# Common properties for building ZIP,GZ,RPM and DEB packages +# +# Properties defined here can be overridden with specific settings, +# like in rpm/packaging.properties and deb/packaging.properties. + +# Environment file +packaging.env.file= + +# Default configuration directory and file to use in bin/plugin script + +# Default values for min/max heap memory allocated to fess java process +packaging.fess.heap.min=256m +packaging.fess.heap.max=1g + +# Specifies the maximum file descriptor number +packaging.os.max.open.files=65535 + +# Maximum number of VMA (Virtual Memory Areas) a process can own +packaging.os.max.map.count=262144 + +# Simple marker to check that properties are correctly overridden +packaging.type=tar.gz + +# Custom header for package scripts +packaging.scripts.header= +packaging.scripts.footer= diff --git a/src/packaging/common/scripts/postinst b/src/packaging/common/scripts/postinst new file mode 100644 index 0000000000000000000000000000000000000000..3a9d217df0315a701a1414b1d5f1a97df1576f3e --- /dev/null +++ b/src/packaging/common/scripts/postinst @@ -0,0 +1,101 @@ +${packaging.scripts.header} + +# +# This script is executed in the post-installation phase +# +# On Debian, +# $1=configure : is set to 'configure' and if $2 is set, it is an upgrade +# +# On RedHat, +# $1=0 : indicates a removal +# $1=1 : indicates an upgrade + + + +# Sets the default values for fess variables used in this script +FESS_USER="${packaging.fess.user}" +FESS_GROUP="${packaging.fess.group}" + +# Source the default env file +FESS_ENV_FILE="${packaging.env.file}" +if [ -f "$FESS_ENV_FILE" ]; then + . "$FESS_ENV_FILE" +fi + +IS_UPGRADE=false + +case "$1" in + + # Debian #################################################### + configure) + + # If $1=configure and $2 is set, this is an upgrade + if [ -n $2 ]; then + IS_UPGRADE=true + fi + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + # RedHat #################################################### + 1) + # If $1=1 this is an install + IS_UPGRADE=false + ;; + 2) + # If $1=1 this is an upgrade + IS_UPGRADE=true + ;; + + *) + echo "post install script called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +if [ "x$IS_UPGRADE" != "xtrue" ]; then + if command -v systemctl >/dev/null; then + echo "### NOT starting on installation, please execute the following statements to configure fess service to start automatically using systemd" + echo " sudo systemctl daemon-reload" + echo " sudo systemctl enable fess.service" + echo "### You can start fess service by executing" + echo " sudo systemctl start fess.service" + + elif command -v chkconfig >/dev/null; then + echo "### NOT starting on installation, please execute the following statements to configure fess service to start automatically using chkconfig" + echo " sudo chkconfig --add fess" + echo "### You can start fess service by executing" + echo " sudo service fess start" + + elif command -v update-rc.d >/dev/null; then + echo "### NOT starting on installation, please execute the following statements to configure fess service to start automatically using chkconfig" + echo " sudo update-rc.d fess defaults 95 10" + echo "### You can start fess service by executing" + echo " sudo /etc/init.d/fess start" + fi +elif [ "$RESTART_ON_UPGRADE" = "true" ]; then + + echo -n "Restarting fess service..." + if command -v systemctl >/dev/null; then + systemctl daemon-reload + systemctl restart fess.service || true + + elif [ -x /etc/init.d/fess ]; then + if command -v invoke-rc.d >/dev/null; then + invoke-rc.d fess stop || true + invoke-rc.d fess start || true + else + /etc/init.d/fess restart || true + fi + + # older suse linux distributions do not ship with systemd + # but do not have an /etc/init.d/ directory + # this tries to start the fess service on these + # as well without failing this script + elif [ -x /etc/rc.d/init.d/fess ] ; then + /etc/rc.d/init.d/fess restart || true + fi + echo " OK" +fi + +${packaging.scripts.footer} diff --git a/src/packaging/common/scripts/postrm b/src/packaging/common/scripts/postrm new file mode 100644 index 0000000000000000000000000000000000000000..982d705a35151b7c415dc0246ac54738cb30127c --- /dev/null +++ b/src/packaging/common/scripts/postrm @@ -0,0 +1,97 @@ +${packaging.scripts.header} + +# +# This script is executed in the post-removal phase +# +# On Debian, +# $1=remove : indicates a removal +# $1=purge : indicates an upgrade +# +# On RedHat, +# $1=0 : indicates a removal +# $1=1 : indicates an upgrade + + + +SOURCE_ENV_FILE=true +REMOVE_DIRS=false +REMOVE_SERVICE=false +REMOVE_USER_AND_GROUP=false + +case "$1" in + + # Debian #################################################### + remove) + REMOVE_DIRS=true + REMOVE_SERVICE=true + ;; + + purge) + REMOVE_USER_AND_GROUP=true + SOURCE_ENV_FILE=false + ;; + failed-upgrade|abort-install|abort-upgrade|disappear|upgrade|disappear) + ;; + + # RedHat #################################################### + 0) + REMOVE_DIRS=true + REMOVE_SERVICE=true + REMOVE_USER_AND_GROUP=true + ;; + 1) + # If $1=1 this is an upgrade + IS_UPGRADE=true + ;; + + *) + echo "post remove script called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# Sets the default values for fess variables used in this script +FESS_USER="${packaging.fess.user}" +FESS_GROUP="${packaging.fess.group}" +PID_DIR="${packaging.fess.pid.dir}" + +# Source the default env file +if [ "$SOURCE_ENV_FILE" = "true" ]; then + FESS_ENV_FILE="${packaging.env.file}" + if [ -f "$FESS_ENV_FILE" ]; then + . "$FESS_ENV_FILE" + fi +fi + +if [ "$REMOVE_SERVICE" = "true" ]; then + if command -v systemctl >/dev/null; then + systemctl --no-reload disable fess.service > /dev/null 2>&1 || true + fi + + if command -v chkconfig >/dev/null; then + chkconfig --del fess 2> /dev/null || true + fi + + if command -v update-rc.d >/dev/null; then + update-rc.d fess remove >/dev/null || true + fi +fi + +if [ "$REMOVE_DIRS" = "true" ]; then + if [ -d "$PID_DIR" ]; then + echo -n "Deleting PID directory..." + rm -rf "$PID_DIR" && echo " OK" || echo " ERROR: unable to delete directory [$PID_DIR]" + fi +fi + +if [ "$REMOVE_USER_AND_GROUP" = "true" ]; then + if id "$FESS_USER" > /dev/null 2>&1 ; then + userdel "$FESS_USER" + fi + + if getent group "$FESS_GROUP" > /dev/null 2>&1 ; then + groupdel "$FESS_GROUP" + fi +fi + +${packaging.scripts.footer} diff --git a/src/packaging/common/scripts/preinst b/src/packaging/common/scripts/preinst new file mode 100644 index 0000000000000000000000000000000000000000..05af57e2987f2930b4c8012d132c1b45346976a6 --- /dev/null +++ b/src/packaging/common/scripts/preinst @@ -0,0 +1,83 @@ +${packaging.scripts.header} + +# +# This script is executed in the pre-installation phase +# +# On Debian, +# $1=install : indicates an new install +# $1=upgrade : indicates an upgrade +# +# On RedHat, +# $1=1 : indicates an new install +# $1=2 : indicates an upgrade + + + +# Sets the default values for fess variables used in this script +FESS_USER="${packaging.fess.user}" +FESS_GROUP="${packaging.fess.group}" + +# Source the default env file +FESS_ENV_FILE="${packaging.env.file}" +if [ -f "$FESS_ENV_FILE" ]; then + . "$FESS_ENV_FILE" +fi + +case "$1" in + + # Debian #################################################### + install|upgrade) + + # Create fess group if not existing + if ! getent group "$FESS_GROUP" > /dev/null 2>&1 ; then + echo -n "Creating $FESS_GROUP group..." + addgroup --quiet --system "$FESS_GROUP" + echo " OK" + fi + + # Create fess user if not existing + if ! id $FESS_USER > /dev/null 2>&1 ; then + echo -n "Creating $FESS_USER user..." + adduser --quiet \ + --system \ + --no-create-home \ + --ingroup "$FESS_GROUP" \ + --disabled-password \ + --shell /bin/false \ + "$FESS_USER" + echo " OK" + fi + ;; + abort-deconfigure|abort-upgrade|abort-remove) + ;; + + # RedHat #################################################### + 1|2) + + # Create fess group if not existing + if ! getent group "$FESS_GROUP" > /dev/null 2>&1 ; then + echo -n "Creating $FESS_GROUP group..." + groupadd -r "$FESS_GROUP" + echo " OK" + fi + + # Create fess user if not existing + if ! id $FESS_USER > /dev/null 2>&1 ; then + echo -n "Creating $FESS_USER user..." + useradd --system \ + -M \ + --gid "$FESS_GROUP" \ + --shell /sbin/nologin \ + --comment "fess user" \ + "$FESS_USER" + echo " OK" + fi + ;; + + *) + echo "pre install script called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +${packaging.scripts.footer} diff --git a/src/packaging/common/scripts/prerm b/src/packaging/common/scripts/prerm new file mode 100644 index 0000000000000000000000000000000000000000..fe59cdc32d0cc3c176de131f531aa223abb280f6 --- /dev/null +++ b/src/packaging/common/scripts/prerm @@ -0,0 +1,69 @@ +${packaging.scripts.header} + +# +# This script is executed in the pre-remove phase +# +# On Debian, +# $1=remove : indicates a removal +# $1=upgrade : indicates an upgrade +# +# On RedHat, +# $1=0 : indicates a removal +# $1=1 : indicates an upgrade + + + +STOP_REQUIRED=false + +case "$1" in + + # Debian #################################################### + remove) + STOP_REQUIRED=true + ;; + upgrade) + if [ "$RESTART_ON_UPGRADE" = "true" ]; then + STOP_REQUIRED=true + fi + ;; + deconfigure|failed-upgrade) + ;; + + # RedHat #################################################### + 0) + STOP_REQUIRED=true + ;; + 1) + # Dont do anything on upgrade, because the preun script in redhat gets executed after the postinst (madness!) + ;; + + *) + echo "pre remove script called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# Stops the service +if [ "$STOP_REQUIRED" = "true" ]; then + echo -n "Stopping fess service..." + if command -v systemctl >/dev/null; then + systemctl --no-reload stop fess.service > /dev/null 2>&1 || true + + elif [ -x /etc/init.d/fess ]; then + if command -v invoke-rc.d >/dev/null; then + invoke-rc.d fess stop || true + else + /etc/init.d/fess stop || true + fi + + # older suse linux distributions do not ship with systemd + # but do not have an /etc/init.d/ directory + # this tries to start the fess service on these + # as well without failing this script + elif [ -x /etc/rc.d/init.d/fess ] ; then + /etc/rc.d/init.d/fess stop || true + fi + echo " OK" +fi + +${packaging.scripts.footer} diff --git a/src/packaging/common/systemd/fess.conf b/src/packaging/common/systemd/fess.conf new file mode 100644 index 0000000000000000000000000000000000000000..2df5fe1c2366af33d5c63bdaa4a126afb81d8bcf --- /dev/null +++ b/src/packaging/common/systemd/fess.conf @@ -0,0 +1 @@ +d ${packaging.fess.pid.dir} 0755 ${packaging.fess.user} ${packaging.fess.group} - - diff --git a/src/packaging/common/systemd/fess.service b/src/packaging/common/systemd/fess.service new file mode 100644 index 0000000000000000000000000000000000000000..80dc68767bd22a545ce865570fbae7b54b9d145e --- /dev/null +++ b/src/packaging/common/systemd/fess.service @@ -0,0 +1,38 @@ +[Unit] +Description=Fess +Documentation=http://fess.codelibs.org/ +Wants=network-online.target +After=network-online.target + +[Service] +Environment=FESS_HOME=${packaging.fess.home.dir} + +User=${packaging.fess.user} +Group=${packaging.fess.group} + +ExecStart=${packaging.fess.bin.dir}/fess + +# Connects standard output to /dev/null +StandardOutput=null + +# Connects standard error to journal +StandardError=journal + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=${packaging.os.max.open.files} + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.mlockall: true' option +# in fess.yml and 'MAX_LOCKED_MEMORY=unlimited' in ${packaging.env.file} +#LimitMEMLOCK=infinity + +# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured) +TimeoutStopSec=20 + +[Install] +WantedBy=multi-user.target + +# Built for ${project.name}-${project.version} (${packaging.type}) diff --git a/src/packaging/common/systemd/sysctl/fess.conf b/src/packaging/common/systemd/sysctl/fess.conf new file mode 100644 index 0000000000000000000000000000000000000000..052cd89cf0b88fe560c7ff3d8bd5f6984f9cf3e0 --- /dev/null +++ b/src/packaging/common/systemd/sysctl/fess.conf @@ -0,0 +1 @@ +vm.max_map_count=${packaging.os.max.map.count} diff --git a/src/packaging/deb/copyright b/src/packaging/deb/copyright new file mode 100644 index 0000000000000000000000000000000000000000..a6568af62c4fcd75fa0500476427a6d723e7fd1c --- /dev/null +++ b/src/packaging/deb/copyright @@ -0,0 +1,17 @@ +Copyright(C) 2009-2015 CodeLibs Project. All Rights Reserved. + +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 version 2.0 license + can be found in "/usr/share/common-licenses/Apache-2.0". diff --git a/src/packaging/deb/init.d/fess b/src/packaging/deb/init.d/fess new file mode 100755 index 0000000000000000000000000000000000000000..0cfe912447782ee744e10b64dfd8ab8255a9dc70 --- /dev/null +++ b/src/packaging/deb/init.d/fess @@ -0,0 +1,224 @@ +#!/bin/sh +# +# /etc/init.d/fess -- startup script for Fess +# +# Written by Miquel van Smoorenburg <miquels@cistron.nl>. +# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>. +# Modified for Tomcat by Stefan Gybas <sgybas@debian.org>. +# Modified for Tomcat6 by Thierry Carrez <thierry.carrez@ubuntu.com>. +# Additional improvements by Jason Brittain <jason.brittain@mulesoft.com>. +# Modified by Nicolas Huray for Fess <nicolas.huray@gmail.com>. +# +### BEGIN INIT INFO +# Provides: fess +# Required-Start: $network $remote_fs $named +# Required-Stop: $network $remote_fs $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts fess +# Description: Starts fess using start-stop-daemon +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +NAME=fess +DESC="Fess Server" +DEFAULT=/etc/default/$NAME + +if [ `id -u` -ne 0 ]; then + echo "You need root privileges to run this script" + exit 1 +fi + + +. /lib/lsb/init-functions + +if [ -r /etc/default/rcS ]; then + . /etc/default/rcS +fi + +# The following variables can be overwritten in $DEFAULT + +# Run Fess as this user ID and group ID +FESS_USER=fess +FESS_GROUP=fess + +# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT) +JDK_DIRS="/usr/lib/jvm/java-8-oracle/ /usr/lib/jvm/j2sdk1.8-oracle/ /usr/lib/jvm/jdk-7-oracle-x64 /usr/lib/jvm/java-7-oracle /usr/lib/jvm/j2sdk1.7-oracle/ /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-armhf /usr/lib/jvm/java-7-openjdk-i386/ /usr/lib/jvm/default-java" + +# Look for the right JVM to use +for jdir in $JDK_DIRS; do + if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then + JAVA_HOME="$jdir" + fi +done +export JAVA_HOME + +# Directory where the Fess binary distribution resides +FESS_HOME=/usr/share/$NAME + +# Heap size defaults to 256m min, 1g max +# Set FESS_HEAP_SIZE to 50% of available RAM, but no more than 31g +#FESS_HEAP_SIZE=2g + +# Heap new generation +#FESS_HEAP_NEWSIZE= + +# max direct memory +#FESS_DIRECT_SIZE= + +# Additional Java OPTS +#FESS_JAVA_OPTS= + +# Maximum number of open files +MAX_OPEN_FILES=65535 + +# Maximum amount of locked memory +#MAX_LOCKED_MEMORY= + +# Fess log directory +#LOG_DIR=/var/log/$NAME + +# Fess data directory +#DATA_DIR=/var/lib/$NAME + +# Maximum number of VMA (Virtual Memory Areas) a process can own +MAX_MAP_COUNT=262144 + +# Path to the GC log file +#FESS_GC_LOG_FILE=/var/log/fess/gc.log + +# Fess PID file directory +PID_DIR="${packaging.fess.pid.dir}" + +# End of variables that can be overwritten in $DEFAULT + +# overwrite settings from default file +if [ -f "$DEFAULT" ]; then + . "$DEFAULT" +fi + +# Define other required variables +PID_FILE="$PID_DIR/$NAME.pid" +DAEMON=$FESS_HOME/bin/fess +DAEMON_OPTS="-d -p $PID_FILE --default.config=$CONF_FILE --default.path.home=$FESS_HOME --default.path.logs=$LOG_DIR --default.path.data=$DATA_DIR" + +export FESS_HEAP_SIZE +export FESS_HEAP_NEWSIZE +export FESS_DIRECT_SIZE +export FESS_JAVA_OPTS + +# Check DAEMON exists +test -x $DAEMON || exit 0 + +checkJava() { + if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA=`which java` + fi + + if [ ! -x "$JAVA" ]; then + echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" + exit 1 + fi +} + +case "$1" in + start) + checkJava + + if [ -n "$MAX_LOCKED_MEMORY" -a -z "$FESS_HEAP_SIZE" ]; then + log_failure_msg "MAX_LOCKED_MEMORY is set - FESS_HEAP_SIZE must also be set" + exit 1 + fi + + log_daemon_msg "Starting $DESC" + + pid=`pidofproc -p $PID_FILE fess` + if [ -n "$pid" ] ; then + log_begin_msg "Already running." + log_end_msg 0 + exit 0 + fi + + # Prepare environment + mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$FESS_USER":"$FESS_GROUP" "$LOG_DIR" "$DATA_DIR" + + # Ensure that the PID_DIR exists (it is cleaned at OS startup time) + if [ -n "$PID_DIR" ] && [ ! -e "$PID_DIR" ]; then + mkdir -p "$PID_DIR" && chown "$FESS_USER":"$FESS_GROUP" "$PID_DIR" + fi + if [ -n "$PID_FILE" ] && [ ! -e "$PID_FILE" ]; then + touch "$PID_FILE" && chown "$FESS_USER":"$FESS_GROUP" "$PID_FILE" + 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 "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then + sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT + fi + + # Start Daemon + start-stop-daemon --start -b --user "$FESS_USER" -c "$FESS_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS + return=$? + if [ $return -eq 0 ] + then + i=0 + timeout=10 + # Wait for the process to be properly started before exiting + until { cat "$PID_FILE" | xargs kill -0; } >/dev/null 2>&1 + do + sleep 1 + i=$(($i + 1)) + if [ $i -gt $timeout ]; then + log_end_msg 1 + exit 1 + fi + done + else + log_end_msg $return + fi + ;; + stop) + log_daemon_msg "Stopping $DESC" + + if [ -f "$PID_FILE" ]; then + start-stop-daemon --stop --pidfile "$PID_FILE" \ + --user "$FESS_USER" \ + --retry=TERM/20/KILL/5 >/dev/null + if [ $? -eq 1 ]; then + log_progress_msg "$DESC is not running but pid file exists, cleaning up" + elif [ $? -eq 3 ]; then + PID="`cat $PID_FILE`" + log_failure_msg "Failed to stop $DESC (pid $PID)" + exit 1 + fi + rm -f "$PID_FILE" + else + log_progress_msg "(not running)" + fi + log_end_msg 0 + ;; + status) + status_of_proc -p $PID_FILE fess fess && exit 0 || exit $? + ;; + restart|force-reload) + if [ -f "$PID_FILE" ]; then + $0 stop + sleep 1 + fi + $0 start + ;; + *) + log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/src/packaging/deb/lintian/fess b/src/packaging/deb/lintian/fess new file mode 100644 index 0000000000000000000000000000000000000000..e0047c01f3dbe2ba85030bc437c34d87fa636900 --- /dev/null +++ b/src/packaging/deb/lintian/fess @@ -0,0 +1,8 @@ +# Ignore arch dependent warnings, we chose the right libs on start +fess binary: arch-independent-package-contains-binary-or-object +# Not stripping external libraries +fess binary: unstripped-binary-or-object +# Ignore arch dependent warnings, we chose the right libs on start +fess binary: arch-dependent-file-in-usr-share +# Please check our changelog at https://github.com/codelibs/fess +fess binary: changelog-file-missing-in-native-package diff --git a/src/packaging/deb/packaging.properties b/src/packaging/deb/packaging.properties new file mode 100644 index 0000000000000000000000000000000000000000..39cd286c695117a29edfbdee532b779f2e53a28a --- /dev/null +++ b/src/packaging/deb/packaging.properties @@ -0,0 +1,12 @@ +# Properties used to build to the DEB package +# + +# Environment file +packaging.env.file=/etc/default/fess + +# Simple marker to check that properties are correctly overridden +packaging.type=deb + +# Custom header for package scripts +packaging.scripts.header=#!/bin/sh${line.separator}set -e +packaging.scripts.footer=exit 0${line.separator}# Built for ${project.name}-${project.version} (${packaging.type}) diff --git a/src/packaging/deb/scripts/conffiles b/src/packaging/deb/scripts/conffiles new file mode 100644 index 0000000000000000000000000000000000000000..3570f58a2125fec87e3d3946af7b2ce5eaa3f04c --- /dev/null +++ b/src/packaging/deb/scripts/conffiles @@ -0,0 +1,3 @@ +${packaging.env.file} +/etc/init.d/fess +/usr/lib/systemd/system/fess.service diff --git a/src/packaging/deb/scripts/control b/src/packaging/deb/scripts/control new file mode 100644 index 0000000000000000000000000000000000000000..83d3bcd314024f367b9e2f7aefef1506d97c8590 --- /dev/null +++ b/src/packaging/deb/scripts/control @@ -0,0 +1,10 @@ +Package: fess +Version: [[version]] +Architecture: all +Maintainer: Fess Team +Depends: libc6, adduser +Section: web +Priority: optional +Homepage: https://github.com/codelibs/fess +Description: Enterprise Search Server: Fess + Fess is very powerful and easily deployable Enterprise Search Server. You can install and run Fess quickly on any platforms, which have Java runtime environment. Fess is provided under Apache license. diff --git a/src/packaging/rpm/init.d/fess b/src/packaging/rpm/init.d/fess new file mode 100644 index 0000000000000000000000000000000000000000..ff1ab3d07c0e655f1ce036c0a91c785c8069b6eb --- /dev/null +++ b/src/packaging/rpm/init.d/fess @@ -0,0 +1,159 @@ +#!/bin/sh +# +# fess <summary> +# +# chkconfig: 2345 80 20 +# description: Starts and stops a single fess instance on this system +# + +### BEGIN INIT INFO +# Provides: Fess +# Required-Start: $network $named +# Required-Stop: $network $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: This service manages the fess daemon +# Description: Fess is very powerful and easily deployable Enterprise Search Server. You can install and run Fess quickly on any platforms, which have Java runtime environment. Fess is provided under Apache license. +### 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 + +# Sets the default values for fess variables used in this script +FESS_USER="${packaging.fess.user}" +FESS_GROUP="${packaging.fess.group}" +FESS_HOME="${packaging.fess.home.dir}" + +# Source the default env file +FESS_ENV_FILE="${packaging.env.file}" +if [ -f "$FESS_ENV_FILE" ]; then + . "$FESS_ENV_FILE" +fi + +exec="$FESS_HOME/bin/fess" +prog="fess" +pidfile="$PID_DIR/${prog}.pid" + +export FESS_HEAP_SIZE +export FESS_HEAP_NEWSIZE +export FESS_DIRECT_SIZE +export FESS_JAVA_OPTS +export JAVA_HOME + +lockfile=/var/lock/subsys/$prog + +# backwards compatibility for old config sysconfig files, pre 0.90.1 +if [ -n $USER ] && [ -z $FESS_USER ] ; then + FESS_USER=$USER +fi + +checkJava() { + if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA=`which java` + fi + + if [ ! -x "$JAVA" ]; then + echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" + exit 1 + fi +} + +start() { + checkJava + [ -x $exec ] || exit 5 + + # Ensure that the PID_DIR exists (it is cleaned at OS startup time) + if [ -n "$PID_DIR" ] && [ ! -e "$PID_DIR" ]; then + mkdir -p "$PID_DIR" && chown "$FESS_USER":"$FESS_GROUP" "$PID_DIR" + fi + if [ -n "$pidfile" ] && [ ! -e "$pidfile" ]; then + touch "$pidfile" && chown "$FESS_USER":"$FESS_GROUP" "$pidfile" + fi + + echo -n $"Starting $prog: " + # if not running, start it up here, usually something like "daemon $exec" + daemon --user $FESS_USER --pidfile $pidfile $exec -p $pidfile -d + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + # stop it here, often "killproc $prog" + killproc -p $pidfile -d 20 $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 $? diff --git a/src/packaging/rpm/packaging.properties b/src/packaging/rpm/packaging.properties new file mode 100644 index 0000000000000000000000000000000000000000..0679bd69a927b8eace99f5a9c34bc033a15b54af --- /dev/null +++ b/src/packaging/rpm/packaging.properties @@ -0,0 +1,14 @@ +# Properties used to build to the RPM package +# + +# Environment file +packaging.env.file=/etc/sysconfig/fess + +# Default configuration directory and file to use in bin/plugin script + +# Simple marker to check that properties are correctly overridden +packaging.type=rpm + +# Custom header for package scripts +packaging.scripts.header= +packaging.scripts.footer=# Built for ${project.name}-${project.version} (${packaging.type})