[packages/onelogin-ldap_connector] init: switch user, use makepid
glen
glen at pld-linux.org
Sat Oct 10 01:32:16 CEST 2015
commit 6169dd7ffbd7d3516a3c7175efcf373d6b2245e9
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Thu Oct 8 18:25:52 2015 +0300
init: switch user, use makepid
requires unreleased rc-scripts
ol-ldapc.init | 42 +++++++++++++++++++++++-------------------
onelogin-ldap_connector.spec | 2 +-
2 files changed, 24 insertions(+), 20 deletions(-)
---
diff --git a/onelogin-ldap_connector.spec b/onelogin-ldap_connector.spec
index bdb0c5a..5b72955 100644
--- a/onelogin-ldap_connector.spec
+++ b/onelogin-ldap_connector.spec
@@ -15,7 +15,7 @@ Source1: ol-ldapc.init
Source2: ol-ldapc.sysconfig
URL: https://www.onelogin.com/product/directory
Requires: jre
-Requires: rc-scripts >= 0.4.3.7
+Requires: rc-scripts >= 0.4.15
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
diff --git a/ol-ldapc.init b/ol-ldapc.init
index e3b1d00..dabaf62 100755
--- a/ol-ldapc.init
+++ b/ol-ldapc.init
@@ -29,27 +29,15 @@ TOKEN=""
SYNC_INTERVAL=30
OBJECT_CLASSES="posixAccount"
JAVA_OPTIONS="-XX:-UseGCOverheadLimit -Xmx64M -Xms64M"
+USER="http"
OPTIONS=""
# Get service config - may override defaults
-[ -f /etc/sysconfig/ol-ldapc ] && . /etc/sysconfig/ol-ldapc
+[ -r /etc/sysconfig/ol-ldapc ] && . /etc/sysconfig/ol-ldapc
appdir="/usr/lib/ol-ldapc"
pidfile="/var/run/ol-ldapc.pid"
-
-daemon_start() {
- java \
- -jar $appdir/ldap-connector.jar \
- --sync-interval "$SYNC_INTERVAL" \
- --object-classes "$OBJECT_CLASSES" \
- --base-dn "$BASEDN" \
- --token "$TOKEN" \
- $OPTIONS \
- > /dev/null 2>&1 &
- RETVAL=$?
- pid=$!
- echo "$pid" > $pidfile
-}
+logdir="/var/log/ol-ldapc"
start() {
# Check if the service is already running?
@@ -59,7 +47,26 @@ start() {
fi
msg_starting "OneLogin LDAP Connector"
- daemon --chdir "$appdir" setsid "$0" daemon_start
+
+ # make pid and log dir accessilbe for changed user
+ touch "$pidfile"
+ chown "$USER" "$pidfile"
+ chown "$USER" "$logdir"
+
+ # using ssd loses pid. so force rc-logging=yes, also when using ssd need to pass --fork
+ RC_LOGGING=yes
+
+ daemon \
+ --chdir "$appdir" \
+ --user "$USER" \
+ --pidfile "$pidfile" \
+ --makepid \
+ java -jar $appdir/ldap-connector.jar "$@" \
+ --sync-interval "$SYNC_INTERVAL" \
+ --object-classes "$OBJECT_CLASSES" \
+ --base-dn "$BASEDN" \
+ --token "$TOKEN" \
+ $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ol-ldapc
}
@@ -106,9 +113,6 @@ case "$1" in
force-reload)
condrestart 7
;;
- daemon_start)
- daemon_start "$@"
- ;;
status)
status --pidfile $pidfile ol-ldapc java
RETVAL=$?
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/onelogin-ldap_connector.git/commitdiff/6169dd7ffbd7d3516a3c7175efcf373d6b2245e9
More information about the pld-cvs-commit
mailing list