-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.log.cunt.sh
More file actions
executable file
·51 lines (39 loc) · 1.02 KB
/
script.log.cunt.sh
File metadata and controls
executable file
·51 lines (39 loc) · 1.02 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
#!/usr/bin/env bash
set -euo pipefail
NAME_PREFIX=${CUNT_NAME_PREFIX:-'nirvai_'}
get_cunt_id() {
container_id=$(docker ps -aqf "name=^${1}$")
if test ${#container_id} -gt 6; then
echo $container_id
else
container_name_with_prefix="${NAME_PREFIX}${1}"
container_id=$(docker ps -aqf "name=^${container_name_with_prefix}$")
if test ${#container_id} -gt 6; then
echo $container_id
fi
fi
echo ""
}
cmd=${1:-''}
case $1 in
disk)
name=${2:-""}
if [[ -z $name ]]; then
echo -e "syntax: logs appname"
exit 1
fi
cunt_id=$(get_cunt_id $name)
if test -z "$cunt_id"; then
echo -e "\ncouldnt find container with name $2 or ${NAME_PREFIX}${2}"
exit 1
fi
log_file_on_disk="/var/lib/docker/containers/$cunt_id/$cunt_id-json.log"
if test ! -f "$log_file_on_disk"; then
echo "no log files exist at $log_file_on_disk"
exit 0
fi
echo -e "displaying log file: $log_file_on_disk"
sudo cat $log_file_on_disk | jq
;;
*) echo -e "available cmds: disk CONTAINER_NAME" ;;
esac