Created
July 17, 2014 01:47
-
-
Save h2onda/799d9541c518b3d7b832 to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| # | |
| # nm-dispatcher.d-rsyslog NetworkManager dispatcher script for Rsyslog | |
| # | |
| # Description: | |
| # This script restart rsyslog when hostname is updated (ex. hostname via dhcp). | |
| # Because new hostname is not applied until rsyslog restarted (ex. via logrotate). | |
| # | |
| # Installation: | |
| # # install nm-dispatcher.d-rsyslog /etc/NetworkManager/dispatcher.d/99-rsyslog | |
| # | |
| prog=$(basename $0) | |
| # Enable update hostname action (default is 1) | |
| ENABLE_UPDATE_HOSTNAME_ACTION=1 | |
| # Override config | |
| [ -f /etc/sysconfig/rsyslog ] && . /etc/sysconfig/rsyslog | |
| function rsyslog_update_hostname() { | |
| systemctl reload-or-restart rsyslog.service | |
| rv=$? | |
| if [ $rv -ne 0 ]; then | |
| echo "${prog}: Failed to restart rsyslog.service" | |
| else | |
| echo "${prog}: Successfully restart rsyslog.service" | |
| fi | |
| return $rv | |
| } | |
| interface=$1 | |
| action=$2 | |
| [ $ENABLE_UPDATE_HOSTNAME_ACTION -ne 1 ] && exit 0 | |
| case "$action" in | |
| hostname) | |
| rsyslog_update_hostname | |
| ;; | |
| esac | |
| exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment