#!/bin/sh if [ -z "${CONFIGURATION_DIR:-}" ] then CONFIGURATION_DIR=/etc/lfirewall . ${CONFIGURATION_DIR}/setup fi options=$(getopt -l "firewall-action,verbose" -o "fv" -- "$@") if [ $? != 0 ] ; then echo "Error while checking options ($0)">&2 exit 1 fi eval set -- "$options" set -eu firewall_action=no verbose=0 while : do if [ ${verbose} = "1" ] ; then echo "$@" fi case "$1" in -f|--firewall-action) firewall_action=yes ;; -v|--verbose) verbose=$(( verbose + 1 )) if [ ${verbose} -gt 1 ] ; then set -x fi if [ ${verbose} -gt 2 ] ; then set -v fi ;; --) shift break ;; esac shift done do_action=${1:-} script_dir=${2:-} if [ -z "${do_action}" ] ; then echo "ERROR: missing action" >&2 exit 2 fi if [ -z "${script_dir}" ] ; then echo "ERROR: missing script directory" >&2 exit 2 fi if [ ${do_action} = "do_delete" ] && [ ${firewall_action} = "yes" ] then # We do nothing in that specific case # (post-up-down) # just leave the script # because we let post-down directive # from /etc/network/interfaces # do the job exit fi set -x cd ${script_dir} for script_file in `ls` do if [ -x ${script_file} ] then # If file is executable ./${script_file} ${do_action} echo "${script_dir}/${script_file} ${do_action} done" fi done set +x cd - > /dev/null