Skip to content

Instantly share code, notes, and snippets.

@pcdummy pcdummy/99-aiccu.sh
Last active Aug 29, 2015

Embed
What would you like to do?
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 <aiccuscript@pc-dummy.net>
#
# 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
You can’t perform that action at this time.