From 9cebbebeb77314a12deac9881b6ee1161b7251d8 Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Thu, 25 Sep 2014 15:14:31 +0100 Subject: [PATCH 1/9] Create tids-wrapper for Debian Tested on Debian 7 --- debian/tids-wrapper | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 debian/tids-wrapper diff --git a/debian/tids-wrapper b/debian/tids-wrapper new file mode 100644 index 0000000..831cb3a --- /dev/null +++ b/debian/tids-wrapper @@ -0,0 +1,14 @@ +#! /usr/bin/env bash + +PIDFILE=$1 +LOGFILE=$2 +shift 2 + +unset DISPLAY +/usr/bin/tids $@ >> $LOGFILE 2>&1 & +BGPID=$! +RET=$? + +echo $BGPID > $PIDFILE + +exit $RET From fa6c6fa796b73c28554b84dfba3a096e269a8017 Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Thu, 25 Sep 2014 15:15:44 +0100 Subject: [PATCH 2/9] Create tids.initd for Debian Tested on Debian 7. --- debian/tids.initd | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 debian/tids.initd diff --git a/debian/tids.initd b/debian/tids.initd new file mode 100644 index 0000000..d2577c7 --- /dev/null +++ b/debian/tids.initd @@ -0,0 +1,101 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: tids +# Default-Start: 3 5 +# Default-Stop: 0 1 2 4 6 +# Required-Start: $freeradius +# Should-Start: $network +# Short-Description: Starts Moonshot TIDS +# Description: Starts the Moonshot Temporary ID Service +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +. /lib/lsb/init-functions + +[ -z "$HOME" ] && export HOME=/ + +usage() { + echo "Usage: $0 {start|stop|status}" +} + +# Load the configuration +[ -f /etc/default/tids ] || exit 6 +. /etc/default/tids + +# Create the PID and LOG directories +[ -d "$TIDS_PIDDIR" ] || mkdir -p $TIDS_PIDDIR && chown $TIDS_USER:$TIDS_GROUP $TIDS_PIDDIR +[ -d "$TIDS_LOGDIR" ] || mkdir -p $TIDS_LOGDIR && chown $TIDS_USER:$TIDS_GROUP $TIDS_LOGDIR + +# Some variables +prog=/usr/bin/tids-wrapper +PIDFILE="$TIDS_PIDDIR/tids.pid" +LOGFILE="$TIDS_LOGDIR/tids.log" + +# Does the trust router and wrapper exist +[ -x /usr/bin/tids ] || exit 5 +[ -x /usr/bin/tids-wrapper ] || exit 5 + +[ -f "$LOGFILE" ] || touch $LOGFILE && chown $TIDS_USER:$TIDS_GROUP $LOGFILE + +OPTIONS="$PIDFILE $LOGFILE $TIDS_SERVER_IP $TIDS_GSS_NAME $TIDS_SERVER_NAME $KEYFILE" + +case $1 in + start) + if [ -f ${PIDFILE} ] ; + then + OLD_PID=$(cat "$PIDFILE") + + if [ -d "/proc/$OLD_PID" ] ; + then + echo "Error: TIDS already running" ; exit 1 + else + rm $PIDFILE + fi + fi + + timestamp=$(date) + echo "$timestamp Starting TIDS..." >> $LOGFILE + log_daemon_msg "Starting TIDS" "tids" + start-stop-daemon --start --chuid $TIDS_USER --pidfile $PIDFILE --oknodo --startas $prog $OPTIONS + status=$? + log_end_msg $status + ;; + stop) + timestamp=$(date) + echo "$timestamp Stopping TIDS..." >> $LOGFILE + log_daemon_msg "Stopping TIDS" "tids" + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE + status=$? + log_end_msg $status + rm -f $PIDFILE + ;; + status) + if [ -f $PIDFILE ] ; + then + PID=$(cat "$PIDFILE") + + if [ -d "/proc/$PID" ] ; + then + echo "TIDS is running (pid $PID)" + else + if [ -e $PIDFILE ] ; then + echo "TIDS appears to be dead but its PID file exists" + else + echo "TIDS appears to be stopped" + fi + fi + else + echo "TIDS appears to be stopped" + fi + exit 0 + ;; + reload | force-reload | condrestart | try-restart) + usage + exit 3 + ;; + *) + usage + exit 2 + ;; +esac From f1a42247be4f07a9598cd9ee72a32df08d491de0 Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Thu, 25 Sep 2014 15:21:04 +0100 Subject: [PATCH 3/9] Move tids.initd to redhat/ Since Redhat and Debian syntax are very close, but not identical, perhaps we should move each into their own directories... --- tids.initd => redhat/tids.initd | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tids.initd => redhat/tids.initd (100%) diff --git a/tids.initd b/redhat/tids.initd similarity index 100% rename from tids.initd rename to redhat/tids.initd From 59eeac192d37c51385f5b3b553fb1dcff9e8d8bb Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Thu, 25 Sep 2014 15:22:19 +0100 Subject: [PATCH 4/9] Update trust_router.spec Updated with moved location of TIDS.INITD. --- trust_router.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trust_router.spec b/trust_router.spec index 1d449ed..9a40478 100644 --- a/trust_router.spec +++ b/trust_router.spec @@ -61,7 +61,7 @@ install -D -m 640 redhat/default-main.cfg $RPM_BUILD_ROOT/%{_sysconfdir}/trust_r install -D -m 640 redhat/tr-test-main.cfg $RPM_BUILD_ROOT/%{_sysconfdir}/trust_router/conf.d/tr-test/main.cfg install -D -m 640 redhat/sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/trust_router install -D -m 640 redhat/sysconfig.tids $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/tids -install -D -m 755 tids.initd $RPM_BUILD_ROOT/%{_initrddir}/tids +install -D -m 755 redhat/tids.initd $RPM_BUILD_ROOT/%{_initrddir}/tids # Link shared config ln -s ../../trusts.cfg $RPM_BUILD_ROOT/%{_sysconfdir}/trust_router/conf.d/default/trusts.cfg From c2066bea26488b414470853ea5fd935b77f7eae7 Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Thu, 25 Sep 2014 15:49:47 +0100 Subject: [PATCH 5/9] Update tids.initd Fixed a missing $ for the pidfile. --- redhat/tids.initd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redhat/tids.initd b/redhat/tids.initd index 3af387a..2bff707 100644 --- a/redhat/tids.initd +++ b/redhat/tids.initd @@ -59,7 +59,7 @@ case "$1" in timestamp=$(date) echo "${timestamp} Starting TIDS..." >> ${LOGFILE} echo -n "Starting TIDS..." - daemon --user="${TIDS_USER}" --pidfile="{PIDFILE}" "${prog}" "${OPTIONS}" + daemon --user="${TIDS_USER}" --pidfile="${PIDFILE}" "${prog}" "${OPTIONS}" echo exit $? From 80dcebb4262f93d44fabb406c6b852e7158bc84c Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Thu, 25 Sep 2014 17:40:23 +0100 Subject: [PATCH 6/9] Update tids.initd with missing LSB comment Otherwise dpkg scripts complain that they're missing. --- debian/tids.initd | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/tids.initd b/debian/tids.initd index d2577c7..9ac7835 100644 --- a/debian/tids.initd +++ b/debian/tids.initd @@ -4,6 +4,7 @@ # Default-Start: 3 5 # Default-Stop: 0 1 2 4 6 # Required-Start: $freeradius +# Required-Stop: # Should-Start: $network # Short-Description: Starts Moonshot TIDS # Description: Starts the Moonshot Temporary ID Service From 8f1f5bd11900612b4ee724db7d1671824c5b84ec Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Fri, 26 Sep 2014 22:15:55 +0100 Subject: [PATCH 7/9] Update Makefile.am Add the three missing files to the distribution file: tids.init, sysconfig.tids, tids-wrapper --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 5fd1825..806e59f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,7 +62,7 @@ noinst_HEADERS = include/gsscon.h include/tr_config.h \ include/tid_internal.h pkgdata_DATA=schema.sql -nobase_dist_pkgdata_DATA=redhat/init redhat/sysconfig redhat/trusts.cfg redhat/tidc-wrapper redhat/trust_router-wrapper redhat/tr-test-main.cfg redhat/default-main.cfg +nobase_dist_pkgdata_DATA=redhat/init redhat/tids.init redhat/sysconfig redhat/sysconfig.tids redhat/trusts.cfg redhat/tidc-wrapper redhat/trust_router-wrapper redhat/tids-wrapper redhat/tr-test-main.cfg redhat/default-main.cfg if HAVE_SYSTEMD systemdsystemunit_DATA = tids.service From 8eaca616727b1f012fe9adc1b29df495e45360d6 Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Fri, 26 Sep 2014 23:20:18 +0100 Subject: [PATCH 8/9] Rename tids.initd to tids.init To match what Sam's done. --- redhat/{tids.initd => tids.init} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename redhat/{tids.initd => tids.init} (100%) diff --git a/redhat/tids.initd b/redhat/tids.init similarity index 100% rename from redhat/tids.initd rename to redhat/tids.init From 222c548e60edc884de4a3a92183284400aa9b166 Mon Sep 17 00:00:00 2001 From: Stefan Paetow Date: Fri, 26 Sep 2014 23:30:19 +0100 Subject: [PATCH 9/9] Update trust_router.spec Tweak the name to what Sam did. --- trust_router.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trust_router.spec b/trust_router.spec index 9a40478..a00abe5 100644 --- a/trust_router.spec +++ b/trust_router.spec @@ -61,7 +61,7 @@ install -D -m 640 redhat/default-main.cfg $RPM_BUILD_ROOT/%{_sysconfdir}/trust_r install -D -m 640 redhat/tr-test-main.cfg $RPM_BUILD_ROOT/%{_sysconfdir}/trust_router/conf.d/tr-test/main.cfg install -D -m 640 redhat/sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/trust_router install -D -m 640 redhat/sysconfig.tids $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/tids -install -D -m 755 redhat/tids.initd $RPM_BUILD_ROOT/%{_initrddir}/tids +install -D -m 755 redhat/tids.init $RPM_BUILD_ROOT/%{_initrddir}/tids # Link shared config ln -s ../../trusts.cfg $RPM_BUILD_ROOT/%{_sysconfdir}/trust_router/conf.d/default/trusts.cfg