Skip to content

Instantly share code, notes, and snippets.

@anoduck
Last active November 5, 2022 06:33
Show Gist options
  • Save anoduck/9dd45c15479fc1159b612015993e0a21 to your computer and use it in GitHub Desktop.
Save anoduck/9dd45c15479fc1159b612015993e0a21 to your computer and use it in GitHub Desktop.
ifplugd ifupdown action script (see https://linux.die.net/man/8/ifplugd)
#!/bin/sh
set -e
set -o errexit
set -o nounset
if [ -z "$1" ] || [ -z "$2" ] ; then
echo "Wrong arguments" > /dev/stderr
exit 1
fi
case "$2" in
up)
/usr/bin/ip link set $1 up
[ "$2" = "up" ] && exec /usr/sbin/dhclient $1
;;
down)
if [ "$2" = "down" ]; then
/usr/sbin/dhclient -x
/usr/bin/ip link set $1 down
fi
;;
esac
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment