statusservices.j2 379 B

123456789101112131415
  1. #!/bin/bash
  2. # {{ ansible_managed }}
  3. declare -a arr=("openvpn-client@proton" "unbound" "dhcpd")
  4. for i in "${arr[@]}"; do
  5. istatus=$(systemctl is-active $i)
  6. format="%-28s \x1b[32m%s\x1b[0m\n" # green output by default
  7. if [ "$istatus" != "active" ]; then
  8. format="%-28s \x1b[31m%s\x1b[0m\n" # make red if service not active
  9. fi
  10. printf "$format" "$i:" "$istatus"
  11. done