From 6c5bab085411be3b779b8e52b5e543c3e269d08d Mon Sep 17 00:00:00 2001 From: Isaac Dunham Date: Sat, 7 Mar 2015 17:43:58 +0000 Subject: [PATCH] contrib/rc/linux/dtlogin: Make the init script work. * insserv requires a shebang line * the rc script can hang if a daemon is started in the foreground * "pgrep dtlogin" apparently can match the init script, if it is started with "service dtlogin start" or similar. * reduce code duplication --- cde/contrib/rc/linux/dtlogin | 51 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/cde/contrib/rc/linux/dtlogin b/cde/contrib/rc/linux/dtlogin index 3a04ab55..c5f17a68 100644 --- a/cde/contrib/rc/linux/dtlogin +++ b/cde/contrib/rc/linux/dtlogin @@ -1,3 +1,4 @@ +#!/bin/sh ### BEGIN INIT INFO # Provides: lsb-dtlogin # Required-Start: $all @@ -8,38 +9,36 @@ # Description: Dtlogin ### END INIT INFO +export PATH="/usr/dt/bin:$PATH" +OPTIONS="-quiet -daemon" + +start(){ + if [ -z "$(pgrep /usr/dt/bin/dtlogin)" ]; + then + echo " * Starting dtlogin..." + export LANG=C + /usr/dt/bin/dtlogin $OPTIONS + fi +} + +stop(){ + if [ -n "$(pgrep /usr/dt/bin/dtlogin)" ]; + then + echo " * Stopping dtlogin..." + killall /usr/dt/bin/dtlogin + fi +} + case "$1" in 'start') - if [ -z "$(pgrep dtlogin)" ]; - then - echo " * Starting dtlogin..." - export LANG=C - exec /usr/dt/bin/dtlogin - else - echo "DTlogin already running..." - exit 0 - fi + start ;; 'stop') - if [ -z "$(pgrep dtlogin)" ]; - then - exit 0 - else - echo " * Stopping dtlogin..." - killall /usr/dt/bin/dtlogin - fi + stop ;; 'restart') - if [ -z "$(pgrep dtlogin)" ]; - then - export LANG=C - exec /usr/dt/bin/dtlogin - else - echo " * Restarting dtlogin..." - killall /usr/dt/bin/dtlogin - export LANG=C - exec /usr/dt/bin/dtlogin - fi + stop + start ;; 'status') if [ -z "$(pgrep dtlogin)" ]; -- 2.25.1