[hsqldb/f18] Converted from SysV to systemd + spec rearrangements

Tomas Radej tradej at fedoraproject.org
Fri Aug 24 13:32:57 UTC 2012


commit f9b1d7ce632be89e5f15655128bf9df4e638ec45
Author: Tomas Radej <tradej at redhat.com>
Date:   Tue May 22 15:33:10 2012 +0200

    Converted from SysV to systemd + spec rearrangements

 hsqldb-post    |   76 +++++++++++++++++++++++++++
 hsqldb-stop    |   84 ++++++++++++++++++++++++++++++
 hsqldb-wrapper |   97 ++++++++++++++++++++++++++++++++++
 hsqldb.spec    |  158 ++++++++++++++++++++++++++++++++++---------------------
 hsqldb.systemd |   14 +++++
 5 files changed, 369 insertions(+), 60 deletions(-)
---
diff --git a/hsqldb-post b/hsqldb-post
new file mode 100644
index 0000000..8ddb1b9
--- /dev/null
+++ b/hsqldb-post
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+# This file was created with portions of the original SysV init script shipped 
+# with hsqldb
+
+# Copyright (c) 2001-2004, The HSQL Development Group
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# Neither the name of the HSQL Development Group nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
+# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+# $MAX_START_SECS from when the Server/WebServer is started.
+MAX_START_SECS=60
+
+# Class in the org.hsqldb package to start.
+# At this time, only the values "Server" or "WebServer" will work.
+TARGET_CLASS=Server
+
+. /etc/sysconfig/hsqldb
+
+# PROPERTY_FILE is a derived value.
+case "$TARGET_CLASS" in
+    Server) PROPERTY_FILE="$SERVER_HOME"/server.properties;;
+    WebServer) PROPERTY_FILE="$SERVER_HOME"/webserver.properties;;
+    *)
+        echo 'Unsupported value for $TARGET_CLASS:  '"$TARGET_CLASS" 1>&2
+        exit 2;;
+esac
+[ -f "$PROPERTY_FILE" ] || {
+    echo "'$PROPERTY_FILE' is missing" 1>&2
+    exit 2
+}
+[ -r "$PROPERTY_FILE" ] || {
+    echo "'$PROPERTY_FILE' isn't readable" 1>&2
+    exit 2
+}
+
+AUTH_FILE_SWITCH=
+# N.b., there will be a problem if there are special characters or
+# spaces inside of $AUTH_FILE.
+[ -n "$AUTH_FILE" ] && AUTH_FILE_SWITCH="-Dsqltoolsprayer.rcfile=$AUTH_FILE"
+
+# Might as well set CLASSPATH for a cleaner command.
+CLASSPATH="$HSQLDB_JAR_PATH"
+export CLASSPATH
+
+sleep 1
+
+"$JAVA_EXECUTABLE" $AUTH_FILE_SWITCH $CLIENT_JVMARGS \
+    "-Dsqltoolsprayer.propfile=$PROPERTY_FILE" \
+    "-Dsqltoolsprayer.maxtime=${MAX_START_SECS}000" \
+    org.hsqldb.util.SqlToolSprayer '--;'
diff --git a/hsqldb-stop b/hsqldb-stop
new file mode 100644
index 0000000..5d5bf71
--- /dev/null
+++ b/hsqldb-stop
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+# This file was created with portions of the original SysV init script shipped 
+# with hsqldb
+
+# Copyright (c) 2001-2004, The HSQL Development Group
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# Neither the name of the HSQL Development Group nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
+# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Class in the org.hsqldb package to start.
+# At this time, only the values "Server" or "WebServer" will work.
+TARGET_CLASS=Server
+MAX_TERMINATE_SECS=1
+
+# To customize settings, edit this file:
+. /etc/sysconfig/hsqldb
+
+# PROPERTY_FILE is a derived value.
+case "$TARGET_CLASS" in
+    Server) PROPERTY_FILE="$SERVER_HOME"/server.properties;;
+    WebServer) PROPERTY_FILE="$SERVER_HOME"/webserver.properties;;
+    *)
+        echo 'Unsupported value for $TARGET_CLASS:  '"$TARGET_CLASS" 1>&2
+        exit 6;;
+esac
+[ -f "$PROPERTY_FILE" ] || {
+    echo "'$PROPERTY_FILE' is missing" 1>&2
+    exit 6
+}
+[ -r "$PROPERTY_FILE" ] || {
+    echo "'$PROPERTY_FILE' isn't readable" 1>&2
+    exit 6
+}
+[ -r "$HSQLDB_JAR_PATH" ] || {
+    echo "'$HSQLDB_JAR_PATH' isn't readable" 1>&2
+    exit 6
+}
+[ -x "$JAVA_EXECUTABLE" ] || {
+    echo "No Java executable found at '$JAVA_EXECUTABLE'" 1>&2
+    exit 6
+}
+
+AUTH_FILE_SWITCH=
+# N.b., there will be a problem if there are special characters or
+# spaces inside of $AUTH_FILE.
+[ -n "$AUTH_FILE" ] &&
+AUTH_FILE_SWITCH="-Dsqltoolsprayer.rcfile=$AUTH_FILE"
+# Might as well set CLASSPATH for a cleaner command.
+CLASSPATH="$HSQLDB_JAR_PATH"
+export CLASSPATH
+export PATH   # Required only for some funny init environments.
+"$JAVA_EXECUTABLE" $AUTH_FILE_SWITCH $CLIENT_JVMARGS \
+    "-Dsqltoolsprayer.propfile=$PROPERTY_FILE" \
+    org.hsqldb.util.SqlToolSprayer "shutdown ;" \
+    $SHUTDOWN_URLIDS
+sleep $MAX_TERMINATE_SECS  # Give the JVM a sec. or 2 to fully exit.
+echo "Successful shutdown ${SHUTDOWN_OPTION} (for the $TARGET_CLASS process)!"
+exit 0
+
diff --git a/hsqldb-wrapper b/hsqldb-wrapper
new file mode 100644
index 0000000..e28c255
--- /dev/null
+++ b/hsqldb-wrapper
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+# This file was created with portions of the original SysV init script shipped 
+# with hsqldb
+
+# Copyright (c) 2001-2004, The HSQL Development Group
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# Neither the name of the HSQL Development Group nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
+# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+# Class in the org.hsqldb package to start.
+# At this time, only the values "Server" or "WebServer" will work.
+TARGET_CLASS=Server
+
+. /etc/sysconfig/hsqldb
+
+# Suffix delimiter to $SERVER_ADDL_CLASSPATH, if it is set.
+[ -n "$SERVER_ADDL_CLASSPATH" ] &&
+SERVER_ADDL_CLASSPATH="${SERVER_ADDL_CLASSPATH}:"
+# Validate that config file sets all required variables.
+[ -n "$JAVA_EXECUTABLE" ] && [ -n "$HSQLDB_JAR_PATH" ] &&
+[ -n "$SERVER_HOME" ] || {
+    echo "Config file '$CFGFILE' does not set one or more of following variables
+    JAVA_EXECUTABLE, HSQLDB_JAR_PATH, SERVER_HOME" 1>&2
+    exit 2
+}
+[ -d "$SERVER_HOME" ] || {
+    echo "SERVER_HOME variable in '$CFGFILE' is set to a non-directory." 1>&2
+    exit 2
+}
+[ -f "$JAVA_EXECUTABLE" ] && [ -f "$HSQLDB_JAR_PATH" ] || {
+    echo "JAVA_EXECUTABLE or HSQLDB_JAR_PATH in '$CFGFILE' is set to a non-file." 1>&2
+    exit 2
+}
+[ -r "$HSQLDB_JAR_PATH" ] || {
+    echo "'$HSQLDB_JAR_PATH' isn't readable" 1>&2
+    exit 2
+}
+[ -x "$JAVA_EXECUTABLE" ] || {
+    echo "No Java executable found at '$JAVA_EXECUTABLE'" 1>&2
+    exit 2
+}
+
+# Make a good effort (but not bullet-proof) check on permissions of the
+# auth file.  Unfortunately, if auth-file is not specified, this depends
+# upon both (a) $HOME being set; and (b) SqlToolSprayer and SqlTool defaults.
+# On the other hand, it works great if AUTH_FILE is set explicitly by user.
+if [ -z "$AUTH_FILE" ] && [ -z "$HOME" ]; then
+    : # Lousy init environment didn't set $HOME, so can't find dflt cfg file.
+else
+    _AUTH_TEST_PATH="$AUTH_FILE"
+    [ -n "${_AUTH_TEST_PATH}" ] || _AUTH_TEST_PATH="$HOME/sqltool.rc"
+    [ -f "$_AUTH_TEST_PATH" ] || {
+        echo "No auth file found at '$_AUTH_TEST_PATH'" 1>&2
+        exit 2
+    }
+    [ -r "$_AUTH_TEST_PATH" ] || {
+        echo "Auth file '$_AUTH_TEST_PATH' not readable" 1>&2
+        exit 2
+    }
+    ls -ld "$_AUTH_TEST_PATH" | grep '^-..------' > /dev/null 2>&1 || {
+        echo "Fix permissions on '$_AUTH_TEST_PATH' like 'chmod 600 $_AUTH_TEST_PATH'" 1>&2
+        exit 2
+    }
+fi
+
+TLS_SWITCHES=
+[ -n "$TLS_KEYSTORE" ] &&
+TLS_SWITCHES="-Djavax.net.ssl.keyStore=$TLS_KEYSTORE -Djavax.net.ssl.keyStorePassword=$TLS_PASSWORD"
+
+cd "$SERVER_HOME" &&
+exec "$JAVA_EXECUTABLE" $SERVER_JVMARGS $TLS_SWITCHES -classpath "${SERVER_ADDL_CLASSPATH}${HSQLDB_JAR_PATH}" org.hsqldb.util.MainInvoker org.hsqldb.$TARGET_CLASS $INVOC_ADDL_ARGS
diff --git a/hsqldb.spec b/hsqldb.spec
index 892f0e8..f182b78 100644
--- a/hsqldb.spec
+++ b/hsqldb.spec
@@ -30,35 +30,50 @@
 
 %global cvs_version 1_8_1_3
 
