Skip to content

Instantly share code, notes, and snippets.

@tpopela
Created March 15, 2019 10:11
Show Gist options
  • Save tpopela/0f0e6af3e0b5dcc12f2a1376e7d78afd to your computer and use it in GitHub Desktop.
Save tpopela/0f0e6af3e0b5dcc12f2a1376e7d78afd to your computer and use it in GitHub Desktop.
Restart iceccd service if ethernet connection changes
#!/bin/bash
# Restarts iceccd service if ethernet connection changes
#
# Put it under /etc/NetworkManager/dispatcher.d/
IF=$1
STATUS=$2
ETHERNET_IFACES=`nmcli device status | grep ethernet | awk '{ print $1 }'`
for ETHERNET_IF in $ETHERNET_IFACES; do
if [ "$ETHERNET_IF" == "$IF" ]; then
case "$2" in
up)
logger -s "Restarting iceccd.service"
systemctl restart iceccd.service
exit 0
;;
down)
logger -s "Restarting iceccd.service"
systemctl restart iceccd.service
exit 0
;;
*)
;;
esac
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment