This patch supersedes the previous patch, it corrects two issue Rob raised in a later patch review

The fixed issues are:

* spec file did not install ipa_memcached SysV initscript on SvsV systems.

* Typo in the name of the pid file variable in the ipa_memcached initscript

--
John Dennis <jden...@redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
>From d70c159046c86ea40dc704dd27607e7c59d431cf Mon Sep 17 00:00:00 2001
From: John Dennis <jden...@redhat.com>
Date: Wed, 14 Dec 2011 15:19:56 -0500
Subject: [PATCH 59-1] Modify spec file to add ipa_memcached service Install &
 control ipa_memcached instance
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

---
 freeipa.spec.in                       |   22 ++++++
 init/SystemV/ipa_memcached.init       |  120 +++++++++++++++++++++++++++++++++
 init/ipa_memcached.conf               |    5 ++
 init/systemd/ipa.conf.tmpfiles        |    1 +
 init/systemd/ipa_memcached.service    |   13 ++++
 install/tools/ipa-server-install      |    7 ++
 ipaserver/install/memcacheinstance.py |   26 +++++++
 ipaserver/install/service.py          |    1 +
 8 files changed, 195 insertions(+), 0 deletions(-)
 create mode 100755 init/SystemV/ipa_memcached.init
 create mode 100644 init/ipa_memcached.conf
 create mode 100644 init/systemd/ipa.conf.tmpfiles
 create mode 100644 init/systemd/ipa_memcached.service
 create mode 100644 ipaserver/install/memcacheinstance.py

diff --git a/freeipa.spec.in b/freeipa.spec.in
index 2526a52..7fcbd19 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -109,6 +109,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
@@ -349,12 +351,25 @@ mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d/
 /bin/touch %{buildroot}%{_sysconfdir}/httpd/conf.d/ipa-pki-proxy.conf
 /bin/touch %{buildroot}%{_sysconfdir}/httpd/conf.d/ipa-rewrite.conf
 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
 
@@ -483,12 +498,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 0000000..b30ea50
--- /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 0000000..19d9127
--- /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 0000000..e4b679a
--- /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 0000000..33ace09
--- /dev/null
+++ b/init/systemd/ipa_memcached.service
@@ -0,0 +1,13 @@
+[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 b913438..9825d54 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
@@ -144,6 +145,8 @@ def parse_options():
                       default=False, help="print debugging information")
     basic_group.add_option("-U", "--unattended", dest="unattended", action="store_true",
                       default=False, help="unattended (un)installation never prompts the user")
+    basic_group.add_option("-M", "--no-memcache", dest="memcache", action="store_false",
+                      help="do not configure memcache", default=True)
     parser.add_option_group(basic_group)
 
     cert_group = OptionGroup(parser, "certificate system options")
@@ -988,6 +991,10 @@ def main():
         os.write(pw_fd, options.http_pin)
         os.close(pw_fd)
 
+    if options.memcache:
+        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 0000000..91c8636
--- /dev/null
+++ b/ipaserver/install/memcacheinstance.py
@@ -0,0 +1,26 @@
+# Authors: John Dennis <jden...@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 d9e6def..467e604 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),
     'ADTRUST':('smb', 60)
-- 
1.7.7.5

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to