kapsikkum-unmanic – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #!/bin/bash |
2 | # -*- coding: utf-8 -*- |
||
3 | ################################################################################################### |
||
4 | # |
||
5 | # Written by: Josh.5 <jsunnex@gmail.com> |
||
6 | # Date: Thu Oct 21 2020, (15:47:00 PM) |
||
7 | # |
||
8 | # Copyright: |
||
9 | # Copyright (C) Josh Sunnex - All Rights Reserved |
||
10 | # |
||
11 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
||
12 | # of this software and associated documentation files (the "Software"), to deal |
||
13 | # in the Software without restriction, including without limitation the rights |
||
14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
15 | # copies of the Software, and to permit persons to whom the Software is |
||
16 | # furnished to do so, subject to the following conditions: |
||
17 | # |
||
18 | # The above copyright notice and this permission notice shall be included in all |
||
19 | # copies or substantial portions of the Software. |
||
20 | # |
||
21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||
23 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||
24 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
||
25 | # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
||
26 | # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE |
||
27 | # OR OTHER DEALINGS IN THE SOFTWARE. |
||
28 | # |
||
29 | # |
||
30 | ################################################################################################### |
||
31 | |||
32 | |||
33 | SCRIPT_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ); |
||
34 | |||
35 | config_dir=${SCRIPT_PATH}/../dev_environment/config |
||
36 | unmanic_dev_logs_dir=${config_dir}/.unmanic/logs |
||
37 | |||
38 | |||
39 | if ! command -v grcat &> /dev/null; then |
||
40 | echo "This script needs 'grcat' for formatting the logs." |
||
41 | echo "You must first install the 'grc' package..." |
||
42 | echo |
||
43 | echo " Debian/Ubuntu: apt-get install grc" |
||
44 | echo " Arch Linux: pacman -S grc" |
||
45 | echo " Fedora: dnf install grc" |
||
46 | exit 1 |
||
47 | fi |
||
48 | |||
49 | # Parse args for what logs to tail and what filters to apply |
||
50 | log_dir="${unmanic_dev_logs_dir}" |
||
51 | logfiles="unmanic.log" |
||
52 | for ARG in ${@}; do |
||
53 | case ${ARG} in |
||
54 | --local) |
||
55 | log_dir="${HOME}/.unmanic/logs"; |
||
56 | ;; |
||
57 | --tornado) |
||
58 | logfiles="${logfiles} tornado.log"; |
||
59 | ;; |
||
60 | --filters*) |
||
61 | # EG: ":DEBUG:" |
||
62 | filters=$(echo ${ARG} | awk -F'=' '{print $2}'); |
||
63 | ;; |
||
64 | *) |
||
65 | echo "Unrecognised param. Exiting!" |
||
66 | exit 1 |
||
67 | ;; |
||
68 | esac |
||
69 | done |
||
70 | |||
71 | if [[ -z ${filters} ]]; then |
||
72 | pushd "${log_dir}" || exit 1 |
||
73 | tail -fn10 ${logfiles} | grcat ${SCRIPT_PATH}/../docker/root/.grc.conf.unmanic.logs |
||
74 | popd &> /dev/null || exit 1 |
||
75 | else |
||
76 | pushd "${log_dir}" || exit 1 |
||
77 | echo "Filter logs with '${filters}'" |
||
78 | tail -fn10 ${logfiles} | stdbuf -o0 grep -v "${filters}" | grcat ${SCRIPT_PATH}/../docker/root/.grc.conf.unmanic.logs |
||
79 | popd &> /dev/null || exit 1 |
||
80 | fi |