Lots of changes

This commit is contained in:
2021-10-22 14:55:52 -04:00
parent f59e3d70e7
commit a188ea73a3
17 changed files with 1861 additions and 185 deletions

View File

@@ -13,13 +13,13 @@ installdir="/usr/local/bin/"
[[ ! -d "$installdir" ]] && mkdir -p "$installdir"
if [[ -v DEBUG ]]; then
banner="generate-motd.sh"
script="generate-motd.sh"
else
banner="$installdir/generate-motd.sh"
script="$installdir/generate-motd.sh"
[[ -f ./functions ]] && cp -f functions "$installdir"
fi
cat <<- 'EOF' > "$banner"
cat <<- 'EOF' > "$script"
#!/usr/bin/env bash
echo -n '
@@ -33,7 +33,7 @@ echo -n '
EOF
# System info
cat <<- 'EOF' >> "$banner"
cat <<- 'EOF' >> "$script"
# get load averages
IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(cat /proc/loadavg | awk '{ print $1,$2,$3 }')
# get free memory
@@ -61,7 +61,7 @@ $W Memory......: $G$USED$W used, $G$AVAIL$W avail, $G$TOTAL$W total$W"
EOF
# Disk usage
cat <<- 'EOF' >> "$banner"
cat <<- 'EOF' >> "$script"
# config
max_usage=90
bar_width=50
@@ -104,7 +104,7 @@ done
EOF
# # Disk health
# cat <<- 'EOF' >> "$banner"
# cat <<- 'EOF' >> "$script"
# # config
# MAX_TEMP=40
# # set column width
@@ -176,7 +176,7 @@ EOF
# Services
cat <<- 'EOF' >> "$banner"
cat <<- 'EOF' >> "$script"
# set column width
COLUMNS=2
# colors
@@ -216,7 +216,7 @@ EOF
# Fail2Ban
cat <<- 'EOF' >> "$banner"
cat <<- 'EOF' >> "$script"
# fail2ban-client status to get all jails, takes about ~70ms
jails=($(fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) print a[i]}'))
@@ -236,7 +236,24 @@ printf "\nfail2ban status:\n"
printf $out | column -ts $',' | sed -e 's/^/ /'
EOF
# cat <<- 'EOF' > "$banner"
# Help links
cat <<- 'EOF' >> "$script"
Cockpit (graphical admin): http://localhost:9090
Robot webcam: http://localhost:8888
Robot computer: vnc://192.168.16.101:5900
EOF
# Scheduled reboot
cat <<- "EOF" >> "$script"
if systemctl is-active scheduled-reboot.timer; then
echo -n "Next scheduled reboot: "
time=$(systemctl cat scheduled-reboot.timer | grep OnCalendar=)
time=${time#*=}
echo "$time"
fi
EOF
# cat <<- 'EOF' > "$script"
# #!/usr/bin/env bash
# [[ -v NO_MOTD ]] && exit 0
@@ -294,14 +311,14 @@ generate-services() {
[Service]
Type=simple
ExecStart=$banner > /etc/motd
ExecStart=$script > /etc/motd
[Install]
WantedBy=default.target
EOF
cat <<- 'EOF' > "$timer"
[Unit]
Description=Generate MoTD on a timer
Description=Generate MoTD every minute on a timer
[Timer]
OnCalendar=*:0/1
@@ -312,7 +329,7 @@ generate-services() {
EOF
}
chmod +x "$banner"
chmod +x "$script"
if [[ -v DEBUG ]]; then
bash generate-motd.sh