Skip to content

Instantly share code, notes, and snippets.

@patent-ed
Created July 5, 2023 16:56
Show Gist options
  • Save patent-ed/76492c101a1219f5cc8e729b397e3360 to your computer and use it in GitHub Desktop.
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
#!/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