diff options
author | Andrew Cady <d@cryptonomic.net> | 2021-10-19 07:44:42 -0400 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2021-10-19 07:44:42 -0400 |
commit | 01144e666dd1b3daed500ab230fbc7d0266962da (patch) | |
tree | 77af1166d631458c3f073e4cf3c66add9bf862d2 | |
parent | cdca287a2d0b9941acafe1629ef1d1ee4285e95b (diff) |
add command fireslay
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | fireslay | 38 |
2 files changed, 39 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | BINDIR = /usr/local/bin | 1 | BINDIR = /usr/local/bin |
2 | BINARIES = sliceweasel | 2 | BINARIES = sliceweasel fireslay |
3 | SUDO != [ "$$(id -u)" = 0 ] || echo sudo | 3 | SUDO != [ "$$(id -u)" = 0 ] || echo sudo |
4 | 4 | ||
5 | .PHONY: install install-bin | 5 | .PHONY: install install-bin |
diff --git a/fireslay b/fireslay new file mode 100755 index 0000000..1826561 --- /dev/null +++ b/fireslay | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | set -e | ||
3 | d=$(mktemp -d) | ||
4 | trap "cd /; rm -r '$d'" EXIT | ||
5 | cd "$d" | ||
6 | |||
7 | web_content_pids() | ||
8 | { | ||
9 | top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | { | ||
10 | while read line | ||
11 | do set -- $line | ||
12 | [ "${12} ${13}" = "Web Content" ] || continue | ||
13 | echo $1 | ||
14 | done | ||
15 | } | ||
16 | } | ||
17 | |||
18 | lesser_tabs() | ||
19 | { | ||
20 | web_content_pids > pids | ||
21 | if [ $(wc -l < pids) -gt 1 ] | ||
22 | then | ||
23 | sed 1d < pids | tac | ||
24 | fi | ||
25 | } | ||
26 | |||
27 | FIRST=y | ||
28 | for tab in $(lesser_tabs) | ||
29 | do | ||
30 | if [ "$FIRST" ] | ||
31 | then | ||
32 | FIRST= | ||
33 | ps $tab | ||
34 | (set -x | ||
35 | kill "$tab") | ||
36 | fi | ||
37 | ps $tab | ||
38 | done | ||