ioemu/sub-view/systemd

46 lines
946 B
Plaintext
Raw Normal View History

#!/bin/bash
# (1) Primary init.
#--------------------------------------------------------#
# (1) Get absolute folder #
ROOT=$(dirname `realpath $0`);
ROOT=`dirname $ROOT`;
# (2) Check lock file #
test ! -f $ROOT/.lock && echo "Daemon not started" && exit 1;
# (2) While viewing loop
#--------------------------------------------------------#
# (1) Initialise vars #
declare -A SERV;
# (2) Get BUF_IN #
source $ROOT/com/config_ioemu;
# (3) For each service update #
while sleep 1; clear; do
# (4) Get last value from lines beginning by 'GSTA' #
SERV_LIST="`cat $BUF_IN | grep -Po "^SYSD(.+)$" | sed 's/^SYSD\(.\+\)$/\1/g' | tail -n20`";
# (5) Store each service #
while IFS= read -r line; do
SERV["${line:1}"]="${line:0:1}";
done <<< "$SERV_LIST";
# (6) Display each service #
for s in "${!SERV[@]}"; do
# if active -> green
test "${SERV[$s]}" = "1" && echo -e "\e[32m$s\e[0m" || echo -e "\e[0m$s\e[0m";
done;
done;