-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-varlog.sh
More file actions
74 lines (64 loc) · 2.23 KB
/
10-varlog.sh
File metadata and controls
74 lines (64 loc) · 2.23 KB
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
#!/usr/bin/env bash
# Author: devnull@libcrack.so
# Date: jue may 12 03:33:19 CEST 2016
# Description: /var/log/ helpers
#
###=============================================================================
### VarLog
###=============================================================================
#
# all (read archive reset)
# auth
# daemon (start stop restart check)
# messages
#
# ------------------------------------------------------------------------------
# varlog daemon='sudo tail -n 100 -f /var/log/daemon.log | ccze -A'
# varlog messages='sudo tail -n 100 -f /var/log/daemon.log | ccze -A'
###=============================================================================
export X='\e[0m'
export B='\e[1m'
export R='\e[0;31m'
export G='\e[0;32m'
export Y='\e[0;33m'
varlog(){
[[ $UID -ne 0 ]] && {
printf "${R}Got r00t?${X}\n"
return $UID
}
case $1 in
auth) [[ -z "$2" ]] && printf "Usage: ${FUNCNAME} auth ${Y}<reset|show|tail>${X}\n" && return 1 ;;
daemon) [[ -z "$2" ]] && printf "Usage: ${FUNCNAME} daemon ${Y}<reset|show|tail>${X}\n" && return 1 ;;
messages) [[ -z "$2" ]] && printf "Usage: ${FUNCNAME} messages ${Y}<reset|show|tail>${X}\n" && return 1 ;;
all) case "$2" in
aaa) echo "AAA\n" ;;
bbb) echo "BBB\n" ;;
ccc) echo "CCC\n" ;;
*|help) echo "Usage: ${FUNCNAME} $1 ${Y}<aaa|bbb|ccc>${X}\n" ;;
esac
;;
*) echo "Usage: ${FUNCNAME} ${Y}<all|auth|daemon|messages>${X}\n" ;;
esac
}
_complete_varlog(){
COMPREPLY=()
local cur prev opts word
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="all auth daemon messages"
if [[ "${prev}" == "all" ]]; then
opts="read archive reset"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}))
return 0
elif [[ "${prev}" == "daemon" ]]; then
opts="start stop restart check"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [[ "${cur}" == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}
complete -F _complete_varlog varlog