Created
July 5, 2023 16:56
-
-
Save patent-ed/76492c101a1219f5cc8e729b397e3360 to your computer and use it in GitHub Desktop.
A Jame Pro extension attribute that determines the apache version and whether it is active state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if Apache is installed | |
if [ -f /usr/sbin/apachectl ]; then | |
# Get the Apache version | |
apacheVersion=$(/usr/sbin/apachectl -v | head -n 1 | awk -F'/' '{print $2}' | awk '{print $1}') | |
# Check if Apache is running | |
if pgrep -x "httpd" > /dev/null; then | |
status="Active" | |
else | |
status="Inactive" | |
fi | |
else | |
apacheVersion="Not Installed" | |
status="Not Installed" | |
fi | |
# Output Apache version and status | |
echo "<result>$apacheVersion - $status</result>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment