[sks/el6: 1/3] Add init scripts

Nick Bebout nb at fedoraproject.org
Mon Jan 23 17:29:02 UTC 2012


commit a7141752bffe87f191e02fde9adc053b6904cbe5
Author: Nick Bebout <nb at fedoraproject.org>
Date:   Fri Jan 20 18:49:46 2012 -0600

    Add init scripts

 sks-db.init    |  141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sks-recon.init |  142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sks.spec       |   19 +++++++-
 3 files changed, 301 insertions(+), 1 deletions(-)
---
diff --git a/sks-db.init b/sks-db.init
new file mode 100755
index 0000000..c85f7aa
--- /dev/null
+++ b/sks-db.init
@@ -0,0 +1,141 @@
+    #!/bin/bash
+    #
+    # sks-db          This shell script takes care of starting and stopping
+    #                 the SKS database server.
+    #
+    # chkconfig: - 89 11
+    # description:    SKS is the OpenPGP Synchronizing Key Server.
+    # processname:    sks-db
+    # config:         /etc/sks/sksconf
+    # pidfile:        /var/run/sks-db.pid
+     
+    # Source function library.
+    . /etc/rc.d/init.d/functions
+     
+    # Source networking configuration.
+    . /etc/sysconfig/network
+     
+    # Check that networking is up.
+    [ ${NETWORKING} = "no" ] && exit 1
+     
+    # Defines
+    DESC="the SKS Database Server"
+    PROG="sks-db"
+    EXEC="/usr/sbin/${PROG}"
+    LOCK="/var/lock/subsys/${PROG}"
+    PIDF="/var/run/${PROG}.pid"
+    CONF="/srv/sks/sksconf"
+     
+    # Include config
+    if [ -s /etc/sysconfig/sks ]; then
+      . /etc/sysconfig/sks
+    fi
+     
+    # Further defines
+    RUN_AS="${RUN_AS:-sks}"
+    SKS_SHUT="${SKS_SHUT:-60}"
+    SKS_CMD="`echo ${PROG} | cut -d'-' -f2`"
+     
+    # Check for binaries and configs
+    [ -x ${EXEC} ] || exit 5
+    [ -f ${CONF} ] || exit 6
+     
+     
+    start() {
+            # Start daemons.
+            cd /srv/sks/
+            echo -n $"Starting ${DESC}: "
+    #       daemon --user=${RUN_AS} ${EXEC} ${SKS_CMD} -debuglevel 4 -hostname key-server.nausch.org -basedir /var/lib/sks -stat_hour 1 2\>/dev/null \&
+            daemon --user=${RUN_AS} ${EXEC} ${SKS_CMD} 2\>/dev/null \&
+    #       daemon --user=${RUN_AS} ${EXEC} ${SKS_CMD} ${OPTIONS} 2\>/dev/null \&
+            RETVAL=${?}
+     
+            [ ${RETVAL} -eq 0 ] && {
+              touch ${LOCK}
+              sleep 3
+     
+              PID=`pidof -o %PPID ${PROG}`
+              RETVAL=${?}
+     
+              [ ${RETVAL} -eq 0 ] && echo ${PID} >${PIDF}
+            }
+            echo
+            return ${RETVAL}
+    }
+     
+    stop() {
+            # Stop daemons.
+            echo -n $"Shutting down ${DESC}: "
+            PID=`pidof -o %PPID ${PROG}`
+            RETVAL=${?}
+     
+            [ ${RETVAL} -eq 0 ] && {
+              kill -TERM ${PID}
+     
+              TIMEOUT=0
+              while pidof -o %PPID ${PROG} >/dev/null; do
+                if [ ${TIMEOUT} -ge ${SKS_SHUT} ]; then
+                  RETVAL=1
+                  break
+                else
+                  sleep 5 && echo -n "."
+                  TIMEOUT=$((TIMEOUT+5))
+                fi
+              done
+     
+              [ ${RETVAL} -eq 0 ] && rm -f ${LOCK} ${PIDF}
+            }
+     
+            [ ${RETVAL} -eq 0 ] && success $"${PROG} shutdown" || failure $"${PROG} shutdown"
+            echo
+            return ${RETVAL}
+    }
+     
+    restart() {
+            stop
+            sleep 2
+            start
+    }
+     
+    force_reload() {
+            restart
+    }
+     
+    rh_status() {
+            status ${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}
+            ;;
+        force-reload)
+            force_reload
+            ;;
+        status)
+            rh_status
+            ;;
+        condrestart|try-restart)
+            rh_status_q || exit 0
+            restart
+            ;;
+        *)
+            echo $"Usage: ${PROG} {start|stop|status|restart|try-restart|force-reload}"
+            exit 2
+    esac
+    exit ${?}
+
diff --git a/sks-recon.init b/sks-recon.init
new file mode 100755
index 0000000..3e4c24f
--- /dev/null
+++ b/sks-recon.init
@@ -0,0 +1,142 @@
+    #!/bin/bash
+    #
+    # sks-recon       This shell script takes care of starting and stopping
+    #                 the SKS reconciliation server.
+    #
+    # chkconfig: - 89 11
+    # description:    SKS is the OpenPGP Synchronizing Key Server.
+    # processname:    sks-recon
+    # config:         /srv/sks/sksconf
+    # pidfile:        /var/run/sks-recon.pid
+     
+    # Source function library.
+    . /etc/rc.d/init.d/functions
+     
+    # Source networking configuration.
+    . /etc/sysconfig/network
+     
+    # Check that networking is up.
+    [ ${NETWORKING} = "no" ] && exit 1
+     
+    # Defines
+    DESC="the SKS Reconciliation Server"
+    PROG="sks-recon"
+    EXEC="/usr/sbin/${PROG}"
+    LOCK="/var/lock/subsys/${PROG}"
+    PIDF="/var/run/${PROG}.pid"
+    CONF="/srv/sks/sksconf"
+     
+    # Include config
+    if [ -s /etc/sysconfig/sks ]; then
+      . /etc/sysconfig/sks
+    fi
+     
+    # Further defines
+    RUN_AS="${RUN_AS:-sks}"
+    SKS_SHUT="${SKS_SHUT:-60}"
+    SKS_CMD="`echo ${PROG} | cut -d'-' -f2`"
+
+    # Check for binaries and configs
+    [ -x ${EXEC} ] || exit 5
+    [ -f ${CONF} ] || exit 6
+     
+     
+    start() {
+            # Start daemons.
+            cd /srv/sks/
+            echo -n $"Starting ${DESC}: "
+    #       daemon --user=${RUN_AS} ${EXEC} ${SKS_CMD} -debuglevel 4 -hostname key-server.nausch.org -basedir /var/lib/sks -stat_hour 1 2\>/dev/null \&
+            daemon --user=${RUN_AS} ${EXEC} ${SKS_CMD} 2\>/dev/null \&
+    #       daemon --user=${RUN_AS} ${EXEC} ${SKS_CMD} ${OPTIONS} 2\>/dev/null \&
+            RETVAL=${?}
+     
+            [ ${RETVAL} -eq 0 ] && {
+              touch ${LOCK}
+              sleep 3
+     
+              PID=`pidof -o %PPID ${PROG}`
+              RETVAL=${?}
+     
+              [ ${RETVAL} -eq 0 ] && echo ${PID} >${PIDF}
+            }
+            echo
+            return ${RETVAL}
+    }
+     
+    stop() {
+            # Stop daemons.
+            echo -n $"Shutting down ${DESC}: "
+            PID=`pidof -o %PPID ${PROG}`
+            RETVAL=${?}
+     
+            [ ${RETVAL} -eq 0 ] && {
+              kill -TERM ${PID}
+     
+              TIMEOUT=0
+              while pidof -o %PPID ${PROG} >/dev/null; do
+                if [ ${TIMEOUT} -ge ${SKS_SHUT} ]; then
+                  RETVAL=1
+                  break
+                else
+                  sleep 5 && echo -n "."
+                  TIMEOUT=$((TIMEOUT+5))
+                fi
+              done
+     
+              [ ${RETVAL} -eq 0 ] && rm -f ${LOCK} ${PIDF}
+            }
+     
+            [ ${RETVAL} -eq 0 ] && success $"${PROG} shutdown" || failure $"${PROG} shutdown"
+            echo
+            return ${RETVAL}
+    }
+     
+    restart() {
+            stop
+            sleep 2
+            start
+    }
+     
+    force_reload() {
+            restart
+    }
+     
+    rh_status() {
+            status ${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}
+            ;;
+        force-reload)
+            force_reload
+            ;;
+        status)
+            rh_status
+            ;;
+        condrestart|try-restart)
+            rh_status_q || exit 0
+            restart
+            ;;
+        *)
+            echo $"Usage: ${PROG} {start|stop|status|restart|try-restart|force-reload}"
+            exit 2
+    esac
+    exit ${?}
+
+
diff --git a/sks.spec b/sks.spec
index 86985be..b17ee17 100644
--- a/sks.spec
+++ b/sks.spec
@@ -1,11 +1,13 @@
 Summary:        Synchronizing Key Server
 Name:           sks
 Version:        1.1.2
