Extension Attribute Apache version and whether it is active

A Jamf 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>"

view raw

Apache-Status

hosted with ❤ by GitHub

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *