This repository has been archived by the owner on May 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
diagnose_me.sh
executable file
·89 lines (71 loc) · 2.15 KB
/
diagnose_me.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
log_file=diagnose_me.log
log() {
echo "========================================="
echo "BEGIN $1"
echo "========================================="
while read data
do
echo "[$(date +"%D %T")] $data"
done
echo "========================================="
echo "END $1"
echo "========================================="
echo
echo
}
ask_perm() {
echo -n "$1 (Y/n): "
read ans
case "$ans" in
y|Y|yes|YES|Yes) return 0 ;;
n|N|no|NO|No) return 1 ;;
*) return 0 ;;
esac
}
echo "Cleaning up after any previous runs..."
rm debug.log diagnose_me.zip diagnose_me.tcpdump diagnose_me.log nohup.out &> /dev/null
echo "Gathering basic system information..."
uname -a | log "uname" > $log_file
echo "Gathering basic network information..."
ifconfig -a | log "ifconfig" >> $log_file
netstat -rnW | log "routing tables" >> $log_file
netstat -vnlW | log "netstat" >> $log_file
which iptables &> /dev/null
if [[ $? -eq 0 ]]; then
iptables -nL | log "iptables" >> $log_file
fi
echo
echo
echo "Gathering process information..."
echo "WARNING: Process information may contain passwords!"
echo 'Check `ps auxwww` output before sending.'
ask_perm "Would you like to send process information?" && ps auxwww | log "process information" >> $log_file
echo "Starting network capture..."
nohup tcpdump -e -s 1514 -w diagnose_me.tcpdump &
echo "Starting pc_autobackup in debug mode..."
nohup ./pc_autobackup.py --debug --log_file=debug.log &
sleep 3
echo
echo
echo
echo "Please start AutoBackup on your camera..."
echo
read -p "Press [Enter] key once AutoBackup fails/finishes..."
echo "Shutting down pc_autobackup..."
pkill -f pc_autobackup
echo "Shutting down network capture..."
pkill tcpdump
cat debug.log | log "pc_autobackup debug output" >> $log_file
echo "Archiving diagnostic files..."
zip -9 diagnose_me.zip diagnose_me.log diagnose_me.tcpdump nohup.out
echo "Deleting diagnostic files..."
rm debug.log diagnose_me.tcpdump diagnose_me.log nohup.out
echo
echo
echo "Please email diagnose_me.zip to [email protected]"