I have two scripts that are used to start and stop services these scripts are at the location
/opt/app/tre
, so that start.sh internally starts the components and stop.sh internally stop all the components, now rite now if I have to stop the services then i need to go first the location where all the scripts are there then I need to execute the stop script and then in between doing some work again need to start the services ..besides there is another script status (status.sh) by which I check the status, so the cycle follows as first stop the services then check the status which confirms that services are stop and then in between doing some work so the interval is of 40 seconds and then again starting the components by executing the start.sh,
$ cd /opt/app/tre
sh stop.sh
sh status.sh
sh start.sh
sh status.sh
so rite now I want to develop another script and the name of this script will be restart.sh that will internally first call my stop.sh script then it will show that status by calling my status.sh script then it will sleep for 40 seconds and then again it will start the components and then will again show the status please advise how to develop these restart.sh script.
one=1
status=1
clear
while [[ $status -eq $one ]]
do
echo "Please enter the appropriate choice for doing the operations"
echo "
1) STOP instance
2) START instance
3) Check status of instance
Enter choice below
@@"
read choice
case $choice
in
1)
echo "Stopping instances."
call STOP script here
2)
echo "starting instances"
Call START script here.
3)
echo "checking instances"
Call Status script here.
*) echo "You have entered an invalid choice";;
esac
echo "\n\n"
echo "Please enter 1(Digit) if you want to continue with menu script, enter 0(digit) to come out of it"
read status
done
Thanks a lot the 4 th choice that I want is the start stop simentously with a 40 seconds gap in between that is service will stop first , and status will be printed and then 40 seconds break will be there and then services will be restarted and again the status will be printed , I have all the scripts ready I just need to call them as you advise.
second query is that as you mention...
case $choice
in
1)
echo "Stopping instances."
call STOP script here
so in the place of call STOP script can I call directly my stop script like as shown below..
case $choice
in
1)
echo "Stopping instances."
stop.sh
Perfect this what I am looking for in sidae a script say resstart.sh, so i will cal the script like sh restart.sh that will internally do the processing in this order and it will internally call my scripts so please advise how to achieve this ,Thanks in advance..!!