| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #!/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
- if [ -z ${verbose:-} ]
- then
- verbose=0
- fi
- 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_log=do_not_log_action
- if [ ${verbose} -gt 0 ] ; then
- do_log=log_action
- fi
- export do_log
- export do_action=${1:-}
- script_dir=${2:-}
- shift 2 # clean any arguments
- 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
- cd ${script_dir}
- for script_file in `ls`
- do
- if [ -x ${script_file} ]
- then
- # If file is executable
- # we SOURCE it (because exporting function
- # can't be done in sh)
- set +eu # Just to avoid that a bad script crashes all others
- . ${script_dir}/${script_file} \
- || echo "ERROR in ${script_dir}/${script_file}" >&2
- set -eu
- fi
- done
- cd - > /dev/null
|