|
|
|
@ -1,25 +1,26 @@
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# the object is to make a launcher script that works with a command file to determine when to launch the application that it is responsible for
|
|
|
|
|
# the objective is to make a launcher script that works with a command file to determine when to launch the application that it is responsible for
|
|
|
|
|
|
|
|
|
|
DOMAIN=$(pwd |sed "s%/srv/core/%%" | sed "s%/.*%%")
|
|
|
|
|
NAME_BASE=$(pwd | sed 's/\/srv\/core\///' | sed 's/^.*\///')
|
|
|
|
|
|
|
|
|
|
#if [ _$DOMAIN == _pre_live ]
|
|
|
|
|
# then
|
|
|
|
|
CTRL_FILE=${NAME_BASE}.launch_ctrl
|
|
|
|
|
NEXT_CTRL_FILE=${NAME_BASE}.deferred_launch_ctrl
|
|
|
|
|
# then
|
|
|
|
|
CTRL_FILE=${NAME_BASE}.launch_ctrl
|
|
|
|
|
NEXT_CTRL_FILE=${NAME_BASE}.deferred_launch_ctrl
|
|
|
|
|
#elif [ _$DOMAIN == _pre_pre_live ]
|
|
|
|
|
# then
|
|
|
|
|
# CTRL_FILE=${NAME_BASE}.launch_ctrl
|
|
|
|
|
# NEXT_CTRL_FILE=${NAME_BASE}.deferred_launch_ctrl
|
|
|
|
|
# then
|
|
|
|
|
# CTRL_FILE=${NAME_BASE}.launch_ctrl
|
|
|
|
|
# NEXT_CTRL_FILE=${NAME_BASE}.deferred_launch_ctrl
|
|
|
|
|
#else
|
|
|
|
|
# CTRL_FILE=${NAME_BASE}_immediate.launch_ctrl
|
|
|
|
|
# NEXT_CTRL_FILE=${NAME_BASE}_waiting.launch_ctrl
|
|
|
|
|
# CTRL_FILE=${NAME_BASE}_immediate.launch_ctrl
|
|
|
|
|
# NEXT_CTRL_FILE=${NAME_BASE}_waiting.launch_ctrl
|
|
|
|
|
#fi
|
|
|
|
|
STATE_FILE=${NAME_BASE}.state
|
|
|
|
|
START_COUNTER_FILE=${NAME_BASE}.start_count
|
|
|
|
|
CTRL_CMDLINE=$*
|
|
|
|
|
CTRL_COMMAND=""
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo ---------------------------------------------------------------------------------
|
|
|
|
@ -36,6 +37,13 @@ echo
|
|
|
|
|
echo 0 > $START_COUNTER_FILE
|
|
|
|
|
START_COUNTER=0
|
|
|
|
|
|
|
|
|
|
# always give ras a first run
|
|
|
|
|
if [ "${NAME_BASE}" = "ras" ]
|
|
|
|
|
then
|
|
|
|
|
echo Force admin service first startup
|
|
|
|
|
printf LAUNCH > $CTRL_FILE
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo Press ENTER to launch program
|
|
|
|
|
while true
|
|
|
|
|
do
|
|
|
|
@ -45,37 +53,37 @@ do
|
|
|
|
|
then
|
|
|
|
|
|
|
|
|
|
# a control file exists so read it's contents
|
|
|
|
|
CTRL_COMMAND=_$(cat $CTRL_FILE)_
|
|
|
|
|
CTRL_COMMAND=$(cat $CTRL_FILE)
|
|
|
|
|
|
|
|
|
|
# do we have a 'launch' command?
|
|
|
|
|
if [ $CTRL_COMMAND = _LAUNCH_ ]
|
|
|
|
|
if [ "$CTRL_COMMAND" = "LAUNCH" ]
|
|
|
|
|
then
|
|
|
|
|
|
|
|
|
|
# update the start counter
|
|
|
|
|
START_COUNTER=$(( $START_COUNTER + 1 ))
|
|
|
|
|
echo $START_COUNTER > $START_COUNTER_FILE
|
|
|
|
|
# update the start counter
|
|
|
|
|
START_COUNTER=$(( $START_COUNTER + 1 ))
|
|
|
|
|
echo $START_COUNTER > $START_COUNTER_FILE
|
|
|
|
|
|
|
|
|
|
# big nasty hack to deal with the special cases of ryzom_naming_service and ryzom_admin_service who have badly names cfg files
|
|
|
|
|
for f in ryzom_*cfg
|
|
|
|
|
do
|
|
|
|
|
cp $f $(echo $f | sed "s/ryzom_//")
|
|
|
|
|
done
|
|
|
|
|
# big nasty hack to deal with the special cases of ryzom_naming_service and ryzom_admin_service who have badly names cfg files
|
|
|
|
|
for f in ryzom_*cfg
|
|
|
|
|
do
|
|
|
|
|
cp $f $(echo $f | sed "s/ryzom_//")
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# we have a launch command so prepare, launch, wait for exit and do the housekeeping
|
|
|
|
|
echo -----------------------------------------------------------------------
|
|
|
|
|
echo Launching ...
|
|
|
|
|
echo
|
|
|
|
|
printf RUNNING > $STATE_FILE
|
|
|
|
|
# we have a launch command so prepare, launch, wait for exit and do the housekeeping
|
|
|
|
|
echo -----------------------------------------------------------------------
|
|
|
|
|
echo Launching ...
|
|
|
|
|
echo
|
|
|
|
|
printf RUNNING > $STATE_FILE
|
|
|
|
|
|
|
|
|
|
$CTRL_CMDLINE
|
|
|
|
|
$CTRL_CMDLINE
|
|
|
|
|
|
|
|
|
|
echo -----------------------------------------------------------------------
|
|
|
|
|
printf STOPPED > $STATE_FILE
|
|
|
|
|
echo -----------------------------------------------------------------------
|
|
|
|
|
printf STOPPED > $STATE_FILE
|
|
|
|
|
|
|
|
|
|
# consume (remove) the control file to allow start once
|
|
|
|
|
rm $CTRL_FILE
|
|
|
|
|
# consume (remove) the control file to allow start once
|
|
|
|
|
rm $CTRL_FILE
|
|
|
|
|
|
|
|
|
|
echo Press ENTER to relaunch
|
|
|
|
|
echo Press ENTER to relaunch
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -87,9 +95,9 @@ do
|
|
|
|
|
else
|
|
|
|
|
# give the terminal user a chance to press enter to provoke a re-launch
|
|
|
|
|
HOLD=`sh -ic '{ read a; echo "ENTER" 1>&3; kill 0; } | { sleep 2; kill 0; }' 3>&1 2>/dev/null`
|
|
|
|
|
if [ _${HOLD}_ != _HOLD_ ]
|
|
|
|
|
then
|
|
|
|
|
printf LAUNCH > $CTRL_FILE
|
|
|
|
|
if [ "${HOLD}" = "ENTER" ]
|
|
|
|
|
then
|
|
|
|
|
printf LAUNCH > $CTRL_FILE
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|