summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Dennis <jdennis@redhat.com>2012-02-06 13:15:06 -0500
committerEndi S. Dewata <edewata@redhat.com>2012-02-09 13:28:00 -0600
commita11d07e01bece4b7dcbd346a337e7a87769acad0 (patch)
tree4ab82dda62b706e1779ccbfadb613a049cb0e551
parent3fa38607b64e0afb579ebd552ddbb33eca671738 (diff)
downloadfreeipa.git-a11d07e01bece4b7dcbd346a337e7a87769acad0.tar.gz
freeipa.git-a11d07e01bece4b7dcbd346a337e7a87769acad0.tar.xz
freeipa.git-a11d07e01bece4b7dcbd346a337e7a87769acad0.zip
Add ipa_memcached service
* Adds ipa_memcached SystemV initscript * Adds ipa_memcached service file and tmpfiles.d/ipa.conf to recreate /var/run/ipa_memcached on reboot. * Adds ipa_memcached config file * Adds memcacheinstnace.py to manage ipa_memcaced as as SimpleService object. * Updates the IPA service list to include ipa_memcached, at service positon 39, httpd is position 40 * Updates the spec file: - requires the memcached daemon and python client - installs service or initscripts depending on OS - installs config file - creates /var/run/ipa_memcached directory * Modifies ipa-server-install to install ipa_memcached
-rw-r--r--freeipa.spec.in22
-rwxr-xr-xinit/SystemV/ipa_memcached.init120
-rw-r--r--init/ipa_memcached.conf5
-rw-r--r--init/systemd/ipa.conf.tmpfiles1
-rw-r--r--init/systemd/ipa_memcached.service12
-rwxr-xr-xinstall/tools/ipa-server-install4
-rw-r--r--ipaserver/install/memcacheinstance.py24
-rw-r--r--ipaserver/install/service.py1
8 files changed, 189 insertions, 0 deletions
diff --git a/freeipa.spec.in b/freeipa.spec.in
index ff860a87..53e589d7 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -108,6 +108,8 @@ Requires: python-ldap
Requires: python-krbV
Requires: acl
Requires: python-pyasn1 >= 0.0.9a
+Requires: memcached
+Requires: python-memcached
%if 0%{?fedora} >= 16
Requires: systemd-units >= 36-3
Requires(pre): systemd-units
@@ -353,12 +355,25 @@ mkdir -p %{buildroot}%{_usr}/share/ipa/html/
/bin/touch %{buildroot}%{_usr}/share/ipa/html/krbrealm.con
/bin/touch %{buildroot}%{_usr}/share/ipa/html/preferences.html
mkdir -p %{buildroot}%{_initrddir}
+mkdir %{buildroot}%{_sysconfdir}/sysconfig/
+install -m 644 init/ipa_memcached.conf %{buildroot}%{_sysconfdir}/sysconfig/ipa_memcached
+
+%if 0%{?fedora} >= 15
+mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d/
+install -m 0644 init/systemd/ipa.conf.tmpfiles %{buildroot}%{_sysconfdir}/tmpfiles.d/ipa.conf
+%endif
+
+mkdir -p %{buildroot}%{_localstatedir}/run/
+install -d -m 0700 %{buildroot}%{_localstatedir}/run/ipa_memcached/
+
%if 0%{?fedora} >= 16
# Default to systemd initscripts for F16 and above
mkdir -p %{buildroot}%{_unitdir}
install -m 644 init/systemd/ipa.service %{buildroot}%{_unitdir}/ipa.service
+install -m 644 init/systemd/ipa_memcached.service %{buildroot}%{_unitdir}/ipa_memcached.service
%else
install -m755 init/SystemV/ipa.init %{buildroot}%{_initrddir}/ipa
+install -m755 init/SystemV/ipa_memcached.init %{buildroot}%{_initrddir}/ipa_memcached
%endif
%endif
@@ -487,12 +502,19 @@ fi
%{_sbindir}/ipa-upgradeconfig
%{_sbindir}/ipa-compliance
%{_sysconfdir}/cron.d/ipa-compliance
+%config(noreplace) %{_sysconfdir}/sysconfig/ipa_memcached
+%dir %attr(0700,apache,apache) %{_localstatedir}/run/ipa_memcached/
+%if 0%{?fedora} >= 15
+%config %{_sysconfdir}/tmpfiles.d/ipa.conf
+%endif
%if 0%{?fedora} >= 16
# Use systemd scheme
%attr(644,root,root) %{_unitdir}/ipa.service
+%attr(644,root,root) %{_unitdir}/ipa_memcached.service
%else
# Use SystemV scheme only before F16
%attr(755,root,root) %{_initrddir}/ipa
+%attr(755,root,root) %{_initrddir}/ipa_memcached
%endif
%dir %{python_sitelib}/ipaserver
%{python_sitelib}/ipaserver/*
diff --git a/init/SystemV/ipa_memcached.init b/init/SystemV/ipa_memcached.init
new file mode 100755
index 00000000..a4673da5
--- /dev/null
+++ b/init/SystemV/ipa_memcached.init
@@ -0,0 +1,120 @@
+#! /bin/sh
+#
+# chkconfig: - 55 45
+# description: The ipa_memcached daemon is a memory cache service for IPA
+# processname: memcached
+# config: /etc/sysconfig/ipa_memcached
+# pidfile: /var/run/ipa_memcached/ipa_memcached.pid
+
+# Standard LSB functions
+#. /lib/lsb/init-functions
+
+# Source function library.
+. /etc/init.d/functions
+
+SOCKET_PATH=/var/run/ipa_memcached/ipa_memcached
+USER=apache
+PIDFILE=/var/run/ipa_memcached/ipa_memcached.pid
+MAXCONN=1024
+CACHESIZE=64
+OPTIONS=""
+
+if [ -f /etc/sysconfig/ipa_memcached ];then
+ . /etc/sysconfig/ipa_memcached
+fi
+
+# Check that networking is up.
+. /etc/sysconfig/network
+
+if [ "$NETWORKING" = "no" ]
+then
+ exit 0
+fi
+
+prog="ipa_memcached"
+pidfile=${PIDFILE-/var/run/ipa_memcached/ipa_memcached.pid}
+lockfile=${LOCKFILE-/var/lock/subsys/ipa_memcached}
+
+start () {
+ echo -n $"Starting $prog: "
+ # Ensure that $pidfile directory has proper permissions and exists
+ piddir=`dirname $pidfile`
+ if [ ! -d $piddir ]; then
+ mkdir $piddir
+ fi
+ if [ "`stat -c %U $piddir`" != "$USER" ]; then
+ chown $USER $piddir
+ fi
+
+ daemon --pidfile ${pidfile} /usr/bin/memcached -d -s ${SOCKET_PATH} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} -P ${pidfile} ${OPTIONS}
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch ${lockfile}
+ return $RETVAL
+}
+
+stop () {
+ echo -n $"Stopping $prog: "
+ killproc -p ${pidfile} $prog
+ RETVAL=$?
+ echo
+ if [ $RETVAL -eq 0 ] ; then
+ rm -f ${lockfile} ${pidfile}
+ fi
+ 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
+}
+
+# See how we were called.
+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/init/ipa_memcached.conf b/init/ipa_memcached.conf
new file mode 100644
index 00000000..19d91274
--- /dev/null
+++ b/init/ipa_memcached.conf
@@ -0,0 +1,5 @@
+SOCKET_PATH=/var/run/ipa_memcached/ipa_memcached
+USER=apache
+MAXCONN=1024
+CACHESIZE=64
+OPTIONS=
diff --git a/init/systemd/ipa.conf.tmpfiles b/init/systemd/ipa.conf.tmpfiles
new file mode 100644
index 00000000..e4b679a5
--- /dev/null
+++ b/init/systemd/ipa.conf.tmpfiles
@@ -0,0 +1 @@
+d /var/run/ipa_memcached 0700 apache apache
diff --git a/init/systemd/ipa_memcached.service b/init/systemd/ipa_memcached.service
new file mode 100644
index 00000000..a4857cd4
--- /dev/null
+++ b/init/systemd/ipa_memcached.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=IPA memcached daemon, increases IPA server performance
+After=network.target
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/ipa_memcached
+PIDFile=/var/run/ipa_memcached/ipa_memcached.pid
+ExecStart=/usr/bin/memcached -d -s $SOCKET_PATH -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/ipa_memcached/ipa_memcached.pid $OPTIONS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index b9134385..949d0219 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -48,6 +48,7 @@ from ipaserver.install import httpinstance
from ipaserver.install import ntpinstance
from ipaserver.install import certs
from ipaserver.install import cainstance
+from ipaserver.install import memcacheinstance
from ipaserver.install import service
from ipapython import version
@@ -988,6 +989,9 @@ def main():
os.write(pw_fd, options.http_pin)
os.close(pw_fd)
+ memcache = memcacheinstance.MemcacheInstance()
+ memcache.create_instance('MEMCACHE', host_name, dm_password, util.realm_to_suffix(realm_name))
+
http = httpinstance.HTTPInstance(fstore)
if options.http_pkcs12:
pkcs12_info = (options.http_pkcs12, pw_name)
diff --git a/ipaserver/install/memcacheinstance.py b/ipaserver/install/memcacheinstance.py
new file mode 100644
index 00000000..d4d28c38
--- /dev/null
+++ b/ipaserver/install/memcacheinstance.py
@@ -0,0 +1,24 @@
+# Authors: John Dennis <jdennis@redhat.com>
+#
+# Copyright (C) 2011 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import service
+
+class MemcacheInstance(service.SimpleServiceInstance):
+ def __init__(self):
+ service.SimpleServiceInstance.__init__(self, "ipa_memcached")
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 69d22554..5188b3d5 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -38,6 +38,7 @@ SERVICE_LIST = {
'KDC':('krb5kdc', 10),
'KPASSWD':('kadmin', 20),
'DNS':('named', 30),
+ 'MEMCACHE':('ipa_memcached', 39),
'HTTP':('httpd', 40),
'CA':('pki-cad', 50)
}