Hi all;
I am trying to make an entry in Rundeck to stop and start SAS Object Spawner by operator if it is NOT UP after a weekly start.
My point is that SAS Object Spawner is asking for a key and that is a mess.
I had tried to comment the wait commands, but it does not work.
Any idea?
This is the current Object Spawner script:
#!/bin/sh -p
#
# ObjectSpawner.sh
#
# syslog Starts the SAS Object Spawner
#
# Uncomment the set -x to run in debug mode
# set -x
# Source level_env
. `dirname $0`/../level_env.sh
CONFIGDIR=$LEVEL_ROOT/ObjectSpawner
LOGSDIR=/work/sas/Lev4/ObjectSpawner/Logs
SASENV=$SASROOT/bin/sasenv
OMRCFG=$LEVEL_ROOT/ObjectSpawner/metadataConfig.xml
SPWNNAME="Object Spawner - sas94-t"
SERVERUSER=sasadm
CMD_OPTIONS=" -dnsmatch sas94-t.internal.epo.org -sspi "
COMMAND="$SASROOT/utilities/bin/objspawn"
SCRIPT=`basename $0`
if [ "$SAS_INSTALL_ROOT" = "" ] ; then
SAS_INSTALL_ROOT=$SASROOT
export SAS_INSTALL_ROOT
fi
# Are we super user
if id | grep "^uid=0(" >/dev/null 2>&1 ; then
root=1
else
root=0
fi
# If there is a keytab present for the object spawner, export it here
if [ -f "$CONFIGDIR/objspawn.keytab" ]; then
KRB5_CLIENT_KTNAME="$CONFIGDIR/objspawn.keytab"
export KRB5_CLIENT_KTNAME
fi
# Get argument
case "$1" in
start | -start)
if [ -f $CONFIGDIR/$SERVER_PID_FILE_NAME ]; then
pid=`cat $CONFIGDIR/$SERVER_PID_FILE_NAME`
kill -0 $pid > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Spawner is already running (pid $pid)"
exit 0
fi
rm $CONFIGDIR/$SERVER_PID_FILE_NAME
fi
if [ $root -eq 1 ]; then
su - $SERVERUSER -c "$CONFIGDIR/$SCRIPT start2_tag &"
else
$CONFIGDIR/$SCRIPT start2_tag &
fi
;;
start2_tag)
cd $CONFIGDIR
. $SASENV
SASROOT=$SASROOT
export SASROOT
# Source usermods file
. $CONFIGDIR/ObjectSpawner_usermods.sh
eval "nohup $COMMAND $CMD_OPTIONS -sasSpawnerCn \"$SPWNNAME\" -xmlconfigfile $OMRCFG -logconfigloc $CONFIGDIR/logconfig.xml ${USERMODS}> $LOGSDIR/ObjectSpawner_console_sas94-t.log 2>&1 &"
pid=$!
echo $pid > $CONFIGDIR/$SERVER_PID_FILE_NAME
echo "Spawner is started (pid $pid)..."
# Trap signals 9 and 15 and pass on to child process
trap 'kill $pid' 2 3 15
wait $!
rm "$CONFIGDIR/$SERVER_PID_FILE_NAME"
echo "Spawner is stopped"
echo "Log files are located at: $LOGSDIR"
;;
stop | -stop)
if [ -f $CONFIGDIR/$SERVER_PID_FILE_NAME ]; then
pid=`cat $CONFIGDIR/$SERVER_PID_FILE_NAME`
kill $pid
if [ $? -ne 0 ]; then
echo "pid: $pid"
fi
else
echo "Spawner is stopped"
fi
;;
status | -status)
if [ -f $CONFIGDIR/$SERVER_PID_FILE_NAME ]; then
pid=`cat $CONFIGDIR/$SERVER_PID_FILE_NAME`
kill -0 $pid > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Spawner is started (pid $pid)"
else
echo "Spawner is stopped"
fi
else
echo "Spawner is stopped"
fi
;;
restart | -restart)
$0 stop
if [ $? -eq 0 ]; then
sleep 5
$0 start
fi
;;
*)
echo "Usage: $SCRIPT {-}{start|stop|status|restart}"
exit 1
esac
exit 0
Redirect the outputs to the bit bucket:
nohup ./ObjectSpawner.sh stop >/dev/null 2>&1 nohup ./ObjectSpawner.sh start >/dev/null 2>&1
Hi @herborfer
What do you mean by asking for a key? parameter? sorry I did not get it. Could you share how are you trying to call the spawner command via RunDeck?
Ok, I get what you are referring to. How about using nohup before the start/stop command whichever way you are using it?
nohup ./ObjectSpawner.sh stop
nohup ./ObjectSpawner.sh start
Yes it would just output everything to a file but it can solve the problem of hitting a key for script to exit or complete.
Redirect the outputs to the bit bucket:
nohup ./ObjectSpawner.sh stop >/dev/null 2>&1 nohup ./ObjectSpawner.sh start >/dev/null 2>&1
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to explore data assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.