OILS / soil / diagnose.sh View on Github | oilshell.org

140 lines, 96 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# soil/diagnose.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10source devtools/task-five.sh
11source soil/common.sh # dump-env
12
13dump-timezone() {
14
15 # On Travis:
16 # /usr/share/zoneinfo/UTC
17 # On my machine
18 # /usr/share/zoneinfo/America/Los_Angeles
19
20 if command -v file; then
21 file '/etc/localtime'
22 fi
23 echo
24 read md5 _ <<< $(md5sum /etc/localtime)
25 log "md5 = $md5"
26 find /usr/share/zoneinfo -type f | xargs md5sum | grep $md5
27 echo
28}
29
30dump-versions() {
31 set +o errexit
32
33 source build/dev-shell.sh # python3 may be here
34
35 set -x
36 which python2
37 python2 -V
38
39 which python3
40 python3 -V
41 set +x
42}
43
44dump-locale() {
45 set -x
46 # show our locale
47 locale
48
49 # show all locales
50 locale -a
51 set +x
52}
53
54dump-hardware() {
55 egrep '^(processor|model name)' /proc/cpuinfo
56 echo
57
58 egrep '^Mem' /proc/meminfo
59 echo
60
61 df -h
62 echo
63}
64
65dump-distro() {
66 local path=/etc/os-release
67 if test -f $path; then
68 cat $path
69 else
70 echo "$path doesn't exist"
71 fi
72 echo
73
74 if command -v apt-cache > /dev/null; then
75 apt-cache policy r-base-core
76 fi
77}
78
79dump-user-host() {
80 echo -n 'whoami = '
81 whoami
82 echo
83
84 echo "PWD = $PWD"
85 echo
86
87 if command -v hostname > /dev/null; then
88 echo -n 'hostname = '
89 hostname
90 else
91 # Fedora
92 echo 'hostname command missing'
93 fi
94 echo
95
96 uname -a
97 echo
98
99 who
100 echo
101}
102
103dump-tty() {
104 echo TTY
105 tty || true
106}
107
108os-info() {
109 dump-user-host
110 echo
111
112 dump-tty
113 echo
114
115 dump-distro
116 echo
117
118 dump-versions
119 echo
120
121 dump-locale
122 echo
123
124 dump-timezone
125 echo
126
127 dump-hardware
128 echo
129
130 # Process limits
131 echo 'Soft limits:'
132 ulimit -S -a
133 echo
134 echo 'Hard limits:'
135 ulimit -H -a
136 echo
137}
138
139task-five "$@"
140