khanat-opennel-code/code/ryzom/tools/scripts/linux/ryzom_domain_screen_wrapper.sh

95 lines
2.3 KiB
Bash
Raw Normal View History

2013-02-18 12:22:03 +00:00
#!/bin/sh
CMD=$1
#DOMAIN=$(pwd|sed s%/home/nevrax/%%)
DOMAIN=shard
2014-04-19 19:53:29 +00:00
if [ "$CMD" = "" ]
2013-02-18 12:22:03 +00:00
then
echo
echo Screen sessions currently running:
screen -list
echo
echo "Commands:"
echo " 'start' to start the shard"
echo " 'stop' to stop the ${DOMAIN}"
echo " 'join' to join the ${DOMAIN}'s screen session"
echo " 'share' to join the screen session in shared mode"
echo " 'state' to view state information for the ${DOMAIN}"
echo
printf "Enter a command: "
read CMD
fi
2014-04-19 19:53:29 +00:00
if [ "$CMD" = "stop" ]
2013-02-18 12:22:03 +00:00
then
if [ $(screen -list | grep \\\.${DOMAIN} | wc -l) != 1 ]
then
2014-04-19 19:53:29 +00:00
echo Cannot stop domain \'${DOMAIN}\' because no screen by that name appears to be running
screen -list
2013-02-18 12:22:03 +00:00
else
2014-04-19 19:53:29 +00:00
screen -d -r $(screen -list | grep \\\.${DOMAIN}| sed 's/(.*)//') -X quit> /dev/null
rm -v */*.state
rm -v */*launch_ctrl ./global.launch_ctrl
2013-02-18 12:22:03 +00:00
fi
fi
STARTARGS=
2014-04-19 19:53:29 +00:00
if [ "$CMD" = "batchstart" ]
2013-02-18 12:22:03 +00:00
then
STARTARGS='-d -m'
CMD='start'
fi
2014-04-19 19:53:29 +00:00
if [ "$CMD" = "start" ]
2013-02-18 12:22:03 +00:00
then
2014-04-19 19:53:29 +00:00
ulimit -c unlimited
screen -wipe > /dev/null
if [ $( screen -list | grep \\\.${DOMAIN} | wc -w ) != 0 ]
then
echo Cannot start domain \'${DOMAIN}\' because this domain is already started
screen -list | grep $DOMAIN
else
screen $STARTARGS -S ${DOMAIN} -c ${DOMAIN}.screen.rc
fi
if [ "$STARTARGS" != "" ]
then
# on "batchstart", AES needs to be launched and AES will then launch other services
printf LAUNCH > aes/aes.launch_ctrl
fi
2013-02-18 12:22:03 +00:00
fi
2014-04-19 19:53:29 +00:00
if [ "$CMD" = "join" ]
2013-02-18 12:22:03 +00:00
then
if [ $(screen -list | grep \\\.${DOMAIN} | wc -l) != 1 ]
then
2014-04-19 19:53:29 +00:00
echo Cannot join domain \'${DOMAIN}\' because no screen by that name appears to be running
screen -list
2013-02-18 12:22:03 +00:00
else
2014-04-19 19:53:29 +00:00
screen -r $(screen -list | grep \\\.${DOMAIN}| sed 's/(.*)//')
fi
2013-02-18 12:22:03 +00:00
fi
2014-04-19 19:53:29 +00:00
if [ "$CMD" = "share" ]
2013-02-18 12:22:03 +00:00
then
if [ $(screen -list | grep \\\.${DOMAIN} | wc -l) != 1 ]
then
2014-04-19 19:53:29 +00:00
echo Cannot join domain \'${DOMAIN}\' because no screen by that name appears to be running
screen -list
2013-02-18 12:22:03 +00:00
else
2014-04-19 19:53:29 +00:00
screen -r -x $(screen -list | grep \\\.${DOMAIN}| sed 's/(.*)//')
fi
2013-02-18 12:22:03 +00:00
fi
2014-04-19 19:53:29 +00:00
if [ "$CMD" = "state" ]
2013-02-18 12:22:03 +00:00
then
echo State of domain ${DOMAIN}:
2014-04-19 19:53:29 +00:00
if [ "$(echo */*.state)" = "*/*.state" ]
2013-02-18 12:22:03 +00:00
then
2014-04-19 19:53:29 +00:00
echo - No state files found
else
grep RUNNING */*state
fi
2013-02-18 12:22:03 +00:00
fi