1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00
iiab/roles/1-prep/templates/iiab-network-reset
2019-04-13 20:51:07 -07:00

85 lines
2.4 KiB
Bash
Executable file

#!/bin/bash
# if called w/ parameter, skip the reset, create diagnostic package w/ param as file name
SCRIPTDIR=$(cd `dirname $0` pwd)
diagnose_name=
if [ $# -ne 0 ]; then
basket=$1
diagnose_name=$1
else
basket=netlog.$$
fi
# collect all the network info in one place
mkdir -p /tmp/$basket
cat << EOF > /tmp/script2overview
#!/bin/bash
# generate the body overview part diagnostic package about network
echo "=========================================================="
echo iiab.env
cat /etc/iiab/iiab.env
echo "=========================================================="
echo ifconfig
ifconfig
echo
echo "=========================================================="
echo ip addr
ip addr
echo
echo "=========================================================="
echo "brctl show"
brctl show
echo
echo "=========================================================="
echo "/etc/resolv.conf"
cat /etc/resolv.conf
echo
echo "=========================================================="
echo "cat {{ iiab_ini_file }}"
cat {{ iiab_ini_file }}
echo
echo "=========================================================="
echo "routing table"
netstat -rn
echo
echo "=========================================================="
echo "install log -- last 50 lines"
tail -50 /opt/iiab/iiab/iiab-install.log
echo
echo "=========================================================="
echo "iiab-network log -- last 50 lines"
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
tail -50 /opt/iiab/iiab/iiab-network.log
else
echo no iiab-network.log
fi
echo
echo "=========================================================="
EOF
chmod 755 /tmp/script2overview
/tmp/script2overview > /tmp/$basket/overview
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
cp /opt/iiab/iiab/iiab-network.log /tmp/$basket
else
touch /tmp/$basket/no_iiab-network.log
fi
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
cp -p /opt/iiab/iiab/iiab-network.log /tmp/$basket
fi
mkdir -p /etc/iiab/diagnose/
if [ ! -z $diagnose_name ];then
pushd /tmp > /dev/null
tar czf /etc/iiab/diagnose/$basket.tgz $basket/*
popd > /dev/null
rm -rf /tmp/$basket
exit 0
else
pushd /tmp > /dev/null
tar czf /etc/iiab/diagnose/$basket.tgz $basket/*
popd > /dev/null
rm -rf /tmp/$basket
fi
echo -e "\n\nAll Network variables erased. Now run 'iiab-network' to set up the new network configuration.\n\nPlease see /opt/iiab/iiab/docs/GETTING_HELP.rst for ways to get help or \nprovide the feedback which will improve IIAB\n\n"