aboutsummaryrefslogtreecommitdiff
path: root/raspberry/.local/bin/services-status.sh
blob: 5eabee2b2a6b63bddcfb212090f7711cae8cd131 (plain)
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
#!/bin/sh
SERVICES="nginx taskd syncthing@eug-vs sshd iwd chronyd"
USER_SERVICES="spotifyd"

RED='\033[1;31m'
GREEN='\033[1;32m'
NC='\033[0m' # No Color

for SERVICE in $SERVICES $USER_SERVICES; do
  if [[ $(echo $USER_SERVICES | grep $SERVICE) ]]; then
    SYSTEMD="systemctl --user"
  else
    SYSTEMD="systemctl"
  fi;

  IS_ACTIVE=$($SYSTEMD is-active $SERVICE)

  if [[ "$IS_ACTIVE" == 'active' ]]; then
    INDICATOR="$GREEN *$NC"
    STATUS="$GREEN $IS_ACTIVE $NC"
  else
    STATUS="$RED $IS_ACTIVE $NC"
    INDICATOR="$RED *$NC"
  fi;

  echo -e "$INDICATOR $SERVICE $STATUS"
done;