/etc/network/ifupdown-scripts-zg2.d/specialcommands is in ifupdown-scripts-zg2 0.6-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #!/bin/bash
# $Header$
# IFACE = Logical interface name
# MODE = start | stop
# METHOD = manual, otherwise exit!
# IF_SCRUPn = commands to be executed on iface up
# IF_SCRDNn = commands to be executed on iface down
# this script allows to write special commands in /etc/network/interfaces.
# This is similiar to ifupdown's built-in up/down command, but allows the
# special commands to be issued in the middle of our scripts instead of
# before the first or after the last script. Additionally, we do some magic
# on the values, and save the "down" commands to the state file. This way,
# changes made to /e/n/i while the interface is up are not immediately valid.
# If the first parameter for a IF_SCRUP line begins with a single quote ',
# everything until the second single quote ' is treated as a sed expression
# to modify the command to be executed on iface down.
# - scrup1 ':' echo comment - will execute the echo command unchanged on
# iface up and iface down
# - scrup1 echo comment - will execute the echo command on iface up only
# - scrup1 's/add /del /' ip addr add dev eth0 127.0.0.1/8
# - will execute "ip addr add dev..." on iface up
# and "ip addr del dev..." on iface down
# - scrdn1 ip link set dev eth0 down
# - will execute the ip command on iface down only
. /etc/network/ifupdown-scripts-zg2.d/common-functions
case "$MODE" in
start)
# execute scrup lines and store appropriate "down" lines
# bash's set is documentedly returning the shell variable list sorted
# an explicit call to sort is therefore not needed
for R in $(set | sed -n '/^IF_SCRUP[^=]*=/{s/^\(^IF_SCRUP[^=]*\)=.*/\1/;p;}'); do
eval S=\$$R
CMD="${S##\'*\' }"
if [ "$CMD" != "$S" ]; then
# modifier given
# apply modifier
MOD="${S%\'*}"
MOD="${MOD#\'}"
DOWN="$(echo $CMD | sed "$MOD")"
add_down "scrup" "$DOWN"
fi
cmd "$CMD"
done
# store scrdn lines
# bash's set is documentedly returning the shell variable list sorted
# an explicit call to sort is therefore not needed
for R in $(set | sed -n '/^IF_SCRDN[^=]*=/{s/^\(^IF_SCRDN[^=]*\)=.*/\1/;p;}'); do
eval S=\$$R
add_down "scrdn" "$S"
cmd "$CMD"
done
;;
stop)
exec_down "scrup" "exec"
exec_down "scrdn" "exec"
;;
*)
;;
esac
# end of file
|