-Name:       hsqldb
-Version:    1.8.1.3
-Release:    8%{?dist}
-Epoch:      1
-Summary:    HyperSQL Database Engine
-License:    BSD
-URL:        http://hsqldb.sourceforge.net/
-Source0:    http://downloads.sourceforge.net/hsqldb/%{name}_%{cvs_version}.zip
-Source1:    %{name}-1.8.0-standard.cfg
-Source2:    %{name}-1.8.0-standard-server.properties
-Source3:    %{name}-1.8.0-standard-webserver.properties
-Source4:    %{name}-1.8.0-standard-sqltool.rc
-Source5:    http://mirrors.ibiblio.org/pub/mirrors/maven2/%{name}/%{name}/1.8.0.10/%{name}-1.8.0.10.pom
-Patch0:     %{name}-1.8.0-scripts.patch
-Patch1:     hsqldb-tmp.patch
-Patch2:     %{name}-1.8.0-specify-su-shell.patch
-Patch3:     %{name}-jdbc-4.1.patch
-Requires:   tomcat-servlet-3.0-api
-Requires:   java
-Requires(post):   coreutils
-Requires(preun):  coreutils
-Requires(preun): initscripts
-Requires(pre):  shadow-utils
+Name:           hsqldb
+Version:        1.8.1.3
+Release:        9%{?dist}
+Epoch:          1
+Summary:        HyperSQL Database Engine
+License:        BSD
+URL:            http://hsqldb.sourceforge.net/
+Group:          Applications/Databases
+
+BuildArch:      noarch
+
+Source0:        http://downloads.sourceforge.net/hsqldb/%{name}_%{cvs_version}.zip
+Source1:        %{name}-1.8.0-standard.cfg
+Source2:        %{name}-1.8.0-standard-server.properties
+Source3:        %{name}-1.8.0-standard-webserver.properties
+Source4:        %{name}-1.8.0-standard-sqltool.rc
+Source5:        http://mirrors.ibiblio.org/pub/mirrors/maven2/%{name}/%{name}/1.8.0.10/%{name}-1.8.0.10.pom
+# Custom systemd files - talking with upstream about incorporating them, see
+# http://sourceforge.net/projects/hsqldb/forums/forum/73673/topic/5367103
+Source6:        %{name}.systemd
+Source7:        %{name}-wrapper
+Source8:        %{name}-post
+Source9:        %{name}-stop
+
+Patch0:         %{name}-1.8.0-scripts.patch
+Patch1:         hsqldb-tmp.patch
+Patch2:         %{name}-1.8.0-specify-su-shell.patch
+Patch3:         %{name}-jdbc-4.1.patch
+
 BuildRequires:  ant
