Need sample to parameterize service #229
Unanswered
SunilSharma1986
asked this question in
General
Replies: 3 comments 1 reply
-
@ko1nksm - Can you please and let me know a sample code in BDD format to check the service |
Beta Was this translation helpful? Give feedback.
1 reply
-
Here are example codes. https://github.com/shellspec/shellspec/tree/master/examples/spec |
Beta Was this translation helpful? Give feedback.
0 replies
-
@SunilSharma1986 - it's not at all clear what you're after - you need to be clear if it's to ...
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Team,
I am new to shell script and this framework, require a sample code to just parameterize the services and check if the service is running or not. Here is a reference code, can you please provide the syntax in the BDD format and that would be very helpful
!/usr/bin/bash
desc: monitor service running on system
auth
date
service=$(which monit | cut -d/ -f4)
checking for installed service
echo " checking for the installed service : $service \n"
if [ $? -ne 0 ] || [ -z $service ]; then
echo "$service not found..exiting"
exit
fi
Check if the service is running
STATUS="$(systemctl is-active $service)"
if [ "${STATUS}" = "active" ]; then
echo "$service is running and active....."
else
echo " Service not running.... so exiting "
exit 1
fi
Beta Was this translation helpful? Give feedback.
All reactions