3 # 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
5 #DOMAIN=$(pwd |sed "s%/home/nevrax/%%" | sed "s%/.*%%")
7 #NAME_BASE=$(pwd | sed 's/\/home\/nevrax\///' | sed 's/^.*\///')
13 #if [ _$DOMAIN == _pre_live ]
15 CTRL_FILE
=${NAME_BASE}.launch_ctrl
16 NEXT_CTRL_FILE
=${NAME_BASE}.deferred_launch_ctrl
17 #elif [ _$DOMAIN == _pre_pre_live ]
19 # CTRL_FILE=${NAME_BASE}.launch_ctrl
20 # NEXT_CTRL_FILE=${NAME_BASE}.deferred_launch_ctrl
22 # CTRL_FILE=${NAME_BASE}_immediate.launch_ctrl
23 # NEXT_CTRL_FILE=${NAME_BASE}_waiting.launch_ctrl
25 STATE_FILE
=${NAME_BASE}.state
26 START_COUNTER_FILE
=${NAME_BASE}.start_count
30 echo ---------------------------------------------------------------------------------
31 echo Starting service launcher
32 echo ---------------------------------------------------------------------------------
33 printf "%-16s = " CMDLINE
; echo $CTRL_CMDLINE
34 printf "%-16s = " CTRL_FILE
; echo $CTRL_FILE
35 printf "%-16s = " NEXT_CTRL_FILE
; echo $NEXT_CTRL_FILE
36 printf "%-16s = " STATE_FILE
; echo $STATE_FILE
37 echo ---------------------------------------------------------------------------------
40 # reinit the start counter
41 echo 0 > $START_COUNTER_FILE
44 echo Press ENTER to launch program
48 # see if the conditions are right to launch the app
52 # a control file exists so read it's contents
53 CTRL_COMMAND
=_$
(cat $CTRL_FILE)_
55 # do we have a 'launch' command?
56 if [ $CTRL_COMMAND = _LAUNCH_
]
59 # update the start counter
60 START_COUNTER
=$
(( $START_COUNTER + 1 ))
61 echo $START_COUNTER > $START_COUNTER_FILE
63 # big nasty hack to deal with the special cases of ryzom_naming_service and ryzom_admin_service who have badly names cfg files
66 cp $f $
(echo $f |
sed "s/ryzom_//")
69 # we have a launch command so prepare, launch, wait for exit and do the housekeeping
70 echo -----------------------------------------------------------------------
73 printf RUNNING
> $STATE_FILE
77 echo -----------------------------------------------------------------------
78 printf STOPPED
> $STATE_FILE
80 # consume (remove) the control file to allow start once
83 echo Press ENTER to relaunch
87 # either we haven't launched the app yet or we have launched and it has exitted
88 if [ -e $NEXT_CTRL_FILE ]
90 # we have some kind of relaunch directive lined up so deal with it
91 mv $NEXT_CTRL_FILE $CTRL_FILE
93 # give the terminal user a chance to press enter to provoke a re-launch when auto-relaunch in AES is disabled
94 HOLD
=`sh -ic '{ read a; echo "ENTER" 1>&3; kill 0; } | { sleep 2; kill 0; }' 3>&1 2>/dev/null`
95 if [ "${HOLD}" = "ENTER" ]
97 printf LAUNCH
> $CTRL_FILE