-BuildRequires:  junit
 BuildRequires:  jpackage-utils >= 0:1.5
+BuildRequires:  junit
+BuildRequires:  systemd-units
 BuildRequires:  tomcat-servlet-3.0-api
-Group:      Applications/Databases
-BuildArch:  noarch
+
+Requires:       java
+Requires:       tomcat-servlet-3.0-api
+Requires(pre):  shadow-utils
+Requires(post): systemd-sysv
+Requires(post): systemd-units
+Requires(preun):  initscripts
+Requires(preun):  systemd-units
+Requires(postun): systemd-units
+
 
 %description
 HSQLdb is a relational database engine written in JavaTM , with a JDBC
@@ -133,45 +148,49 @@ popd
 
 %install
 # jar
-install -d -m 755 $RPM_BUILD_ROOT%{_javadir}
-install -m 644 lib/%{name}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}.jar
+install -d -m 755 %{buildroot}%{_javadir}
+install -m 644 lib/%{name}.jar %{buildroot}%{_javadir}/%{name}.jar
 # bin
-install -d -m 755 $RPM_BUILD_ROOT%{_bindir}
-install -m 755 bin/runUtil.sh $RPM_BUILD_ROOT%{_bindir}/%{name}RunUtil
-# sysv init
-install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
-install -m 755 bin/%{name} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name}
+install -d -m 755 %{buildroot}%{_bindir}
+install -m 755 bin/runUtil.sh %{buildroot}%{_bindir}/%{name}RunUtil
+# systemd
+install -d -m 755 %{buildroot}%{_unitdir}
+install -d -m 755 %{buildroot}%{_prefix}/lib/%{name}
+install -m 755 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}.service
+install -m 755 %{SOURCE7} %{buildroot}%{_prefix}/lib/%{name}/%{name}-wrapper
+install -m 755 %{SOURCE8} %{buildroot}%{_prefix}/lib/%{name}/%{name}-post
+install -m 755 %{SOURCE9} %{buildroot}%{_prefix}/lib/%{name}/%{name}-stop
 # config
