mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge pull request #259 from georgejhunt/flat
sync from georgejhunt:flat
This commit is contained in:
commit
74a68bed56
8 changed files with 238 additions and 140 deletions
|
@ -1,137 +0,0 @@
|
|||
#!/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 "=========================================================="
|
||||
for f in \$(ls /etc/sysconfig/network-scripts/ifcfg-*|gawk '{printf(" %s",\$1)}'); do
|
||||
echo
|
||||
echo \$f
|
||||
cat \$f
|
||||
done
|
||||
echo
|
||||
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/schoolserver/iiab/iiab-install.log
|
||||
echo
|
||||
echo "=========================================================="
|
||||
echo "iiab-network log -- last 50 lines"
|
||||
if [ -f /opt/schoolserver/iiab/iiab-network.log ]; then
|
||||
tail -50 /opt/schoolserver/iiab/iiab-network.log
|
||||
else
|
||||
echo no iiab-network.log
|
||||
fi
|
||||
echo
|
||||
echo "=========================================================="
|
||||
cat /etc/fedora-release | grep 18
|
||||
if [ \$? -eq 0 ]; then
|
||||
echo "nmcli conn list"
|
||||
nmcli conn list 3>&2
|
||||
else
|
||||
echo "nmcli conn show"
|
||||
nmcli conn show 3>&2
|
||||
fi
|
||||
echo
|
||||
echo "=========================================================="
|
||||
echo nmcli dev wifi list
|
||||
nmcli dev wifi list
|
||||
EOF
|
||||
chmod 755 /tmp/script2overview
|
||||
/tmp/script2overview > /tmp/$basket/overview
|
||||
|
||||
if [ -f /opt/schoolserver/iiab/iiab-network.log ]; then
|
||||
cp /opt/schoolserver/iiab/iiab-network.log /tmp/$basket
|
||||
else
|
||||
touch /tmp/$basket/no_iiab-network.log
|
||||
fi
|
||||
|
||||
if [ -f /etc/sysconfig/iiab_domain_name ];then
|
||||
cp -p /etc/sysconfig/iiab_domain_name /tmp/$basket
|
||||
else
|
||||
touch /tmp/$basket/iiab_domain_name_not_set
|
||||
fi
|
||||
|
||||
if [ -f /etc/sysconfig/iiab_lan_device ];then
|
||||
cp -p /etc/sysconfig/iiab_lan_device /tmp/$basket
|
||||
else
|
||||
touch /tmp/$basket/iiab_lan_device_not_set
|
||||
fi
|
||||
if [ -f /etc/sysconfig/iiab_wan_device ];then
|
||||
cp -p /etc/sysconfig/iiab_wan_device /tmp/$basket
|
||||
else
|
||||
touch /tmp/$basket/iiab_wan_device_not_set
|
||||
fi
|
||||
ls /etc/NetworkManager/system-connections > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
cp -rp /etc/NetworkManager/system-connections /tmp/$basket
|
||||
fi
|
||||
cp /etc/sysconfig/network-scripts/ifcfg-* /tmp/$basket
|
||||
if [ -f /opt/schoolserver/iiab/iiab-network.log ]; then
|
||||
cp -p /opt/schoolserver/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
|
||||
|
||||
# clear out all the memory variables and let auto-configure start from scratch
|
||||
rm -rf /etc/sysconfig/iiab_domain_name
|
||||
rm -rf /etc/sysconfig/iiab_lan_device
|
||||
rm -rf /etc/sysconfig/iiab_wan_device
|
||||
rm -rf /etc/NetworkManager/system-connestions/*
|
||||
if [ -f /etc/sysconfig/network-scripts/ifcfg-WAN ];then
|
||||
mv /etc/sysconfig/network-scripts/ifcfg-WAN /root
|
||||
echo -e "\n\nWAN setup file moved to /root for safekeeping.\n\n"
|
||||
fi
|
||||
|
||||
ls -1 /etc/sysconfig/network-scripts/ifcfg-*|grep -v -e ifcfg-lo
|
||||
if [ $? -eq 0 ]; then
|
||||
ls -1 /etc/sysconfig/network-scripts/ifcfg-*|grep -v -e ifcfg-lo|xargs rm
|
||||
fi
|
||||
|
||||
echo -e "\n\nAll Network variables erased. Now run 'iiab-network' to set up the new network configuration.\n\nPlease see /opt/schoolserver/iiab/docs/GETTING_HELP.rst for ways to get help or \nprovide the feedback which will improve XSCE\n\n"
|
|
@ -26,6 +26,12 @@
|
|||
src: roles/1-prep/templates/iiab_env.py.j2
|
||||
dest: /etc/iiab/iiab_env.py
|
||||
|
||||
- name: Put a symbolic link to diagnostic diagnostics on PATH
|
||||
file:
|
||||
src: "{{ iiab_dir }}/scripts/iiab-diagnostics"
|
||||
dest: /usr/bin/iiab-diagnostics
|
||||
state: link
|
||||
|
||||
- name: Recording STAGE 3 HAS COMPLETED =====================
|
||||
lineinfile:
|
||||
dest: "{{ iiab_env_file }}"
|
||||
|
|
14
roles/all-vars/tasks/main.yml
Normal file
14
roles/all-vars/tasks/main.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
- name: Print some debug information
|
||||
vars:
|
||||
msg: |
|
||||
Module Variables ("vars"):
|
||||
--------------------------------
|
||||
{{ vars | to_nice_json }}
|
||||
|
||||
Environment Variables ("environment"):
|
||||
--------------------------------
|
||||
{{ environment | to_nice_json }}
|
||||
|
||||
debug:
|
||||
msg: "{{ msg.split('\n') }}"
|
||||
tags: debug_info
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
vars_files:
|
||||
- vars/default_vars.yml
|
||||
- vars/{{ ansible_local.local_facts.os_ver }}.yml
|
||||
- "vars/{{ ansible_local.local_facts.os_ver }}.yml"
|
||||
- /etc/iiab/local_vars.yml
|
||||
- /etc/iiab/config_vars.yml
|
||||
|
||||
|
|
7
runrole
7
runrole
|
@ -4,8 +4,11 @@ INVENTORY="ansible_hosts"
|
|||
PLAYBOOK="run-one-role.yml"
|
||||
#PLAYBOOK="iiab-stages.yml"
|
||||
CWD=`pwd`
|
||||
|
||||
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
|
||||
if [ $# -eq 2 ]; then
|
||||
export ANSIBLE_LOG_PATH="$2"
|
||||
else
|
||||
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
|
||||
fi
|
||||
|
||||
if [ ! -f $PLAYBOOK ]; then
|
||||
echo "Exiting: IIAB Playbook not found."
|
||||
|
|
35
scripts/diagnostics_features.md
Normal file
35
scripts/diagnostics_features.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
## Objective
|
||||
* Creates a flat file which can be uploaded to pastebinit. Gathers the following:
|
||||
|
||||
1. /etc/iiab/iiab.ini
|
||||
2. /etc/iiab/iiab.env
|
||||
3. Output of /sbin/ip addr command
|
||||
4. Output of /sbin/ifconfig command
|
||||
5. Output of /sbin/brctl show
|
||||
6. /etc/resolv.conf
|
||||
7. Output of /bin/netstat -rn (routing table)
|
||||
8. Output from /bin/netstat -natp (which services have which ports)
|
||||
9. /opt/iiab/iiab-install.log
|
||||
10. /opt/iiab/iiab-debug.log
|
||||
11. /opt/iiab-network.log
|
||||
12. all ansible facts
|
||||
|
||||
contents of following directories:
|
||||
|
||||
1. /etc/network/interfaces.d (and interfaces)
|
||||
2. /etc/sysconfig/network-scripts/if-cfg*
|
||||
3. /etc/NetworkManager/system-connections
|
||||
4. /etc/systemd/network/
|
||||
|
||||
#### Suggested Usage
|
||||
1. Create a diagnostic package
|
||||
```
|
||||
sudo iiab-diagnostics
|
||||
```
|
||||
(this will generate a new file with the collected information and place it into /etc/iiab/diagnostics/)
|
||||
|
||||
2. Upload the diagnostics you have just generated to pastebinit.
|
||||
```
|
||||
pastebinit -i /etc/iiab/diagnostics/<name of file you just created>
|
||||
```
|
||||
3. Email a description of the symptoms, and how to generate them, along with the URL which was returned by the "pastebinit" command, to bugs@iiab.io.
|
9
scripts/filelist
Normal file
9
scripts/filelist
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
/etc/iiab/iiab.env
|
||||
/etc/iiab/local_vars.yml
|
||||
/etc/iiab/config_vars.yml
|
||||
/etc/iiab/iiab.ini
|
||||
/usr/bin/iiab-gen-iptables
|
||||
/etc/network/interfaces
|
||||
/etc/resolv.conf
|
||||
/etc/iiab/openvpn_handle
|
168
scripts/iiab-diagnostics
Executable file
168
scripts/iiab-diagnostics
Executable file
|
@ -0,0 +1,168 @@
|
|||
#!/bin/bash
|
||||
# create a diagnostic collection, and documet OS settings
|
||||
|
||||
read -p "\n\nPlease provide a name or nickname: (8 characters or less, no spaces) " who
|
||||
if [ -z "$who" ]; then
|
||||
who="noname"
|
||||
fi
|
||||
|
||||
# Build up a meaningful name for transmission back to the development team
|
||||
OS_VER=`cat /etc/iiab/iiab.env | grep OS_VER | cut -d'=' -f2`
|
||||
pushd /opt/iiab/iiab
|
||||
HASH=`git log --pretty=format:'g%h' -n 1`
|
||||
YMD=$(date +%y%m%d)
|
||||
popd
|
||||
|
||||
SCRIPTDIR=$(cd `dirname $0` pwd)
|
||||
diagnostics_name=${OS_VER}-$YMD-$who
|
||||
outfile=$diagnostics_name.$$
|
||||
VARS_VALUES=/tmp/all-vars
|
||||
|
||||
# record all the ansible variables
|
||||
pushd /opt/iiab/iiab > /dev/null
|
||||
# ./runrole all-vars $VARS_VALUES
|
||||
popd > /dev/null
|
||||
|
||||
# cat files in this direcory
|
||||
function cat_dir(){
|
||||
echo >>/tmp/$outfile
|
||||
echo "=IIAB=====================================================" >> /tmp/$outfile
|
||||
if [ -d "$1" ];then
|
||||
echo "Printing files in $1 directory" >> /tmp/$outfile
|
||||
echo >>/tmp/$outfile
|
||||
filelist=$(ls $1)
|
||||
if [ ! -z "$filelist" ]; then
|
||||
pushd $1
|
||||
for f in `ls *`;do
|
||||
echo "Printing contents of $f" >> /tmp/$outfile
|
||||
echo >>/tmp/$outfile
|
||||
cat $f | iconv -t UTF-8//IGNORE >> /tmp/$outfile
|
||||
done
|
||||
popd
|
||||
fi
|
||||
else
|
||||
echo "Directory $1 does not exist" >> /tmp/$outfile
|
||||
fi
|
||||
}
|
||||
|
||||
function cat_file(){
|
||||
echo >>/tmp/$outfile
|
||||
echo "=IIAB====================================================" >> /tmp/$outfile
|
||||
if [ -f $1 ];then
|
||||
echo "Printing contents of $1" >> /tmp/$outfile
|
||||
echo >>/tmp/$outfile
|
||||
if [ $# -eq 2 ];then
|
||||
echo "Printing last 100 lines" >> /tmp/$outfile
|
||||
tail -100 $1 | iconv -t UTF-8//IGNORE >> /tmp/$outfile
|
||||
else
|
||||
cat $1 | iconv -t UTF-8//IGNORE >> /tmp/$outfile
|
||||
fi
|
||||
else
|
||||
echo "File $1 does not exists" >> /tmp/$outfile
|
||||
fi
|
||||
}
|
||||
|
||||
function cat_file_list(){
|
||||
for f in $(cat filelist);do
|
||||
cat_file $f
|
||||
done
|
||||
}
|
||||
# collect all the network info in one place
|
||||
cat << EOF > /tmp/diagnostics_script
|
||||
#!/bin/bash
|
||||
# generate the body overview part diagnostic package about network
|
||||
echo "=IIAB====================================================="
|
||||
echo Diagnostics submitted by:
|
||||
echo $who
|
||||
echo "Identifier: $diagnostics_name"
|
||||
echo "=IIAB====================================================="
|
||||
echo Output from /sbin/ifconfig command
|
||||
echo
|
||||
ifconfig
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo Output fro /sbin/ip addr
|
||||
echo
|
||||
ip addr
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo Checking for information about raspberry pi base image
|
||||
echo Output from command 'cat /etc/rpi-issue'
|
||||
echo
|
||||
if [ -f /etc/rpi-issue ];then
|
||||
cat /etc/rpi-issue
|
||||
echo "stage2 = lite; stage5 = desktop SEE https://github.com/RPi-Distro/pi-gen#stage-anatomy"
|
||||
else
|
||||
echo "not a raspberry pi"
|
||||
fi
|
||||
echo "=IIAB====================================================="
|
||||
echo "/sbin/brctl show"
|
||||
echo
|
||||
brctl show
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo Output from /bin/netstat -rn
|
||||
echo "routing table"
|
||||
netstat -rn
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo "Output of /sbin/iptables-save"
|
||||
echo
|
||||
iptables-save
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
if [ -f /.iiab-image ];then
|
||||
echo "Output of /bin/cat /.iiab-image command."
|
||||
echo
|
||||
cat /.iiab-image
|
||||
else
|
||||
echo /.iiab-image does not exist.
|
||||
fi
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo "systemctl status dnsmasq"
|
||||
echo
|
||||
systemctl status dnsmasq
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo "journalctl -u dnsmasq"
|
||||
echo
|
||||
journalctl -u dnsmasq
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo "Output of command /bin/netstat -natp showing port usage"
|
||||
echo
|
||||
netstat -natp
|
||||
echo
|
||||
echo "=IIAB====================================================="
|
||||
echo "Output of command /ansible -i localhost -m setup showing all local facts."
|
||||
echo
|
||||
ansible localhost -m setup 2>/dev/null
|
||||
echo
|
||||
EOF
|
||||
chmod 755 /tmp/diagnostics_script
|
||||
/tmp/diagnostics_script > /tmp/$outfile
|
||||
|
||||
cat_file_list
|
||||
|
||||
cat_dir /etc/network/interfaces.d
|
||||
cat_dir /etc/systemd/network
|
||||
cat_dir /etc/NetworkManager/system-connections
|
||||
cat_dir /etc/sysconfig/network-scripts/if-cfg*
|
||||
|
||||
cat_file /opt/iiab/iiab/iiab-debug.log last
|
||||
cat_file /opt/iiab/iiab/iiab-install.log last
|
||||
cat_file /opt/iiab/iiab-admin-console/admin-install.log last
|
||||
|
||||
#if [ -f "$VARS_VALUES" ]; then
|
||||
# cat "$VARS_VALUES" >> /tmp/$outfile
|
||||
#fi
|
||||
|
||||
mkdir -p /etc/iiab/diagnostics
|
||||
if [ ! -z $diagnostics_name ];then
|
||||
pushd /tmp > /dev/null
|
||||
cp /tmp/$outfile /etc/iiab/diagnostics/
|
||||
popd > /dev/null
|
||||
#rm -rf /tmp/$outfile
|
||||
exit 0
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue