I am deploying an app to AWS EC2 instance and I am using a config file in the .ebextensions folder to execute a bash script.
In the script I am detecting if a particular service is running, if it's not running, install the package using rpm.
#!/bin/bash
service --status-all | grep -q 'MyService'
if [ $? -ne 0 ];
then
install my package
else
do nothing
fi
But the script is not working and it always go to install my service again.
It is because
service --status-all
is returning nothing at all which confuses me! But after the deployment when I go to the EC2 instance and try out the script, it does work. Just that it does not work during deployment.
There should be at least some services running but empty?
Am I doing this correctly?