-install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
-install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
+install -d -m 755 %{buildroot}%{_sysconfdir}/sysconfig
+install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
 # serverconfig
-install -d -m 755 $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}
-install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/server.properties
-install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/webserver.properties
-install -m 600 %{SOURCE4} $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/sqltool.rc
+install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}
+install -m 644 %{SOURCE2} %{buildroot}%{_localstatedir}/lib/%{name}/server.properties
+install -m 644 %{SOURCE3} %{buildroot}%{_localstatedir}/lib/%{name}/webserver.properties
+install -m 600 %{SOURCE4} %{buildroot}%{_localstatedir}/lib/%{name}/sqltool.rc
 # lib
-install -d -m 755 $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/lib
-install -m 644 lib/functions $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/lib
+install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}/lib
+install -m 644 lib/functions %{buildroot}%{_localstatedir}/lib/%{name}/lib
 # data
-install -d -m 755 $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/data
+install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}/data
 # demo
-install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/demo
-install -m 755 demo/*.sh $RPM_BUILD_ROOT%{_datadir}/%{name}/demo
-install -m 644 demo/*.html $RPM_BUILD_ROOT%{_datadir}/%{name}/demo
+install -d -m 755 %{buildroot}%{_datadir}/%{name}/demo
+install -m 755 demo/*.sh %{buildroot}%{_datadir}/%{name}/demo
+install -m 644 demo/*.html %{buildroot}%{_datadir}/%{name}/demo
 # javadoc
-install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}
-cp -r doc/src/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}
+install -d -m 755 %{buildroot}%{_javadocdir}/%{name}
+cp -r doc/src/* %{buildroot}%{_javadocdir}/%{name}
 rm -rf doc/src
 # manual
-install -d -m 755 $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
-cp -r doc/* $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
-cp index.html $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
+install -d -m 755 %{buildroot}%{_docdir}/%{name}-%{version}
+cp -r doc/* %{buildroot}%{_docdir}/%{name}-%{version}
+cp index.html %{buildroot}%{_docdir}/%{name}-%{version}
 
 # Maven metadata
-install -pD -T -m 644 pom.xml $RPM_BUILD_ROOT%{_mavenpomdir}/JPP-%{name}.pom
-%add_to_maven_depmap %{name} %{name} %{version} JPP %{name}
+install -pD -T -m 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
+%add_maven_depmap
 
-pushd $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/lib
+pushd %{buildroot}%{_localstatedir}/lib/%{name}/lib
     # build-classpath can not be used as the jar is not
     # yet present during the build
     ln -s %{_javadir}/hsqldb.jar hsqldb.jar
@@ -179,10 +198,7 @@ pushd $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/lib
 popd
 
 %preun
-if [ $1 = 0 ] ; then
-    /sbin/service %{name} stop >/dev/null 2>&1
-    /sbin/chkconfig --del %{name}
-fi
+%systemd_preun hsqldb.service
 
 %pre
 # Add the "hsqldb" user and group
@@ -192,16 +208,34 @@ fi
     -d %{_localstatedir}/lib/%{name} -r %{name} 2> /dev/null || :
 
 %post
-# This adds the proper /etc/rc*.d links for the script
-/sbin/chkconfig --add %{name}
+%systemd_post hsqldb.service
+
+%postun
+%systemd_postun_with_restart hsqldb.service
+
+%triggerun -- hsqldb < 1.8.1.3-9
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply httpd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save hsqldb >/dev/null 2>&1 ||:
+
+# If the package is allowed to autostart:
+/bin/systemctl --no-reload enable hsqldb.service >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del hsqldb >/dev/null 2>&1 || :
+/bin/systemctl try-restart hsqldb.service >/dev/null 2>&1 || :
 
 %files
 %defattr(-,root,root,-)
 %doc doc/hsqldb_lic.txt
 %{_javadir}/*
 %attr(0755,root,root) %{_bindir}/*
-%attr(0755,root,root) %{_sysconfdir}/rc.d/init.d/%{name}
 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
+%{_unitdir}/%{name}.service
+%{_prefix}/lib/%{name}/%{name}-wrapper
+%{_prefix}/lib/%{name}/%{name}-post
+%{_prefix}/lib/%{name}/%{name}-stop
 %attr(0700,hsqldb,hsqldb) %{_localstatedir}/lib/%{name}/data
 %{_localstatedir}/lib/%{name}/lib
 %{_localstatedir}/lib/%{name}/server.properties
@@ -223,6 +257,10 @@ fi
 %{_datadir}/%{name}
 
 %changelog
+* Fri Aug 24 2012 Tomas Radej <tradej at redhat.com> - 1:1.8.1.3-9
+- Switched from SysV to systemd
+- Spec rearrangements
+
 * Thu Jul 19 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1:1.8.1.3-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
 
diff --git a/hsqldb.systemd b/hsqldb.systemd
new file mode 100644
index 0000000..00c866f
--- /dev/null
+++ b/hsqldb.systemd
@@ -0,0 +1,14 @@
+[Unit]
+Description=HyperSQL Database Engine
+
+
+[Service]
+Type=simple
+User=hsqldb
+Group=hsqldb
+ExecStart=/usr/lib/hsqldb/hsqldb-wrapper
+ExecStartPost=/usr/lib/hsqldb/hsqldb-post
+ExecStop=/usr/lib/hsqldb/hsqldb-stop
+
+[Install]
+WantedBy=multi-user.target


More information about the scm-commits mailing list