-
Notifications
You must be signed in to change notification settings - Fork 4
/
eos-sendlog
executable file
·84 lines (72 loc) · 2.52 KB
/
eos-sendlog
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
#!/bin/bash
# Like the "old" eos-sendlog, with an addition to take the input from multiple commands.
DIE() { echo "$progname: error: $1" >&2; exit 1; }
Verbose() { [ $verbose = yes ] && echo -e "$@" >&2 ; }
Options() {
local opts
local sopts="e:hv"
local lopts="0x0,dpaste,termbin" # pastebin options
lopts+=",expire:,help,verbose,no-yad" # general options
opts="$(/bin/getopt -o="$sopts" --longoptions "$lopts" --name "$progname" -- "$@")" || Usage 1
eval set -- "$opts"
while true ; do
case "$1" in
-h | --help) Usage 0 ;;
-v | --verbose) verbose=yes ;;
--0x0 | --dpaste | --termbin) helper_options+=("$1") ;;
-e | --expire) helper_options+=(--expire="$2"); shift ;;
--no-yad) helper_options+=($1) ;;
--) shift; break ;;
*) break ;;
esac
shift
done
[ "$1" ] && commands="$*"
}
Usage() {
cat <<EOF >&2
Usage:
1. input from one command via stdin:
<command> | $progname [$progname-options]
2. input from outputs of multiple commands:
$progname [$progname-options] "<command1> ; <command2> ; <command3> ..."
${progname}-options:
--0x0 Use only pastebin 0x0.st.
--dpaste Use only pastebin dpaste.com.
--termbin Use only pastebin termbin.com.
--help, -h This help.
--verbose, -v Be more verbose.
--expire, -e The URL will expire in X days. Default: $expire_def.
Currently supported only for 0x0.st.
--no-yad Prevent using yad messages (useful if display cannot be opened).
Without ${progname}-options the services are tried in order:
1. 0x0
2. dpaste
3. termbin
until one succeeds or all fail.
Examples:
inxi -Fza | $progname --dpaste
$progname "pacman -Qm ; lsusb"
EOF
[ "$1" ] && exit "$1"
}
Main() {
local progname=${0##*/}
local commands=""
local verbose=no
local -r expire_def=7 # days
local helper_options=(--expire=$expire_def)
Options "$@"
if [ "$commands" ] ; then
Verbose "==> input from commands..."
eos-sendlog-helper "${helper_options[@]}" "$commands"
else
Verbose "==> input from stdin..."
local -r file=$(mktemp)
chmod go-rwx $file
cat > $file
eos-sendlog-helper "${helper_options[@]}" --infile=$file
rm -f $file
fi
}
Main "$@"