Created
August 14, 2023 01:49
-
-
Save ferbass/2b53ce08a9fec2eb98fb499dc5fda27a to your computer and use it in GitHub Desktop.
Post to slack if your host requires reboot
This file contains hidden or 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
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
if [[ "${TRACE-0}" == "1" ]]; then | |
set -o xtrace | |
fi | |
# Function to send a message to Slack | |
send_slack_notification() { | |
message="Reboot is required on $(hostname)" | |
slack_webhook_url="YOUR_SLACK_WEBHOOK" | |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$message\"}" "$slack_webhook_url" | |
} | |
# Check if a reboot is required | |
if [ -e /var/run/reboot-required ]; then | |
send_slack_notification | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment