Skip to content

Commit

Permalink
Add facts.d script to monitor deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
threepistons committed Mar 24, 2023
1 parent ad70494 commit cb8185d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions facts.d/lithnet_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Apt is advertised as having an unstable command-line interface. The format of /var/lib/dpkg/status seems stable and grep will return 0 on finding one or more matches, 1 for no matches.
grep 'Package: lithnetaccessmanageragent' /var/lib/dpkg/status &> /dev/null

if [ $? != 0 ]
then echo lithnet_agent=missing
exit 0 # This bails us out of this facts script without bothering to run the rest of it
fi

# systemctl status returns 0 for running service, 4 for not running
systemctl status LithnetAccessManagerAgent &> /dev/null

if [ $? != 0 ]
then echo lithnet_agent=installed_not_running
exit 0
fi

# To get this far without falling into an exit 0, the service must be running.
echo lithnet_agent=running

0 comments on commit cb8185d

Please sign in to comment.