-Release:        1%{?dist}
+Release:        2%{?dist}
 License:        GPLv2+
 Group:          System Environment/Daemons
 URL:            http://code.google.com/p/sks-keyserver/
 Source0:        http://sks-keyserver.googlecode.com/files/sks-1.1.2.tgz
+Source1:        sks-db.init
+Source2:        sks-recon.init
 Patch0:         sks-1.1.1-libdb.patch
 #Patch1:		sks-1.1.1-bdb.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
@@ -33,6 +35,12 @@ deploy, decentralized, and highly reliable synchronization.
 %__make install PREFIX="%{buildroot}%{_prefix}" MANDIR="%{buildroot}%{_mandir}"
 chmod -x %{buildroot}%{_mandir}/man8/sks.8.gz
 chrpath --delete %{buildroot}%{_bindir}/sks
+install -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/sks-db
+install -Dp -m0755 %{SOURCE2} %{buildroot}%{_initrddir}/sks-recon
+for TYPE in db recon; do
+  %{__ln_s} %{_bindir}/%{name}  ${RPM_BUILD_ROOT}%{_sbindir}/%{name}-${TYPE}
+done
+
 
 %clean
 %__rm -Rf "%{buildroot}"
@@ -43,9 +51,15 @@ chrpath --delete %{buildroot}%{_bindir}/sks
 %{_bindir}/sks
 %{_bindir}/sks_build.sh
 %{_bindir}/sks_add_mail
+%{_sbindir}/%{name}-db
+%{_sbindir}/%{name}-recon
 %{_mandir}/man8/sks.8.gz
+%{_initrddir}/sks-*
 
 %changelog
+* Thu Jan 19 2012 Nick Bebout <nb at fedoraproject.org> - 1.1.2-2
+- Add init.d scripts
+
 * Tue Dec 13 2011 Nick Bebout <nb at fedoraproject.org> - 1.1.2-1
 - Upgrade to 1.1.2
 
@@ -60,9 +74,12 @@ chrpath --delete %{buildroot}%{_bindir}/sks
 
 * Tue May 18 2010 Nick Bebout <nb at fedoraproject.org> - 1.1.1-4
 - Make bdb patch better
+
 * Tue Apr 20 2010 Nick Bebout <nb at fedoraproject.org> - 1.1.1-3
 - Fix FTBFS
+
 * Wed Oct 14 2009 Nick Bebout <nb at fedoraproject.org> - 1.1.1-2
 - Add CFLAGS to make all
+
 * Tue Oct 13 2009 Nick Bebout <nb at fedoraproject.org> - 1.1.1-1
 - Initial Fedora package based on 1.1.1 of sks


More information about the scm-commits mailing list