-
Notifications
You must be signed in to change notification settings - Fork 9
/
view_logs.sh
executable file
·111 lines (101 loc) · 4.09 KB
/
view_logs.sh
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Author: coincashew.eth | coincashew.com
# License: GNU GPL
# Source: https://github.com/coincashew/ethpillar
#
# Made for home and solo stakers 🏠🥩
# Install btop process monitoring
if ! command -v btop &> /dev/null; then
sudo apt-get install btop -y
fi
# Install tmux
if ! command -v tmux &> /dev/null; then
sudo apt-get install tmux -y
fi
# Check if the current user belongs to the systemd-journal group
current_user=$(whoami)
group_members=$(getent group systemd-journal | cut -d: -f2-)
if ! echo "$group_members" | grep -qE -o -- "$current_user"; then
clear
# Add the user to the systemd-journal group if they're not already a member
sudo usermod -aG systemd-journal $current_user
echo -e "\033[1m########## New Terminal Session Required ############"
echo "To view logs, $current_user has been added to systemd-journal group."
echo "Open a new terminal, run 'ethpillar', then check logs again."
echo "Press ENTER to continue"
read
exit 0
fi
# Enable truecolor logs for btop
if [[ ! -f ~/.tmux.conf ]]; then
cat << EOF > ~/.tmux.conf
set-option -g terminal-overrides ",*:Tc"
EOF
fi
# Kill prior session
tmux kill-session -t logs
# Get terminal width
cols=$(tput cols)
# Portrait view for narrow terminals <= 80 col
if [[ $cols -lt 81 ]]; then
if [[ -f /etc/systemd/system/execution.service ]] && [[ -f /etc/systemd/system/consensus.service ]] && [[ -f /etc/systemd/system/validator.service ]]; then
# Solo Staking Node
tmux new-session -d -s logs \; \
send-keys 'journalctl -fu consensus | ccze -A' C-m \; \
split-window -v \; \
send-keys 'journalctl -fu validator | ccze -A' C-m \; \
select-pane -t 0 \; \
split-window -v \; \
send-keys 'journalctl -fu execution | ccze -A' C-m \; \
select-layout even-vertical \;
elif [[ -f /etc/systemd/system/execution.service ]] && [[ -f /etc/systemd/system/consensus.service ]]; then
# Full Node Only
tmux new-session -d -s logs \; \
send-keys 'journalctl -fu consensus | ccze -A' C-m \; \
split-window -h \; \
select-pane -t 1 \; \
send-keys 'journalctl -fu execution | ccze -A' C-m \; \
select-layout even-vertical \;
elif [[ -f /etc/systemd/system/validator.service ]]; then
# Validator Client Only
tmux new-session -d -s logs \; \
send-keys 'journalctl -fu validator | ccze -A' C-m \; \
split-window -h \; \
select-pane -t 1 \; \
send-keys 'btop --utf-force' C-m \; \
select-layout even-vertical \;
fi
else
# Create full screen panes for validator node or non-staking node
if [[ -f /etc/systemd/system/execution.service ]] && [[ -f /etc/systemd/system/consensus.service ]] && [[ -f /etc/systemd/system/validator.service ]]; then
# Solo Staking Node
tmux new-session -d -s logs \; \
send-keys 'journalctl -fu consensus | ccze -A' C-m \; \
split-window -h \; \
send-keys 'btop --utf-force' C-m \; \
split-window -v \; \
send-keys 'journalctl -fu validator | ccze -A' C-m \; \
select-pane -t 0 \; \
split-window -v \; \
send-keys 'journalctl -fu execution | ccze -A' C-m \;
elif [[ -f /etc/systemd/system/execution.service ]] && [[ -f /etc/systemd/system/consensus.service ]]; then
# Full Node Only
tmux new-session -d -s logs \; \
send-keys 'journalctl -fu consensus | ccze -A' C-m \; \
split-window -v \; \
split-window -h \; \
send-keys 'btop --utf-force' C-m \; \
select-pane -t 1 \; \
send-keys 'journalctl -fu execution | ccze -A' C-m \;
elif [[ -f /etc/systemd/system/validator.service ]]; then
# Validator Client Only
tmux new-session -d -s logs \; \
send-keys 'journalctl -fu validator | ccze -A' C-m \; \
split-window -h \; \
select-pane -t 1 \; \
send-keys 'btop --utf-force' C-m \; \
select-layout even-vertical \;
fi
fi
# Attach to the tmux session
tmux attach-session -t logs