Skip to content

Instantly share code, notes, and snippets.

@jochumdev
Last active August 29, 2015 14:12
Show Gist options
  • Save jochumdev/71fb385761e8e5be6687 to your computer and use it in GitHub Desktop.
Save jochumdev/71fb385761e8e5be6687 to your computer and use it in GitHub Desktop.
Auto restart Sixx's aiccu when a interface managed networkmanager goes up/down.
#!/bin/bash
# -*- coding: utf-8 -*-
# Restarts aiccu if the given $IF is in $AICCU_RESTART_INTERFACES.
# The init/upstart/systemd script should check the rest.
#
# Copyright (c) 2014 by pcdummy <[email protected]>
#
# You need an array "AICCU_RESTART_INTERFACES" in /etc/default/aiccu,
# with the interfaces you want to restart on.
#
# Example:
# AICCU_RESTART_INTERFACES="eth0 wlan0 ppp0"
#
# Manual Running/Test: ./99-aiccu eth0 up
PATH=/bin:/sbin:/usr/sbin:/usr/bin
[ -e /etc/default/aiccu ] && source /etc/default/aiccu
IF=$1
ACTION=$2
logger "NetworkManager dispatcher aiccu running with args if=$IF action=$ACTION"
# https://stackoverflow.com/questions/3685970
if [[ ! " ${AICCU_RESTART_INTERFACES[@]} " =~ " ${IF} " ]]; then
logger "aiccu NetworkManager dispatcher: \"${IF}\" not in \"${AICCU_RESTART_INTERFACES[@]}\""
exit 0
fi
if [ "x${ACTION}" = "xup" ] || [ "x${ACTION}" = "xdown" ]; then
/etc/init.d/aiccu restart > /dev/null 2>&1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment