OLD | NEW |
| (Empty) |
1 #!/bin/sh | |
2 # | |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 # | |
7 # Copies all logs, screen-shots, crash dumps to Downloads folder. | |
8 | |
9 # Help information about script usage | |
10 if ([ "$1" = -h ] || [ "$1" = -? ]); then | |
11 echo "Usage of generate_logs script:" | |
12 echo "To collect logs, dumps and screenshots: sh $0" | |
13 echo "To collect data and clear up folders: sh $0 --delete" | |
14 echo "Collected data is zipped to tar.bz2 file with timestamp in Downloads" | |
15 exit 1 | |
16 fi | |
17 | |
18 echo "Collecting logs for $USER user" | |
19 home_dir=/home/$USER/user | |
20 | |
21 # Creating folder to copy logs, screenshots and dumps | |
22 log_dir=$home_dir/Downloads/diagnostic_logs | |
23 mkdir -p $log_dir | |
24 sudo rm -rf $log_dir/* | |
25 echo "Created log folder in Downloads" | |
26 | |
27 # Copying file with current timestamp and date | |
28 date > $log_dir/timestamp.txt | |
29 echo "Copied current timestamp" | |
30 | |
31 # Copying lsb-release file | |
32 sudo cp /etc/lsb-release $log_dir | |
33 echo "Copied lsb-release file with version information" | |
34 | |
35 # Copying logs- windows manager, screen-locker, messages, session_manager | |
36 mkdir $log_dir/system_level_logs | |
37 cp -r /var/log/messages \ | |
38 /var/log/session_manager \ | |
39 /var/log/softwareupdate.log \ | |
40 /var/log/update_engine.log \ | |
41 /var/log/window_manager \ | |
42 $log_dir/system_level_logs | |
43 cp -rf $home_dir/log $log_dir/user_level_logs | |
44 echo "Copied relevant logs" | |
45 | |
46 # Copying screen-shots | |
47 cp -rf $home_dir/Downloads/Screenshots $log_dir/screenshots 2> /dev/null && \ | |
48 echo "Copied screen-shots" | |
49 | |
50 # Copying crash dumps and deleting from original location | |
51 cp -rf $home_dir/.config/google-chrome/Crash\ Reports $log_dir/crashdumps 2> \ | |
52 /dev/null && echo "Copied crash dumps" | |
53 | |
54 # Compressing the log folder with all collected files | |
55 currentdate=$(date +%m%d%y-%H%M%S) | |
56 tar cjfP $home_dir/Downloads/log-$currentdate.tar.bz2 $log_dir/ | |
57 sudo rm -rf $log_dir/* | |
58 echo "Files zipped to folder under Downloads : log-$currentdate.tar.bz2" | |
59 | |
60 # Deleting logs, dumps, screenshots from original location with flag -delete | |
61 if [ "$1" = --delete ]; then | |
62 echo "Deleting all logs " | |
63 sudo rm -rf /var/log/messages \ | |
64 /var/log/session_manager \ | |
65 /var/log/softwareupdate.log \ | |
66 /var/log/update_engine.log \ | |
67 /var/log/window_manager/* | |
68 sudo rm -rf $home_dir/log/* | |
69 | |
70 echo "Deleting crash dumps" | |
71 sudo rm -rf $home_dir/.config/google-chrome/Crash\ Reports/* | |
72 | |
73 echo "Deleting screen-shots" | |
74 sudo rm -rf $home_dir/Downloads/Screenshots/* | |
75 | |
76 # Reboot after deleting all files | |
77 echo "Rebooting system after clean up in 1 minute" | |
78 sudo shutdown -r 1 | |
79 else | |
80 echo "Logs and dumps are copied but not deleted." | |
81 echo "To clear all logs, run the script with --delete flag" | |
82 fi | |
OLD | NEW |