Accepted submit request 58451 from user mvyskocil OBS-URL: https://build.opensuse.org/request/show/58451 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/hsqldb?expand=0&rev=6
524 lines
16 KiB
Diff
524 lines
16 KiB
Diff
Index: bin/hsqldb
|
|
===================================================================
|
|
--- bin/hsqldb.orig 2011-01-14 13:55:34.636488672 +0100
|
|
+++ bin/hsqldb 2011-01-14 14:05:37.464628070 +0100
|
|
@@ -50,7 +50,7 @@
|
|
### BEGIN INIT INFO
|
|
# Provides: HSQLDB-Server
|
|
# Required-Start: $syslog $remote_fs $network $named
|
|
-# Required-Stop:
|
|
+# Required-Stop: $syslog $remote_fs $network $named
|
|
# Default-Start: 3 5
|
|
# Default-Stop: 0 1 2 6
|
|
# Short-Description: HSQLDB-Server
|
|
@@ -89,19 +89,73 @@
|
|
|
|
# -- blaine.simpson@admc.com
|
|
|
|
+# Shell functions sourced from /etc/rc.status:
|
|
+# rc_check check and set local and overall rc status
|
|
+# rc_status check and set local and overall rc status
|
|
+# rc_status -v ditto but be verbose in local rc status
|
|
+# rc_status -v -r ditto and clear the local rc status
|
|
+# rc_failed set local and overall rc status to failed
|
|
+# rc_failed <num> set local and overall rc status to <num><num>
|
|
+# rc_reset clear local rc status (overall remains)
|
|
+# rc_exit exit appropriate to overall rc status
|
|
+. /etc/rc.status
|
|
+
|
|
+# First reset status of this service
|
|
+rc_reset
|
|
+
|
|
+# Return values acc. to LSB for all commands but status:
|
|
+# 0 - success
|
|
+# 1 - generic or unspecified error
|
|
+# 2 - invalid or excess argument(s)
|
|
+# 3 - unimplemented feature (e.g. "reload")
|
|
+# 4 - insufficient privilege
|
|
+# 5 - program is not installed
|
|
+# 6 - program is not configured
|
|
+# 7 - program is not running
|
|
+#
|
|
+# Note that starting an already running service, stopping
|
|
+# or restarting a not-running service as well as the restart
|
|
+# with force-reload (in case signalling is not supported) are
|
|
+# considered a success.
|
|
+
|
|
set +u
|
|
|
|
+# "chown" lives in /usr on some UNIXes.
|
|
+PATH="/bin:/sbin:/usr/sbin"
|
|
+
|
|
+
|
|
+NAME="$(/bin/basename $0)"
|
|
+unset ISBOOT
|
|
+if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then
|
|
+ NAME="${NAME:3}"
|
|
+ ISBOOT="1"
|
|
+fi
|
|
+
|
|
+# remove SUSE's rc name
|
|
+if [ "${NAME:0:2}" = "rc" ]; then
|
|
+ NAME="${NAME:2}"
|
|
+fi
|
|
+
|
|
+# For SELinux we need to use 'runuser' not 'su'
|
|
+if [ -x "/sbin/runuser" ]; then
|
|
+ SU="/sbin/runuser"
|
|
+else
|
|
+ SU="/bin/su"
|
|
+fi
|
|
+
|
|
# This is only used for recursive invocations.
|
|
# Will not necessarily be set correctly at system bootup invocations
|
|
# (where it is sometimes invoked like "sh... /path/to/hsqldb start"),
|
|
# but, in those cases there will be no recursion.
|
|
-INVOC_PATH=`dirname "$0"` || {
|
|
+INVOC_PATH=`/usr/bin/dirname "$0"` || {
|
|
echo "'dirname' failed" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -n "$INVOC_PATH" ] && INVOC_PATH="${INVOC_PATH}/"
|
|
|
|
-SYNTAX_MSG="SYNTAX: ${INVOC_PATH}hsqldb start|stop|stopcompact|restart|restartcmpacted|status"
|
|
+SYNTAX_MSG="Usage: ${INVOC_PATH}/${NAME} start|stop|status|try-restart|restart|force-reload|reload|probe"
|
|
|
|
# You can override any of these default values in your config file:
|
|
|
|
@@ -110,9 +164,12 @@
|
|
SU_ECHO_SECS=1
|
|
# File used as semaphore. If file is removed, a running pid checker
|
|
# process will exit.
|
|
-PIDCHECKER_FLAGFILE=`mktemp /tmp/hsqldb.XXXXXXXX`
|
|
+PIDCHECKER_FLAGFILE=`/bin/mktemp /tmp/hsqldb.XXXXXXXX`
|
|
if [ x"$PIDCHECKER_FLAGFILE" = "x" ] ; then
|
|
- echo "unable to create tmp file"; exit 1
|
|
+ echo "unable to create tmp file"
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
fi
|
|
# The following settings get overridden by optional setting in the config file.
|
|
# Time to allow for JVM to die after all HSQLDB instances stopped.
|
|
@@ -168,25 +225,31 @@
|
|
done
|
|
[ -n "$CFGFILE" ] || {
|
|
echo "No global config file found in any of allowed locations" 1>&2
|
|
- exit 11
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
|
|
# Sanity check
|
|
[ -n "$LOGFILE" ] && [ -n "$PIDFILE" ] || {
|
|
echo "Internal problem in init script" 1>&2
|
|
- exit 11
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
|
|
[ $# -eq 1 ] || {
|
|
echo "$SYNTAX_MSG" 1>&2
|
|
- exit 4
|
|
+ exit 1
|
|
}
|
|
|
|
# It would be nice to permit some uses, like "status" by non-root users,
|
|
# but for now our goal is a superuser init script.
|
|
[ -w / ] || { # Very portable, but perhaps not perfect, test for superuser.
|
|
echo "Only 'root' may use this init script" 1>&2
|
|
- exit 4
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
|
|
# Use bsd-style enable/disable if it's in place.
|
|
@@ -209,11 +272,15 @@
|
|
|
|
[ -r "$CFGFILE" ] || {
|
|
echo "Unable to read config file '$CFGFILE'" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -f "$CFGFILE" ] || {
|
|
echo "'$CFGFILE' is not a regular file" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
HSQLDB_OWNER=
|
|
JAVA_EXECUTABLE=
|
|
@@ -221,6 +288,28 @@
|
|
SERVER_HOME=
|
|
SHUTDOWN_URLIDS=
|
|
. "$CFGFILE"
|
|
+
|
|
+[ -z "$JAVA_EXECUTABLE" ] && {
|
|
+ # JPackage source Java config
|
|
+ . /etc/java/java.conf
|
|
+
|
|
+ if [ -n "$JAVA_HOME" ]; then
|
|
+ JAVA_EXECUTABLE=${JAVA_HOME}/bin/java
|
|
+ else
|
|
+ JAVA_EXECUTABLE=${JVM_ROOT}/java/bin/java
|
|
+ fi
|
|
+
|
|
+ if [ -z "$JAVA_HOME" ]; then
|
|
+ if [ -d "$JVM_ROOT/java" ]; then
|
|
+ JAVA_EXECUTABLE=$JVM_ROOT/java/bin/java
|
|
+ else
|
|
+ JAVA_EXECUTABLE=$JVM_ROOT/jre/bin/java
|
|
+ fi
|
|
+ else
|
|
+ JAVA_EXECUTABLE=$JAVA_HOME/bin/java
|
|
+ fi
|
|
+}
|
|
+
|
|
# Suffix delimiter to $SERVER_ADDL_CLASSPATH, if it is set.
|
|
[ -n "$SERVER_ADDL_CLASSPATH" ] &&
|
|
SERVER_ADDL_CLASSPATH="${SERVER_ADDL_CLASSPATH}:"
|
|
@@ -229,15 +318,21 @@
|
|
[ -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
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -d "$SERVER_HOME" ] || {
|
|
echo "SERVER_HOME variable in '$CFGFILE' is set to a non-directory." 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -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
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
|
|
# PROPERTY_FILE is a derived value.
|
|
@@ -246,28 +341,36 @@
|
|
WebServer) PROPERTY_FILE="$SERVER_HOME"/webserver.properties;;
|
|
*)
|
|
echo 'Unsupported value for $TARGET_CLASS: '"$TARGET_CLASS" 1>&2
|
|
- exit 2;;
|
|
+ rc_failed 2
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
+ ;;
|
|
esac
|
|
[ -f "$PROPERTY_FILE" ] || {
|
|
echo "'$PROPERTY_FILE' is missing" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -r "$PROPERTY_FILE" ] || {
|
|
echo "'$PROPERTY_FILE' isn't readable" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -r "$HSQLDB_JAR_PATH" ] || {
|
|
echo "'$HSQLDB_JAR_PATH' isn't readable" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -x "$JAVA_EXECUTABLE" ] || {
|
|
echo "No Java executable found at '$JAVA_EXECUTABLE'" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
|
|
-# "chown" lives here on some UNIXes.
|
|
-PATH="$PATH:/usr/sbin"
|
|
-
|
|
# 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.
|
|
@@ -279,15 +382,21 @@
|
|
[ -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
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -r "$_AUTH_TEST_PATH" ] || {
|
|
echo "Auth file '$_AUTH_TEST_PATH' not readable" 1>&2
|
|
- exit 2
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
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
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
fi
|
|
|
|
@@ -296,29 +405,37 @@
|
|
[ -r "$PIDFILE" ] && {
|
|
[ -f "$PIDFILE" ] || {
|
|
echo "'$PIDFILE' is not a regular file" 1>&2
|
|
- exit 6
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
[ -w "$PIDFILE" ] || {
|
|
echo "'$PIDFILE' is not writable" 1>&2
|
|
- exit 6
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
HSQLDB_PID="`cat $PIDFILE`" || {
|
|
echo "Failed to read pid file '$PIDFILE'" 1>&2
|
|
- exit 6
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
case "$HSQLDB_PID" in
|
|
*[a-zA-Z/!@#$%*+=_~]*) HSQLDB_PID=;;
|
|
*'^'*) HSQLDB_PID=;;
|
|
esac
|
|
[ -n "$HSQLDB_PID" ] || {
|
|
- echo "Pid file '$PIDFILE' does not contain a valid process identifier" 1>&2
|
|
- exit 6
|
|
+ rc_failed 7
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
kill -0 "$HSQLDB_PID" > /dev/null 2>&1 || {
|
|
echo 'Removing stale pid file'
|
|
rm -f "$PIDFILE" || {
|
|
- echo "Failed to remove pid file '$PIDFILE'" 1>&2
|
|
- exit 6
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
HSQLDB_PID=
|
|
}
|
|
@@ -329,7 +446,9 @@
|
|
status)
|
|
[ -n "$HSQLDB_PID" ] || {
|
|
echo "I don't know of any running hsqldb server."
|
|
- exit 0
|
|
+ rc_failed 7
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
echo "There is an hsqldb server loaded from $HSQLDB_JAR_PATH
|
|
running with pid $HSQLDB_PID."
|
|
@@ -348,32 +467,42 @@
|
|
"-Dsqltoolsprayer.propfile=$PROPERTY_FILE" \
|
|
"-Dsqltoolsprayer.monfile=$PIDFILE" \
|
|
org.hsqldb.util.SqlToolSprayer '--;'
|
|
+ rc_failed 0
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
;;
|
|
start)
|
|
[ -n "$HSQLDB_PID" ] && {
|
|
echo "There is already a hsqldb server running with pid $HSQLDB_PID." 1>&2
|
|
- exit 1
|
|
+ rc_failed 0
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
TLS_SWITCHES=
|
|
[ -n "$TLS_KEYSTORE" ] &&
|
|
TLS_SWITCHES="-Djavax.net.ssl.keyStore=$TLS_KEYSTORE -Djavax.net.ssl.keyStorePassword=$TLS_PASSWORD"
|
|
if [ -n "$HSQLDB_OWNER" ]; then
|
|
touch "$PIDFILE" || {
|
|
- echo "Failed to create pid file" 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
chown "$HSQLDB_OWNER" "$PIDFILE" || {
|
|
echo "Failed to chown pid file to '$HSQLDB_OWNER'" 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
# Some OSes choke if there are newlines in this string.
|
|
# N.b.!!! The shell of the -c command is the target user's default
|
|
# login shell, so keep this command shell-independent!
|
|
- nohup su "$HSQLDB_OWNER" -c "cd '$SERVER_HOME' && echo "'$$'" > '$PIDFILE' && 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" >> "$LOGFILE" 2>&1 &
|
|
+ /usr/bin/nohup $SU "$HSQLDB_OWNER" -c "cd '$SERVER_HOME' && echo "'$$'" > '$PIDFILE' && 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" >> "$LOGFILE" 2>&1 &
|
|
else
|
|
cd "$SERVER_HOME" || {
|
|
echo "Failed to cd to '$SERVER_HOME'" 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
export JAVA_EXECUTABLE
|
|
export HSQLDB_JAR_PATH
|
|
@@ -382,10 +511,12 @@
|
|
export SERVER_JVMARGS
|
|
export TARGET_CLASS
|
|
export INVOC_ADDL_ARGS
|
|
- nohup sh -c '
|
|
+ /usr/bin/nohup sh -c '
|
|
echo $$ > "$PIDFILE" || {
|
|
echo "Failed to write pid to pid file" 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
eval 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
|
|
' >> "$LOGFILE" 2>&1 &
|
|
@@ -404,7 +535,9 @@
|
|
# but regardless of why, the pid file does not contain a valid pid.
|
|
touch "$PIDCHECKER_FLAGFILE" || {
|
|
echo "Failed to touch file '$PIDCHECKER_FLAGFILE'" 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
export PIDCHECKER_FLAGFILE
|
|
export PIDFILE
|
|
@@ -414,7 +547,9 @@
|
|
[ -f "$PIDCHECKER_FLAGFILE" ] || exit 0
|
|
kill -0 "`cat $PIDFILE`" > /dev/null 2>&1 || {
|
|
rm -f "$PIDFILE" "$PIDCHECKER_FLAGFILE"
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
sleep 1
|
|
done
|
|
@@ -426,18 +561,24 @@
|
|
org.hsqldb.util.SqlToolSprayer '--;' && {
|
|
rm -f "$PIDCHECKER_FLAGFILE"
|
|
echo "org.hsqldb.$TARGET_CLASS started with pid `cat $PIDFILE`"
|
|
- exit 0
|
|
+ rc_failed 0
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
rm -f "$PIDCHECKER_FLAGFILE"
|
|
echo "Failed to start org.hsqldb.$TARGET_CLASS.
|
|
See log file '$LOGFILE'." 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
;;
|
|
stop|stopcompact)
|
|
[ "$COMMAND" = stopcompact ] && SHUTDOWN_OPTION='compact'
|
|
[ -n "$HSQLDB_PID" ] || {
|
|
echo "I don't know of any running hsqldb server." 1>&2
|
|
- exit 1
|
|
+ rc_failed 7
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
AUTH_FILE_SWITCH=
|
|
# N.b., there will be a problem if there are special characters or
|
|
@@ -455,23 +596,64 @@
|
|
sleep $MAX_TERMINATE_SECS # Give the JVM a sec. or 2 to fully exit.
|
|
kill -0 "$HSQLDB_PID" > /dev/null 2>&1 && {
|
|
echo "WARNING: hsqldb is still running!" 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
rm -f "$PIDFILE" || {
|
|
echo "Failed to remove pid file '$PIDFILE'" 1>&2
|
|
- exit 1
|
|
+ rc_failed 1
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
}
|
|
echo "Successful shutdown ${SHUTDOWN_OPTION} (for the $TARGET_CLASS process)!"
|
|
- exit 0
|
|
+ rc_failed 0
|
|
+ rc_status -v
|
|
+ rc_exit
|
|
;;
|
|
restart|restartcompacted)
|
|
STOP_COMMAND=stop
|
|
[ "$COMMAND" = restartcompacted ] && STOP_COMMAND=stopcompact
|
|
- "${INVOC_PATH}"hsqldb $STOP_COMMAND || exit $?
|
|
+ "${INVOC_PATH}"hsqldb $STOP_COMMAND || {
|
|
+ rc_failed $?
|
|
+ rc_status -s
|
|
+ rc_exit
|
|
+ }
|
|
exec "${INVOC_PATH}"/hsqldb start
|
|
+ rc_failed $?
|
|
+ rc_status -s
|
|
+ rc_exit
|
|
;;
|
|
+ try-restart)
|
|
+ ## Stop the service and if this succeeds (i.e. the
|
|
+ ## service was running before), start it again.
|
|
+ ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
|
|
+ $0 status >/dev/null && $0 restart
|
|
+
|
|
+ # Remember status and be quiet
|
|
+ rc_status
|
|
+ ;;
|
|
+ force-reload)
|
|
+ ## Signal the daemon to reload its config. Most daemons
|
|
+ ## do this on signal 1 (SIGHUP).
|
|
+ ## If it does not support it, restart.
|
|
+
|
|
+ echo -n "Reload service hsqldb"
|
|
+ ## if it supports it:
|
|
+ #killproc -HUP $TOMCAT_BIN
|
|
+ #touch /var/run/FOO.pid
|
|
+ #rc_status -v
|
|
+
|
|
+ ## Otherwise:
|
|
+ $0 stop && $0 start
|
|
+ rc_status
|
|
+ ;;
|
|
+ reload|probe)
|
|
+ rc_failed 3
|
|
+ rc_status -v
|
|
+ ;;
|
|
*)
|
|
echo "$SYNTAX_MSG" 1>&2
|
|
- exit 5
|
|
+ exit 1
|
|
;;
|
|
esac
|