Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stub IP to troubleshoot dhclient
#! /bin/bash
if ! [[ -f /jeff/ip ]]; then
mkdir /jeff
mv /sbin/ip /jeff/ip
fi
cat <<"EOF" > /sbin/ip
#! /bin/bash
#
read -a st < /proc/$$/stat
read -a ppid < /proc/${st[3]}/stat
file=$(printf '/tmp/%06d_' $$)
/jeff/ip route list table all > ${file}_01_before.txt
echo "ip $@" > ${file}_02_command.txt
/jeff/ip "$@"
rval=$?
echo "rval=${rval}" > ${file}_03_rval.txt
/jeff/ip route list table all > ${file}_04_after.txt
# Write the checklist
echo " * [ ] \`$0 $*\` [**PID=${$}** PPID=${st[3]} ${ppid[1]}] (rval=${rval}) " >> /tmp/jeff.txt
exit $rval
EOF
chmod a+x /sbin/ip
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.